[test] Add cs::undefined tests.

This commit is contained in:
Adam Wulkiewicz 2019-06-28 23:25:46 +02:00
parent f17be7daba
commit b73a401480
11 changed files with 1003 additions and 2 deletions

View File

@ -4,8 +4,8 @@
# Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
# Copyright (c) 2009-2018 Mateusz Loskot, London, UK.
#
# This file was modified by Oracle on 2017, 2018.
# Modifications copyright (c) 2017-2018 Oracle and/or its affiliates.
# This file was modified by Oracle on 2017, 2018, 2019.
# Modifications copyright (c) 2017-2019 Oracle and/or its affiliates.
# Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
#
# Use, modification and distribution is subject to the Boost Software License,
@ -49,6 +49,7 @@ build-project strategies ;
build-project policies ;
build-project io ;
build-project srs ;
build-project cs_undefined ;
build-project util ;
build-project views ;

View File

@ -0,0 +1,20 @@
# Boost.Geometry
#
# Copyright (c) 2019, Oracle and/or its affiliates.
#
# Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
#
# Licensed under the Boost Software License version 1.0.
# http://www.boost.org/LICENSE_1_0.txt)
test-suite boost-geometry-cs_undefined
:
[ compile distance.cpp : : csundef_distance ]
[ compile envelope_expand.cpp : : csundef_envelope_expand ]
[ compile index.cpp : : csundef_index ]
[ compile is.cpp : : csundef_is ]
[ compile measure.cpp : : csundef_measure ]
[ compile other.cpp : : csundef_other ]
[ compile relops.cpp : : csundef_relops ]
[ compile setops.cpp : : csundef_setops ]
;

View File

@ -0,0 +1,69 @@
// Boost.Geometry
// Copyright (c) 2019, Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Licensed under the Boost Software License version 1.0.
// http://www.boost.org/users/license.html
#ifndef BOOST_GEOMETRY_TEST_CS_UNDEFINED_COMMON_HPP
#define BOOST_GEOMETRY_TEST_CS_UNDEFINED_COMMON_HPP
#include <geometry_test_common.hpp>
#include <boost/geometry/geometries/geometries.hpp>
#include <boost/geometry/strategies/strategies.hpp>
#include <boost/geometry/io/wkt/read.hpp>
struct geom
{
//typedef bg::model::point<double, 2, bg::cs::cartesian> point;
typedef bg::model::point<double, 2, bg::cs::undefined> point;
typedef bg::model::box<point> box;
typedef bg::model::segment<point> segment;
typedef bg::model::linestring<point> linestring;
typedef bg::model::ring<point> ring;
typedef bg::model::polygon<point> polygon;
typedef bg::model::multi_linestring<linestring> multi_linestring;
typedef bg::model::multi_polygon<polygon> multi_polygon;
typedef bg::model::multi_point<point> multi_point;
geom()
{
pt = point(0, 0);
b = box(point(-1, -1), point(1, 1));
s = segment(point(0, 0), point(1, 1));
ls.push_back(point(0, 0));
ls.push_back(point(1, 1));
ls.push_back(point(1.1, 1.1));
r.push_back(point(0, 0));
r.push_back(point(0, 1));
r.push_back(point(1, 1));
r.push_back(point(1, 0));
r.push_back(point(0, 0));
po.outer() = r;
po.inners().push_back(ring());
po.inners().back().push_back(point(0, 0));
po.inners().back().push_back(point(0.2, 0.1));
po.inners().back().push_back(point(0.1, 0.2));
po.inners().back().push_back(point(0, 0));
mls.push_back(ls);
mpo.push_back(po);
mpt.push_back(pt);
}
point pt;
box b;
segment s;
linestring ls;
ring r;
polygon po;
multi_linestring mls;
multi_polygon mpo;
multi_point mpt;
};
#endif // BOOST_GEOMETRY_TEST_CS_UNDEFINED_COMMON_HPP

View File

@ -0,0 +1,113 @@
// Boost.Geometry
// Copyright (c) 2019, Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Licensed under the Boost Software License version 1.0.
// http://www.boost.org/users/license.html
#include "common.hpp"
#include <boost/geometry/algorithms/distance.hpp>
int test_main(int, char*[])
{
geom g;
bg::distance(g.pt, g.pt, bg::strategy::distance::pythagoras<>());
bg::distance(g.pt, g.pt, bg::strategy::distance::haversine<>());
bg::distance(g.pt, g.pt, bg::strategy::distance::geographic<>());
bg::distance(g.pt, g.mpt, bg::strategy::distance::pythagoras<>());
bg::distance(g.pt, g.mpt, bg::strategy::distance::haversine<>());
bg::distance(g.pt, g.mpt, bg::strategy::distance::geographic<>());
bg::distance(g.mpt, g.mpt, bg::strategy::distance::pythagoras<>());
bg::distance(g.mpt, g.mpt, bg::strategy::distance::haversine<>());
bg::distance(g.mpt, g.mpt, bg::strategy::distance::geographic<>());
bg::distance(g.pt, g.ls, bg::strategy::distance::projected_point<>());
bg::distance(g.pt, g.ls, bg::strategy::distance::cross_track<>());
bg::distance(g.pt, g.ls, bg::strategy::distance::geographic_cross_track<>());
bg::distance(g.pt, g.mls, bg::strategy::distance::projected_point<>());
bg::distance(g.pt, g.mls, bg::strategy::distance::cross_track<>());
bg::distance(g.pt, g.mls, bg::strategy::distance::geographic_cross_track<>());
bg::distance(g.mpt, g.ls, bg::strategy::distance::projected_point<>());
bg::distance(g.mpt, g.ls, bg::strategy::distance::cross_track<>());
bg::distance(g.mpt, g.ls, bg::strategy::distance::geographic_cross_track<>());
bg::distance(g.mpt, g.mls, bg::strategy::distance::projected_point<>());
bg::distance(g.mpt, g.mls, bg::strategy::distance::cross_track<>());
bg::distance(g.mpt, g.mls, bg::strategy::distance::geographic_cross_track<>());
bg::distance(g.ls, g.ls, bg::strategy::distance::projected_point<>());
bg::distance(g.ls, g.ls, bg::strategy::distance::cross_track<>());
bg::distance(g.ls, g.ls, bg::strategy::distance::geographic_cross_track<>());
bg::distance(g.ls, g.mls, bg::strategy::distance::projected_point<>());
bg::distance(g.ls, g.mls, bg::strategy::distance::cross_track<>());
bg::distance(g.ls, g.mls, bg::strategy::distance::geographic_cross_track<>());
bg::distance(g.mls, g.mls, bg::strategy::distance::projected_point<>());
bg::distance(g.mls, g.mls, bg::strategy::distance::cross_track<>());
bg::distance(g.mls, g.mls, bg::strategy::distance::geographic_cross_track<>());
bg::distance(g.pt, g.r, bg::strategy::distance::projected_point<>());
bg::distance(g.pt, g.r, bg::strategy::distance::cross_track<>());
bg::distance(g.pt, g.r, bg::strategy::distance::geographic_cross_track<>());
bg::distance(g.pt, g.po, bg::strategy::distance::projected_point<>());
bg::distance(g.pt, g.po, bg::strategy::distance::cross_track<>());
bg::distance(g.pt, g.po, bg::strategy::distance::geographic_cross_track<>());
bg::distance(g.pt, g.mpo, bg::strategy::distance::projected_point<>());
bg::distance(g.pt, g.mpo, bg::strategy::distance::cross_track<>());
bg::distance(g.pt, g.mpo, bg::strategy::distance::geographic_cross_track<>());
bg::distance(g.mpt, g.r, bg::strategy::distance::projected_point<>());
bg::distance(g.mpt, g.r, bg::strategy::distance::cross_track<>());
bg::distance(g.mpt, g.r, bg::strategy::distance::geographic_cross_track<>());
bg::distance(g.mpt, g.po, bg::strategy::distance::projected_point<>());
bg::distance(g.mpt, g.po, bg::strategy::distance::cross_track<>());
bg::distance(g.mpt, g.po, bg::strategy::distance::geographic_cross_track<>());
bg::distance(g.mpt, g.mpo, bg::strategy::distance::projected_point<>());
bg::distance(g.mpt, g.mpo, bg::strategy::distance::cross_track<>());
bg::distance(g.mpt, g.mpo, bg::strategy::distance::geographic_cross_track<>());
bg::distance(g.ls, g.r, bg::strategy::distance::projected_point<>());
bg::distance(g.ls, g.r, bg::strategy::distance::cross_track<>());
bg::distance(g.ls, g.r, bg::strategy::distance::geographic_cross_track<>());
bg::distance(g.ls, g.po, bg::strategy::distance::projected_point<>());
bg::distance(g.ls, g.po, bg::strategy::distance::cross_track<>());
bg::distance(g.ls, g.po, bg::strategy::distance::geographic_cross_track<>());
bg::distance(g.ls, g.mpo, bg::strategy::distance::projected_point<>());
bg::distance(g.ls, g.mpo, bg::strategy::distance::cross_track<>());
bg::distance(g.ls, g.mpo, bg::strategy::distance::geographic_cross_track<>());
bg::distance(g.mls, g.r, bg::strategy::distance::projected_point<>());
bg::distance(g.mls, g.r, bg::strategy::distance::cross_track<>());
bg::distance(g.mls, g.r, bg::strategy::distance::geographic_cross_track<>());
bg::distance(g.mls, g.po, bg::strategy::distance::projected_point<>());
bg::distance(g.mls, g.po, bg::strategy::distance::cross_track<>());
bg::distance(g.mls, g.po, bg::strategy::distance::geographic_cross_track<>());
bg::distance(g.mls, g.mpo, bg::strategy::distance::projected_point<>());
bg::distance(g.mls, g.mpo, bg::strategy::distance::cross_track<>());
bg::distance(g.mls, g.mpo, bg::strategy::distance::geographic_cross_track<>());
bg::distance(g.r, g.r, bg::strategy::distance::projected_point<>());
bg::distance(g.r, g.r, bg::strategy::distance::cross_track<>());
bg::distance(g.r, g.r, bg::strategy::distance::geographic_cross_track<>());
bg::distance(g.r, g.po, bg::strategy::distance::projected_point<>());
bg::distance(g.r, g.po, bg::strategy::distance::cross_track<>());
bg::distance(g.r, g.po, bg::strategy::distance::geographic_cross_track<>());
bg::distance(g.r, g.mpo, bg::strategy::distance::projected_point<>());
bg::distance(g.r, g.mpo, bg::strategy::distance::cross_track<>());
bg::distance(g.r, g.mpo, bg::strategy::distance::geographic_cross_track<>());
bg::distance(g.po, g.r, bg::strategy::distance::projected_point<>());
bg::distance(g.po, g.r, bg::strategy::distance::cross_track<>());
bg::distance(g.po, g.r, bg::strategy::distance::geographic_cross_track<>());
bg::distance(g.po, g.po, bg::strategy::distance::projected_point<>());
bg::distance(g.po, g.po, bg::strategy::distance::cross_track<>());
bg::distance(g.po, g.po, bg::strategy::distance::geographic_cross_track<>());
bg::distance(g.po, g.mpo, bg::strategy::distance::projected_point<>());
bg::distance(g.po, g.mpo, bg::strategy::distance::cross_track<>());
bg::distance(g.po, g.mpo, bg::strategy::distance::geographic_cross_track<>());
bg::distance(g.mpo, g.r, bg::strategy::distance::projected_point<>());
bg::distance(g.mpo, g.r, bg::strategy::distance::cross_track<>());
bg::distance(g.mpo, g.r, bg::strategy::distance::geographic_cross_track<>());
bg::distance(g.mpo, g.po, bg::strategy::distance::projected_point<>());
bg::distance(g.mpo, g.po, bg::strategy::distance::cross_track<>());
bg::distance(g.mpo, g.po, bg::strategy::distance::geographic_cross_track<>());
bg::distance(g.mpo, g.mpo, bg::strategy::distance::projected_point<>());
bg::distance(g.mpo, g.mpo, bg::strategy::distance::cross_track<>());
bg::distance(g.mpo, g.mpo, bg::strategy::distance::geographic_cross_track<>());
return 0;
}

View File

@ -0,0 +1,53 @@
// Boost.Geometry
// Copyright (c) 2019, Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Licensed under the Boost Software License version 1.0.
// http://www.boost.org/users/license.html
#include "common.hpp"
#include <boost/geometry/algorithms/envelope.hpp>
#include <boost/geometry/algorithms/expand.hpp>
int test_main(int, char*[])
{
geom g;
bg::expand(g.b, g.pt, bg::strategy::expand::cartesian_point());
bg::expand(g.b, g.pt, bg::strategy::expand::spherical_point());
bg::expand(g.b, g.b, bg::strategy::expand::cartesian_box());
bg::expand(g.b, g.b, bg::strategy::expand::spherical_box());
bg::expand(g.b, g.s, bg::strategy::expand::cartesian_segment());
bg::expand(g.b, g.s, bg::strategy::expand::spherical_segment<>());
bg::expand(g.b, g.s, bg::strategy::expand::geographic_segment<>());
bg::envelope(g.pt, g.b, bg::strategy::envelope::cartesian_point());
bg::envelope(g.pt, g.b, bg::strategy::envelope::spherical_point());
bg::envelope(g.b, g.b, bg::strategy::envelope::cartesian_box());
bg::envelope(g.b, g.b, bg::strategy::envelope::spherical_box());
bg::envelope(g.s, g.b, bg::strategy::envelope::cartesian_segment<>());
bg::envelope(g.s, g.b, bg::strategy::envelope::spherical_segment<>());
bg::envelope(g.s, g.b, bg::strategy::envelope::geographic_segment<>());
bg::envelope(g.ls, g.b, bg::strategy::envelope::cartesian<>());
bg::envelope(g.ls, g.b, bg::strategy::envelope::spherical<>());
bg::envelope(g.ls, g.b, bg::strategy::envelope::geographic<>());
bg::envelope(g.r, g.b, bg::strategy::envelope::cartesian<>());
bg::envelope(g.r, g.b, bg::strategy::envelope::spherical<>());
bg::envelope(g.r, g.b, bg::strategy::envelope::geographic<>());
bg::envelope(g.po, g.b, bg::strategy::envelope::cartesian<>());
bg::envelope(g.po, g.b, bg::strategy::envelope::spherical<>());
bg::envelope(g.po, g.b, bg::strategy::envelope::geographic<>());
bg::envelope(g.mls, g.b, bg::strategy::envelope::cartesian<>());
bg::envelope(g.mls, g.b, bg::strategy::envelope::spherical<>());
bg::envelope(g.mls, g.b, bg::strategy::envelope::geographic<>());
bg::envelope(g.mpo, g.b, bg::strategy::envelope::cartesian<>());
bg::envelope(g.mpo, g.b, bg::strategy::envelope::spherical<>());
bg::envelope(g.mpo, g.b, bg::strategy::envelope::geographic<>());
bg::envelope(g.mpt, g.b, bg::strategy::envelope::cartesian_multipoint());
bg::envelope(g.mpt, g.b, bg::strategy::envelope::spherical_multipoint());
return 0;
}

101
test/cs_undefined/index.cpp Normal file
View File

@ -0,0 +1,101 @@
// Boost.Geometry
// Copyright (c) 2019, Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Licensed under the Boost Software License version 1.0.
// http://www.boost.org/users/license.html
#include "common.hpp"
// These includes are required for the following code to compile.
// This is probably wrong.
#include <boost/geometry/algorithms/covered_by.hpp>
#include <boost/geometry/algorithms/disjoint.hpp>
#include <boost/geometry/algorithms/equals.hpp>
#include <boost/geometry/algorithms/intersects.hpp>
#include <boost/geometry/index/rtree.hpp>
#include <vector>
namespace bgi = boost::geometry::index;
template
<
typename VG, typename QG,
typename VTag = typename bg::tag<VG>::type,
typename QTag = typename bg::tag<QG>::type
>
struct call_query
{
template <typename Rtree, typename Res>
static inline void apply(Rtree const& , Res const& )
{}
};
template <typename VG, typename QG>
struct call_query<VG, QG, bg::box_tag, bg::point_tag>
{
template <typename Rtree>
static inline void apply(Rtree const& rtree, QG const& qg)
{
std::vector<VG> res;
rtree.query(bgi::intersects(qg), std::back_inserter(res));
}
};
template <typename G, typename P>
inline void rtree_test(G const& g, P const& p)
{
{
bgi::rtree<G, P> rtree;
}
std::vector<G> de2(100, g);
bgi::rtree<G, P> rtree(de2, p);
rtree.insert(g);
rtree.remove(g);
rtree.count(g);
call_query<G, geom::point>::apply(rtree, geom::point(0, 0));
}
int test_main(int, char*[])
{
geom g;
rtree_test(g.pt, bgi::parameters<bgi::linear<4>, bg::strategy::index::cartesian<> >());
rtree_test(g.pt, bgi::parameters<bgi::quadratic<4>, bg::strategy::index::cartesian<> >());
rtree_test(g.pt, bgi::parameters<bgi::rstar<4>, bg::strategy::index::cartesian<> >());
rtree_test(g.b, bgi::parameters<bgi::linear<4>, bg::strategy::index::cartesian<> >());
rtree_test(g.b, bgi::parameters<bgi::quadratic<4>, bg::strategy::index::cartesian<> >());
rtree_test(g.b, bgi::parameters<bgi::rstar<4>, bg::strategy::index::cartesian<> >());
rtree_test(g.s, bgi::parameters<bgi::linear<4>, bg::strategy::index::cartesian<> >());
rtree_test(g.s, bgi::parameters<bgi::quadratic<4>, bg::strategy::index::cartesian<> >());
rtree_test(g.s, bgi::parameters<bgi::rstar<4>, bg::strategy::index::cartesian<> >());
rtree_test(g.pt, bgi::parameters<bgi::linear<4>, bg::strategy::index::spherical<> >());
rtree_test(g.pt, bgi::parameters<bgi::quadratic<4>, bg::strategy::index::spherical<> >());
rtree_test(g.pt, bgi::parameters<bgi::rstar<4>, bg::strategy::index::spherical<> >());
rtree_test(g.b, bgi::parameters<bgi::linear<4>, bg::strategy::index::spherical<> >());
rtree_test(g.b, bgi::parameters<bgi::quadratic<4>, bg::strategy::index::spherical<> >());
rtree_test(g.b, bgi::parameters<bgi::rstar<4>, bg::strategy::index::spherical<> >());
rtree_test(g.s, bgi::parameters<bgi::linear<4>, bg::strategy::index::spherical<> >());
rtree_test(g.s, bgi::parameters<bgi::quadratic<4>, bg::strategy::index::spherical<> >());
rtree_test(g.s, bgi::parameters<bgi::rstar<4>, bg::strategy::index::spherical<> >());
rtree_test(g.pt, bgi::parameters<bgi::linear<4>, bg::strategy::index::geographic<> >());
rtree_test(g.pt, bgi::parameters<bgi::quadratic<4>, bg::strategy::index::geographic<> >());
rtree_test(g.pt, bgi::parameters<bgi::rstar<4>, bg::strategy::index::geographic<> >());
rtree_test(g.b, bgi::parameters<bgi::linear<4>, bg::strategy::index::geographic<> >());
rtree_test(g.b, bgi::parameters<bgi::quadratic<4>, bg::strategy::index::geographic<> >());
rtree_test(g.b, bgi::parameters<bgi::rstar<4>, bg::strategy::index::geographic<> >());
rtree_test(g.s, bgi::parameters<bgi::linear<4>, bg::strategy::index::geographic<> >());
rtree_test(g.s, bgi::parameters<bgi::quadratic<4>, bg::strategy::index::geographic<> >());
rtree_test(g.s, bgi::parameters<bgi::rstar<4>, bg::strategy::index::geographic<> >());
return 0;
}

44
test/cs_undefined/is.cpp Normal file
View File

@ -0,0 +1,44 @@
// Boost.Geometry
// Copyright (c) 2019, Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Licensed under the Boost Software License version 1.0.
// http://www.boost.org/users/license.html
#include "common.hpp"
#include <boost/geometry/algorithms/is_simple.hpp>
#include <boost/geometry/algorithms/is_valid.hpp>
template <typename G, typename S>
inline void is(G const& g, S const& s)
{
bg::is_simple(g, s);
bg::is_valid(g, s);
}
template <typename G>
inline void is_x(G const& g)
{
::is(g, bg::strategy::intersection::cartesian_segments<>());
::is(g, bg::strategy::intersection::spherical_segments<>());
::is(g, bg::strategy::intersection::geographic_segments<>());
}
int test_main(int, char*[])
{
geom g;
::is_x(g.pt);
::is_x(g.mpt);
::is_x(g.s);
::is_x(g.ls);
::is_x(g.mls);
::is_x(g.r);
::is_x(g.po);
::is_x(g.mpo);
return 0;
}

View File

@ -0,0 +1,51 @@
// Boost.Geometry
// Copyright (c) 2019, Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Licensed under the Boost Software License version 1.0.
// http://www.boost.org/users/license.html
#include "common.hpp"
#include <boost/geometry/algorithms/area.hpp>
#include <boost/geometry/algorithms/length.hpp>
#include <boost/geometry/algorithms/perimeter.hpp>
int test_main(int, char*[])
{
geom g;
bg::area(g.r, bg::strategy::area::cartesian<>());
bg::area(g.r, bg::strategy::area::spherical<>());
bg::area(g.r, bg::strategy::area::geographic<>());
bg::area(g.po, bg::strategy::area::cartesian<>());
bg::area(g.po, bg::strategy::area::spherical<>());
bg::area(g.po, bg::strategy::area::geographic<>());
bg::area(g.mpo, bg::strategy::area::cartesian<>());
bg::area(g.mpo, bg::strategy::area::spherical<>());
bg::area(g.mpo, bg::strategy::area::geographic<>());
bg::length(g.s, bg::strategy::distance::pythagoras<>());
bg::length(g.s, bg::strategy::distance::haversine<>());
bg::length(g.s, bg::strategy::distance::geographic<>());
bg::length(g.ls, bg::strategy::distance::pythagoras<>());
bg::length(g.ls, bg::strategy::distance::haversine<>());
bg::length(g.ls, bg::strategy::distance::geographic<>());
bg::length(g.mls, bg::strategy::distance::pythagoras<>());
bg::length(g.mls, bg::strategy::distance::haversine<>());
bg::length(g.mls, bg::strategy::distance::geographic<>());
bg::perimeter(g.r, bg::strategy::distance::pythagoras<>());
bg::perimeter(g.r, bg::strategy::distance::haversine<>());
bg::perimeter(g.r, bg::strategy::distance::geographic<>());
bg::perimeter(g.po, bg::strategy::distance::pythagoras<>());
bg::perimeter(g.po, bg::strategy::distance::haversine<>());
bg::perimeter(g.po, bg::strategy::distance::geographic<>());
bg::perimeter(g.mpo, bg::strategy::distance::pythagoras<>());
bg::perimeter(g.mpo, bg::strategy::distance::haversine<>());
bg::perimeter(g.mpo, bg::strategy::distance::geographic<>());
return 0;
}

View File

@ -0,0 +1,40 @@
// Boost.Geometry
// Copyright (c) 2019, Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Licensed under the Boost Software License version 1.0.
// http://www.boost.org/users/license.html
#include "common.hpp"
#include <boost/geometry/algorithms/centroid.hpp>
#include <boost/geometry/algorithms/simplify.hpp>
template <typename G>
inline void simplify(G const& g1, G & g2)
{
bg::simplify(g1, g2, 1, bg::strategy::simplify::douglas_peucker<geom::point, bg::strategy::distance::projected_point<> >());
bg::simplify(g1, g2, 1, bg::strategy::simplify::douglas_peucker<geom::point, bg::strategy::distance::cross_track<> >());
// TODO: douglas_peucker does not define a ctor taking distance strategy
// which is needed in geographic CS
bg::simplify(g1, g2, 1, bg::strategy::simplify::douglas_peucker<geom::point, bg::strategy::distance::geographic_cross_track<> >());
}
int test_main(int, char*[])
{
geom g, o;
// this compiles but it shouldn't!
// internally default_strategy is defined as not_applicable_strategy for box
bg::centroid(g.b, o.pt);
::simplify(g.ls, o.ls);
// TODO:
//::simplify(g.r, o.r); // area (point order) strategy not propagated
//::simplify(g.po, o.po); // area (point order) strategy not propagated
return 0;
}

View File

@ -0,0 +1,228 @@
// Boost.Geometry
// Copyright (c) 2019, Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Licensed under the Boost Software License version 1.0.
// http://www.boost.org/users/license.html
#include "common.hpp"
#include <boost/geometry/algorithms/covered_by.hpp>
#include <boost/geometry/algorithms/crosses.hpp>
#include <boost/geometry/algorithms/disjoint.hpp>
#include <boost/geometry/algorithms/equals.hpp>
#include <boost/geometry/algorithms/intersects.hpp>
#include <boost/geometry/algorithms/overlaps.hpp>
#include <boost/geometry/algorithms/relate.hpp>
#include <boost/geometry/algorithms/relation.hpp>
#include <boost/geometry/algorithms/touches.hpp>
#include <boost/geometry/algorithms/within.hpp>
template
<
typename G1,
typename G2,
std::size_t Dim1 = bg::topological_dimension<G1>::value,
std::size_t Dim2 = bg::topological_dimension<G2>::value
>
struct call_equals
{
template <typename S>
static void apply(G1 const& g1, G2 const& g2, S const& s) {}
};
template <typename G1, typename G2, std::size_t Dim>
struct call_equals<G1, G2, Dim, Dim>
{
template <typename S>
static void apply(G1 const& g1, G2 const& g2, S const& s)
{
bg::equals(g1, g2, s);
}
};
template
<
typename G1,
typename G2,
std::size_t Dim1 = bg::topological_dimension<G1>::value,
std::size_t Dim2 = bg::topological_dimension<G2>::value
>
struct call_overlaps
{
template <typename S>
static void apply(G1 const& g1, G2 const& g2, S const& s) {}
};
template <typename G1, typename G2, std::size_t Dim>
struct call_overlaps<G1, G2, Dim, Dim>
{
template <typename S>
static void apply(G1 const& g1, G2 const& g2, S const& s)
{
bg::overlaps(g1, g2, s);
}
};
template
<
typename G1,
typename G2,
std::size_t Dim1 = bg::topological_dimension<G1>::value,
std::size_t Dim2 = bg::topological_dimension<G2>::value
>
struct call_touches
{
template <typename S>
static void apply(G1 const& g1, G2 const& g2, S const& s)
{
bg::touches(g1, g2, s);
}
};
template <typename G1, typename G2>
struct call_touches<G1, G2, 0, 0>
{
template <typename S>
static void apply(G1 const& g1, G2 const& g2, S const& s) {}
};
template
<
typename G1,
typename G2,
std::size_t Dim1 = bg::topological_dimension<G1>::value,
std::size_t Dim2 = bg::topological_dimension<G2>::value
>
struct call_crosses
{
template <typename S>
static void apply(G1 const& g1, G2 const& g2, S const& s)
{
bg::crosses(g1, g2, s);
}
};
template <typename G1, typename G2>
struct call_crosses<G1, G2, 0, 0>
{
template <typename S>
static void apply(G1 const& g1, G2 const& g2, S const& s) {}
};
template <typename G1, typename G2>
struct call_crosses<G1, G2, 2, 2>
{
template <typename S>
static void apply(G1 const& g1, G2 const& g2, S const& s) {}
};
template <typename G1, typename G2, typename S>
inline void rel(G1 const& g1, G2 const& g2, S const& s)
{
bg::relation(g1, g2, s);
bg::relate(g1, g2, bg::de9im::mask("*********"), s);
bg::covered_by(g1, g2, s);
call_crosses<G1, G2>::apply(g1, g2, s);
bg::disjoint(g1, g2, s);
call_equals<G1, G2>::apply(g1, g2, s);
bg::intersects(g1, g2, s);
call_overlaps<G1, G2>::apply(g1, g2, s);
call_touches<G1, G2>::apply(g1, g2, s);
bg::within(g1, g2, s);
}
template <typename G1, typename G2>
inline void rel_pp(G1 const& g1, G2 const& g2)
{
::rel(g1, g2, bg::strategy::within::cartesian_point_point());
::rel(g1, g2, bg::strategy::within::spherical_point_point());
}
template <typename G1, typename G2>
inline void rel_ps(G1 const& g1, G2 const& g2)
{
typedef typename bg::point_type<G1>::type point;
::rel(g1, g2, bg::strategy::within::cartesian_winding<point>());
::rel(g1, g2, bg::strategy::within::spherical_winding<point>());
::rel(g1, g2, bg::strategy::within::geographic_winding<point>());
}
template <typename G1, typename G2>
inline void rel_ss(G1 const& g1, G2 const& g2)
{
::rel(g1, g2, bg::strategy::intersection::cartesian_segments<>());
::rel(g1, g2, bg::strategy::intersection::spherical_segments<>());
::rel(g1, g2, bg::strategy::intersection::geographic_segments<>());
}
int test_main(int, char*[])
{
geom g;
bg::disjoint(g.pt, g.b, bg::strategy::covered_by::cartesian_point_box());
bg::disjoint(g.pt, g.b, bg::strategy::covered_by::spherical_point_box());
bg::disjoint(g.b, g.b, bg::strategy::disjoint::cartesian_box_box());
bg::disjoint(g.b, g.b, bg::strategy::disjoint::spherical_box_box());
bg::within(g.pt, g.b, bg::strategy::within::cartesian_point_box());
bg::within(g.pt, g.b, bg::strategy::within::spherical_point_box());
bg::within(g.b, g.b, bg::strategy::within::cartesian_box_box());
bg::within(g.b, g.b, bg::strategy::within::spherical_box_box());
bg::covered_by(g.pt, g.b, bg::strategy::covered_by::cartesian_point_box());
bg::covered_by(g.pt, g.b, bg::strategy::covered_by::spherical_point_box());
bg::covered_by(g.b, g.b, bg::strategy::covered_by::cartesian_box_box());
bg::covered_by(g.b, g.b, bg::strategy::covered_by::spherical_box_box());
// P/P
::rel_pp(g.pt, g.pt);
::rel_pp(g.pt, g.mpt);
::rel_pp(g.mpt, g.mpt);
// P/L
//::rel_ps(g.pt, g.s); // relate not implemented
::rel_ps(g.pt, g.ls);
::rel_ps(g.pt, g.mls);
//::rel_ps(g.mpt, g.s); // relate not implemented
::rel_ps(g.mpt, g.ls);
::rel_ps(g.mpt, g.mls);
// P/A
::rel_ps(g.pt, g.r);
::rel_ps(g.mpt, g.r);
::rel_ps(g.pt, g.po);
::rel_ps(g.mpt, g.po);
::rel_ps(g.pt, g.mpo);
::rel_ps(g.mpt, g.mpo);
// L/L
//::rel_ss(g.s, g.s); // relate not implemented
//::rel_ss(g.s, g.ls); // relate not implemented
//::rel_ss(g.s, g.mls); // relate not implemented
//::rel_ss(g.ls, g.s); // relate not implemented
::rel_ss(g.ls, g.ls);
::rel_ss(g.ls, g.mls);
//::rel_ss(g.mls, g.s); // relate not implemented
::rel_ss(g.mls, g.ls);
::rel_ss(g.mls, g.mls);
// L/A
//::rel_ss(g.s, g.r); // relate not implemented
::rel_ss(g.ls, g.r);
::rel_ss(g.mls, g.r);
//::rel_ss(g.s, g.po); // relate not implemented
::rel_ss(g.ls, g.po);
::rel_ss(g.mls, g.po);
//::rel_ss(g.s, g.mpo); // relate not implemented
::rel_ss(g.ls, g.mpo);
::rel_ss(g.mls, g.mpo);
// A/A
::rel_ss(g.r, g.r);
::rel_ss(g.po, g.r);
::rel_ss(g.mpo, g.r);
::rel_ss(g.r, g.po);
::rel_ss(g.po, g.po);
::rel_ss(g.mpo, g.po);
::rel_ss(g.r, g.mpo);
::rel_ss(g.po, g.mpo);
::rel_ss(g.mpo, g.mpo);
return 0;
}

View File

@ -0,0 +1,281 @@
// Boost.Geometry
// Copyright (c) 2019, Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Licensed under the Boost Software License version 1.0.
// http://www.boost.org/users/license.html
#include "common.hpp"
#include <boost/geometry/algorithms/difference.hpp>
#include <boost/geometry/algorithms/intersection.hpp>
#include <boost/geometry/algorithms/sym_difference.hpp>
#include <boost/geometry/algorithms/union.hpp>
template <typename G1, typename G2, typename G3, typename S>
inline void set_idsu(G1 const& g1, G2 const& g2, G3 & g3, S const& s)
{
bg::intersection(g1, g2, g3, s);
bg::difference(g1, g2, g3, s);
bg::sym_difference(g1, g2, g3, s);
bg::union_(g1, g2, g3, s);
}
template <typename G1, typename G2, typename G3, typename S>
inline void set_ids(G1 const& g1, G2 const& g2, G3 & g3, S const& s)
{
bg::intersection(g1, g2, g3, s);
bg::difference(g1, g2, g3, s);
bg::sym_difference(g1, g2, g3, s);
}
template <typename G1, typename G2, typename G3, typename S>
inline void set_id(G1 const& g1, G2 const& g2, G3 & g3, S const& s)
{
bg::intersection(g1, g2, g3, s);
bg::difference(g1, g2, g3, s);
}
template <typename G1, typename G2, typename G3, typename S>
inline void set_i(G1 const& g1, G2 const& g2, G3 & g3, S const& s)
{
bg::intersection(g1, g2, g3, s);
}
template <typename G1, typename G2, typename G3, typename S>
inline void set_d(G1 const& g1, G2 const& g2, G3 & g3, S const& s)
{
bg::difference(g1, g2, g3, s);
}
template <typename G1, typename G2, typename G3>
inline void set_idsu_pp(G1 const& g1, G2 const& g2, G3 & g3)
{
::set_idsu(g1, g2, g3, bg::strategy::within::cartesian_point_point());
::set_idsu(g1, g2, g3, bg::strategy::within::spherical_point_point());
}
template <typename G1, typename G2, typename G3>
inline void set_idsu_ps(G1 const& g1, G2 const& g2, G3 & g3)
{
typedef typename bg::point_type<G1>::type point_type;
::set_idsu(g1, g2, g3, bg::strategy::within::cartesian_winding<point_type>());
::set_idsu(g1, g2, g3, bg::strategy::within::spherical_winding<point_type>());
::set_idsu(g1, g2, g3, bg::strategy::within::geographic_winding<point_type>());
}
template <typename G1, typename G2, typename G3>
inline void set_idsu_ss(G1 const& g1, G2 const& g2, G3 & g3)
{
::set_idsu(g1, g2, g3, bg::strategy::intersection::cartesian_segments<>());
::set_idsu(g1, g2, g3, bg::strategy::intersection::spherical_segments<>());
::set_idsu(g1, g2, g3, bg::strategy::intersection::geographic_segments<>());
}
template <typename G1, typename G2, typename G3>
inline void set_ids_pp(G1 const& g1, G2 const& g2, G3 & g3)
{
::set_ids(g1, g2, g3, bg::strategy::within::cartesian_point_point());
::set_ids(g1, g2, g3, bg::strategy::within::spherical_point_point());
}
template <typename G1, typename G2, typename G3>
inline void set_ids_ps(G1 const& g1, G2 const& g2, G3 & g3)
{
typedef typename bg::point_type<G1>::type point_type;
::set_ids(g1, g2, g3, bg::strategy::within::cartesian_winding<point_type>());
::set_ids(g1, g2, g3, bg::strategy::within::spherical_winding<point_type>());
::set_ids(g1, g2, g3, bg::strategy::within::geographic_winding<point_type>());
}
template <typename G1, typename G2, typename G3>
inline void set_ids_ss(G1 const& g1, G2 const& g2, G3 & g3)
{
::set_ids(g1, g2, g3, bg::strategy::intersection::cartesian_segments<>());
::set_ids(g1, g2, g3, bg::strategy::intersection::spherical_segments<>());
::set_ids(g1, g2, g3, bg::strategy::intersection::geographic_segments<>());
}
template <typename G1, typename G2, typename G3>
inline void set_id_pp(G1 const& g1, G2 const& g2, G3 & g3)
{
::set_id(g1, g2, g3, bg::strategy::within::cartesian_point_point());
::set_id(g1, g2, g3, bg::strategy::within::spherical_point_point());
}
template <typename G1, typename G2, typename G3>
inline void set_id_ps(G1 const& g1, G2 const& g2, G3 & g3)
{
typedef typename bg::point_type<G1>::type point_type;
::set_id(g1, g2, g3, bg::strategy::within::cartesian_winding<point_type>());
::set_id(g1, g2, g3, bg::strategy::within::spherical_winding<point_type>());
::set_id(g1, g2, g3, bg::strategy::within::geographic_winding<point_type>());
}
template <typename G1, typename G2, typename G3>
inline void set_id_ss(G1 const& g1, G2 const& g2, G3 & g3)
{
::set_id(g1, g2, g3, bg::strategy::intersection::cartesian_segments<>());
::set_id(g1, g2, g3, bg::strategy::intersection::spherical_segments<>());
::set_id(g1, g2, g3, bg::strategy::intersection::geographic_segments<>());
}
template <typename G1, typename G2, typename G3>
inline void set_i_pp(G1 const& g1, G2 const& g2, G3 & g3)
{
::set_i(g1, g2, g3, bg::strategy::within::cartesian_point_point());
::set_i(g1, g2, g3, bg::strategy::within::spherical_point_point());
}
template <typename G1, typename G2, typename G3>
inline void set_i_ps(G1 const& g1, G2 const& g2, G3 & g3)
{
typedef typename bg::point_type<G1>::type point_type;
::set_i(g1, g2, g3, bg::strategy::within::cartesian_winding<point_type>());
::set_i(g1, g2, g3, bg::strategy::within::spherical_winding<point_type>());
::set_i(g1, g2, g3, bg::strategy::within::geographic_winding<point_type>());
}
template <typename G1, typename G2, typename G3>
inline void set_i_ss(G1 const& g1, G2 const& g2, G3 & g3)
{
::set_i(g1, g2, g3, bg::strategy::intersection::cartesian_segments<>());
::set_i(g1, g2, g3, bg::strategy::intersection::spherical_segments<>());
::set_i(g1, g2, g3, bg::strategy::intersection::geographic_segments<>());
}
template <typename G1, typename G2, typename G3>
inline void set_d_pp(G1 const& g1, G2 const& g2, G3 & g3)
{
::set_d(g1, g2, g3, bg::strategy::within::cartesian_point_point());
::set_d(g1, g2, g3, bg::strategy::within::spherical_point_point());
}
template <typename G1, typename G2, typename G3>
inline void set_d_ps(G1 const& g1, G2 const& g2, G3 & g3)
{
typedef typename bg::point_type<G1>::type point_type;
::set_d(g1, g2, g3, bg::strategy::within::cartesian_winding<point_type>());
::set_d(g1, g2, g3, bg::strategy::within::spherical_winding<point_type>());
::set_d(g1, g2, g3, bg::strategy::within::geographic_winding<point_type>());
}
template <typename G1, typename G2, typename G3>
inline void set_d_ss(G1 const& g1, G2 const& g2, G3 & g3)
{
::set_d(g1, g2, g3, bg::strategy::intersection::cartesian_segments<>());
::set_d(g1, g2, g3, bg::strategy::intersection::spherical_segments<>());
::set_d(g1, g2, g3, bg::strategy::intersection::geographic_segments<>());
}
int test_main(int, char*[])
{
geom g;
// P/P->P
::set_idsu_pp(g.pt, g.pt, g.mpt);
::set_idsu_pp(g.pt, g.mpt, g.mpt);
::set_idsu_pp(g.mpt, g.mpt, g.mpt);
// P/L->P
::set_id_ps(g.pt, g.s, g.mpt);
::set_id_ps(g.pt, g.ls, g.mpt);
::set_id_ps(g.pt, g.mls, g.mpt);
::set_id_ps(g.mpt, g.s, g.mpt);
::set_id_ps(g.mpt, g.ls, g.mpt);
::set_id_ps(g.mpt, g.mls, g.mpt);
// P/A->P
// no intersection nor difference
//::set_id_ps(g.pt, g.r, g.mpt);
//::set_id_ps(g.pt, g.po, g.mpt);
//::set_id_ps(g.pt, g.mpo, g.mpt);
//::set_id_ps(g.mpt, g.r, g.mpt);
//::set_id_ps(g.mpt, g.po, g.mpt);
//::set_id_ps(g.mpt, g.mpo, g.mpt);
// L/L->P
::set_ids_ss(g.s, g.s, g.mpt);
//::set_i_ss(g.s, g.ls, g.mpt); // no intersection nor difference
//::set_i_ss(g.s, g.mls, g.mpt); // no intersection nor difference
//::set_i_ss(g.ls, g.s, g.mpt); // no intersection nor difference
::set_ids_ss(g.ls, g.ls, g.mpt);
::set_i_ss(g.ls, g.mls, g.mpt); // no difference nor sym_difference
//::set_i_ss(g.mls, g.s, g.mpt); // no intersection nor difference
::set_i_ss(g.mls, g.ls, g.mpt); // no difference nor sym_difference
::set_ids_ss(g.mls, g.mls, g.mpt);
// L/L->L
//::set_ids_ss(g.s, g.s, g.mls); // union not implemented, missing specialization
//::set_idsu_ss(g.s, g.ls, g.mls); // missing specialization
//::set_idsu_ss(g.s, g.mls, g.mls); // missing specialization
//::set_idsu_ss(g.ls, g.s, g.mls); // missing specialization
::set_idsu_ss(g.ls, g.ls, g.mls);
::set_idsu_ss(g.ls, g.mls, g.mls);
//::set_idsu_ss(g.mls, g.s, g.mls); // missing specialization
::set_idsu_ss(g.mls, g.ls, g.mls);
::set_idsu_ss(g.mls, g.mls, g.mls);
// S/B->L ?
// L/B->L ?
// L/A->P
//::set_ids_ss(g.s, g.r, g.mpt); // no intersection
//::set_ids_ss(g.s, g.po, g.mpt); // no intersection
//::set_ids_ss(g.s, g.mpo, g.mpt); // no intersection
::set_ids_ss(g.ls, g.r, g.mpt);
::set_ids_ss(g.ls, g.po, g.mpt);
::set_ids_ss(g.ls, g.mpo, g.mpt);
::set_ids_ss(g.mls, g.r, g.mpt);
::set_ids_ss(g.mls, g.po, g.mpt);
::set_ids_ss(g.mls, g.mpo, g.mpt);
// L/A->L
//::set_id_ss(g.s, g.r, g.mls); // no intersection
//::set_id_ss(g.s, g.po, g.mls); // no intersection
//::set_id_ss(g.s, g.mpo, g.mls); // no intersection
::set_id_ss(g.ls, g.r, g.mls);
::set_id_ss(g.ls, g.po, g.mls);
::set_id_ss(g.ls, g.mpo, g.mls);
::set_id_ss(g.mls, g.r, g.mls);
::set_id_ss(g.mls, g.po, g.mls);
::set_id_ss(g.mls, g.mpo, g.mls);
// A/A->P
::set_i_ss(g.r, g.r, g.mpt);
::set_i_ss(g.r, g.po, g.mpt);
::set_i_ss(g.r, g.mpo, g.mpt);
::set_i_ss(g.po, g.r, g.mpt);
::set_i_ss(g.po, g.po, g.mpt);
::set_i_ss(g.po, g.mpo, g.mpt);
::set_i_ss(g.mpo, g.r, g.mpt);
::set_i_ss(g.mpo, g.po, g.mpt);
::set_i_ss(g.mpo, g.mpo, g.mpt);
// A/A->L
::set_i_ss(g.r, g.r, g.mls);
::set_i_ss(g.r, g.po, g.mls);
::set_i_ss(g.r, g.mpo, g.mls);
::set_i_ss(g.po, g.r, g.mls);
::set_i_ss(g.po, g.po, g.mls);
::set_i_ss(g.po, g.mpo, g.mls);
::set_i_ss(g.mpo, g.r, g.mls);
::set_i_ss(g.mpo, g.po, g.mls);
::set_i_ss(g.mpo, g.mpo, g.mls);
// A/A->A
::set_idsu_ss(g.r, g.r, g.mpo);
::set_idsu_ss(g.r, g.po, g.mpo);
::set_idsu_ss(g.r, g.mpo, g.mpo);
::set_idsu_ss(g.po, g.r, g.mpo);
::set_idsu_ss(g.po, g.po, g.mpo);
::set_idsu_ss(g.po, g.mpo, g.mpo);
::set_idsu_ss(g.mpo, g.r, g.mpo);
::set_idsu_ss(g.mpo, g.po, g.mpo);
::set_idsu_ss(g.mpo, g.mpo, g.mpo);
return 0;
}