// Boost.Geometry (aka GGL, Generic Geometry Library) // Copyright (c) 2014, Oracle and/or its affiliates. // Licensed under the Boost Software License version 1.0. // http://www.boost.org/users/license.html // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle #ifndef BOOST_TEST_MODULE #define BOOST_TEST_MODULE test_disjoint_coverage #endif // unit test to test disjoint for all geometry combinations #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "from_wkt.hpp" #ifdef HAVE_TTMATH #include #endif namespace bg = ::boost::geometry; //============================================================================ template ::type> struct pretty_print_geometry { static inline std::ostream& apply(Geometry const& geometry) { std::cout << bg::wkt(geometry); return std::cout; } }; template struct pretty_print_geometry { static inline std::ostream& apply(Segment const& segment) { std::cout << "SEGMENT" << bg::dsv(segment); return std::cout; } }; template struct pretty_print_geometry { static inline std::ostream& apply(Ring const& ring) { std::cout << "RING" << bg::dsv(ring); return std::cout; } }; template struct pretty_print_geometry { static inline std::ostream& apply(Box const& box) { std::cout << "BOX" << bg::dsv(box); return std::cout; } }; //============================================================================ struct test_disjoint { template static inline void apply(Geometry1 const& geometry1, Geometry2 const& geometry2, bool expected_result) { bool result = bg::disjoint(geometry1, geometry2); BOOST_CHECK( result == expected_result ); result = bg::disjoint(geometry2, geometry1); BOOST_CHECK( result == expected_result ); #ifdef BOOST_GEOMETRY_TEST_DEBUG std::cout << "G1 - G2: "; pretty_print_geometry::apply(geometry1) << " - "; pretty_print_geometry::apply(geometry2) << std::endl; std::cout << std::boolalpha; std::cout << "expected/computed result: " << expected_result << " / " << result << std::endl; std::cout << std::endl; std::cout << std::noboolalpha; #endif } }; //============================================================================ // pointlike-pointlike geometries template inline void test_point_point() { typedef test_disjoint tester; tester::apply(from_wkt

("POINT(0 0)"), from_wkt

("POINT(0 0)"), false); tester::apply(from_wkt

("POINT(0 0)"), from_wkt

("POINT(1 1)"), true); } template inline void test_point_multipoint() { typedef bg::model::multi_point

MP; typedef test_disjoint tester; tester::apply(from_wkt

("POINT(0 0)"), from_wkt("MULTIPOINT(0 0,1 1)"), false); tester::apply(from_wkt

("POINT(0 0)"), from_wkt("MULTIPOINT(1 1,2 2)"), true); } template inline void test_multipoint_multipoint() { typedef bg::model::multi_point

MP; typedef test_disjoint tester; tester::apply(from_wkt("MULTIPOINT(0 0,1 0)"), from_wkt("MULTIPOINT(0 0,1 1)"), false); tester::apply(from_wkt("MULTIPOINT(0 0,1 0)"), from_wkt("MULTIPOINT(1 1,2 2)"), true); } //============================================================================ // pointlike-linear geometries template inline void test_point_segment() { typedef test_disjoint tester; typedef bg::model::segment

S; tester::apply(from_wkt

("POINT(0 0)"), from_wkt("SEGMENT(0 0,2 0)"), false); tester::apply(from_wkt

("POINT(1 0)"), from_wkt("SEGMENT(0 0,2 0)"), false); tester::apply(from_wkt

("POINT(1 1)"), from_wkt("SEGMENT(0 0,2 0)"), true); } template inline void test_point_linestring() { typedef bg::model::linestring

L; typedef test_disjoint tester; tester::apply(from_wkt

("POINT(0 0)"), from_wkt("LINESTRING(0 0,2 2,4 4)"), false); tester::apply(from_wkt

("POINT(1 1)"), from_wkt("LINESTRING(0 0,2 2,4 4)"), false); tester::apply(from_wkt

("POINT(3 3)"), from_wkt("LINESTRING(0 0,2 2,4 4)"), false); tester::apply(from_wkt

("POINT(1 0)"), from_wkt("LINESTRING(0 0,2 2,4 4)"), true); } template inline void test_point_multilinestring() { typedef bg::model::linestring

L; typedef bg::model::multi_linestring ML; typedef test_disjoint tester; tester::apply(from_wkt

("POINT(0 1)"), from_wkt("MULTILINESTRING((0 0,2 2,4 4),(0 0,2 0,4 0))"), true); tester::apply(from_wkt

("POINT(0 0)"), from_wkt("MULTILINESTRING((0 0,2 2,4 4),(0 0,2 0,4 0))"), false); tester::apply(from_wkt

("POINT(1 1)"), from_wkt("MULTILINESTRING((0 0,2 2,4 4),(0 0,2 0,4 0))"), false); tester::apply(from_wkt

("POINT(1 0)"), from_wkt("MULTILINESTRING((0 0,2 2,4 4),(0 0,2 0,4 0))"), false); } template inline void test_multipoint_segment() { typedef test_disjoint tester; typedef bg::model::multi_point

MP; typedef bg::model::segment

S; tester::apply(from_wkt("MULTIPOINT(0 0,1 1)"), from_wkt("SEGMENT(0 0,2 0)"), false); tester::apply(from_wkt("MULTIPOINT(1 0,1 1)"), from_wkt("SEGMENT(0 0,2 0)"), false); tester::apply(from_wkt("MULTIPOINT(1 1,2 2)"), from_wkt("SEGMENT(0 0,2 0)"), true); } template inline void test_multipoint_linestring() { typedef bg::model::multi_point

MP; typedef bg::model::linestring

L; typedef test_disjoint tester; tester::apply(from_wkt("MULTIPOINT(0 0,1 0)"), from_wkt("LINESTRING(0 0,2 2,4 4)"), false); tester::apply(from_wkt("MULTIPOINT(1 0,1 1)"), from_wkt("LINESTRING(0 0,2 2,4 4)"), false); tester::apply(from_wkt("MULTIPOINT(1 0,3 3)"), from_wkt("LINESTRING(0 0,2 2,4 4)"), false); tester::apply(from_wkt("MULTIPOINT(1 0,2 0)"), from_wkt("LINESTRING(0 0,2 2,4 4)"), true); } template inline void test_multipoint_multilinestring() { typedef bg::model::multi_point

MP; typedef bg::model::linestring

L; typedef bg::model::multi_linestring ML; typedef test_disjoint tester; tester::apply(from_wkt("MULTIPOINT(0 1,0 2)"), from_wkt("MULTILINESTRING((0 0,2 2,4 4),(0 0,2 0,4 0))"), true); tester::apply(from_wkt("POINT(0 0,1 0)"), from_wkt("MULTILINESTRING((0 0,2 2,4 4),(0 0,2 0,4 0))"), false); tester::apply(from_wkt("POINT(0 1,1 1)"), from_wkt("MULTILINESTRING((0 0,2 2,4 4),(0 0,2 0,4 0))"), false); tester::apply(from_wkt("POINT(0 1,1 0)"), from_wkt("MULTILINESTRING((0 0,2 2,4 4),(0 0,2 0,4 0))"), false); } //============================================================================ // pointlike-areal geometries template inline void test_point_box() { typedef test_disjoint tester; typedef bg::model::box

B; tester::apply(from_wkt

("POINT(0 0)"), from_wkt("BOX(0 0,1 1)"), false); tester::apply(from_wkt

("POINT(2 2)"), from_wkt("BOX(0 0,1 0)"), true); } template inline void test_point_ring() { typedef bg::model::ring R; // ccw, open typedef test_disjoint tester; tester::apply(from_wkt

("POINT(0 0)"), from_wkt("POLYGON((0 0,1 0,0 1))"), false); tester::apply(from_wkt

("POINT(1 1)"), from_wkt("POLYGON((0 0,1 0,0 1))"), true); } template inline void test_point_polygon() { typedef bg::model::polygon PL; // ccw, open typedef test_disjoint tester; tester::apply(from_wkt

("POINT(0 0)"), from_wkt("POLYGON((0 0,1 0,0 1))"), false); tester::apply(from_wkt

("POINT(1 1)"), from_wkt("POLYGON((0 0,1 0,0 1))"), true); } template inline void test_point_multipolygon() { typedef bg::model::polygon PL; // ccw, open typedef bg::model::multi_polygon MPL; typedef test_disjoint tester; tester::apply(from_wkt

("POINT(0 0)"), from_wkt("MULTIPOLYGON(((0 0,1 0,0 1)),((2 0,3 0,2 1)))"), false); tester::apply(from_wkt

("POINT(1 1)"), from_wkt("MULTIPOLYGON(((0 0,1 0,0 1)),((2 0,3 0,2 1)))"), true); } template inline void test_multipoint_box() { typedef test_disjoint tester; typedef bg::model::multi_point

MP; typedef bg::model::box

B; tester::apply(from_wkt("MULTIPOINT(0 0,1 1)"), from_wkt("BOX(0 0,2 2)"), false); tester::apply(from_wkt("MULTIPOINT(1 1,3 3)"), from_wkt("BOX(0 0,2 2)"), false); tester::apply(from_wkt("MULTIPOINT(3 3,4 4)"), from_wkt("BOX(0 0,2 2)"), true); } template inline void test_multipoint_ring() { typedef bg::model::multi_point

MP; typedef bg::model::ring R; // ccw, open typedef test_disjoint tester; tester::apply(from_wkt("MULTIPOINT(0 0,1 0)"), from_wkt("POLYGON((0 0,1 0,0 1))"), false); tester::apply(from_wkt("MULTIPOINT(1 0,1 1)"), from_wkt("POLYGON((0 0,1 0,0 1))"), false); tester::apply(from_wkt("MULTIPOINT(1 1,2 2)"), from_wkt("POLYGON((0 0,1 0,0 1))"), true); } template inline void test_multipoint_polygon() { typedef bg::model::multi_point

MP; typedef bg::model::polygon PL; // ccw, open typedef test_disjoint tester; tester::apply(from_wkt("MULTIPOINT(0 0,1 0)"), from_wkt("POLYGON(((0 0,1 0,0 1)))"), false); tester::apply(from_wkt("MULTIPOINT(0 0,2 0)"), from_wkt("POLYGON(((0 0,1 0,0 1)))"), false); tester::apply(from_wkt("MULTIPOINT(1 1,2 0)"), from_wkt("POLYGON(((0 0,1 0,0 1)))"), true); tester::apply(from_wkt("MULTIPOINT(1 1,2 3)"), from_wkt("POLYGON(((0 0,1 0,0 1)))"), true); } template inline void test_multipoint_multipolygon() { typedef bg::model::multi_point

MP; typedef bg::model::polygon PL; // ccw, open typedef bg::model::multi_polygon MPL; typedef test_disjoint tester; tester::apply(from_wkt("MULTIPOINT(0 0,2 0)"), from_wkt("MULTIPOLYGON((0 0,1 0,0 1)),(2 0,3 0,2 1))"), false); tester::apply(from_wkt("MULTIPOINT(0 0,1 0)"), from_wkt("MULTIPOLYGON((0 0,1 0,0 1)),(2 0,3 0,2 1))"), false); tester::apply(from_wkt("MULTIPOINT(1 1,2 0)"), from_wkt("MULTIPOLYGON((0 0,1 0,0 1)),(2 0,3 0,2 1))"), false); tester::apply(from_wkt("MULTIPOINT(1 1,2 3)"), from_wkt("MULTIPOLYGON((0 0,1 0,0 1)),(2 0,3 0,2 1))"), true); } //============================================================================ // linear-linear geometries template inline void test_segment_segment() { typedef bg::model::segment

S; typedef test_disjoint tester; tester::apply(from_wkt("SEGMENT(0 0,2 0)"), from_wkt("SEGMENT(0 0,0 2)"), false); tester::apply(from_wkt("SEGMENT(0 0,2 0)"), from_wkt("SEGMENT(2 0,3 0)"), false); tester::apply(from_wkt("SEGMENT(0 0,2 0)"), from_wkt("SEGMENT(1 0,3 0)"), false); tester::apply(from_wkt("SEGMENT(0 0,2 0)"), from_wkt("SEGMENT(1 0,1 1)"), false); tester::apply(from_wkt("SEGMENT(0 0,2 0)"), from_wkt("SEGMENT(1 1,2 2)"), true); } template inline void test_linestring_segment() { typedef bg::model::segment

S; typedef bg::model::linestring

L; typedef test_disjoint tester; tester::apply(from_wkt("SEGMENT(0 0,2 0)"), from_wkt("LINESTRING(0 0,0 2)"), false); tester::apply(from_wkt("SEGMENT(0 0,2 0)"), from_wkt("LINESTRING(2 0,3 0)"), false); tester::apply(from_wkt("SEGMENT(0 0,2 0)"), from_wkt("LINESTRING(1 0,3 0)"), false); tester::apply(from_wkt("SEGMENT(0 0,2 0)"), from_wkt("LINESTRING(1 0,1 1)"), false); tester::apply(from_wkt("SEGMENT(0 0,2 0)"), from_wkt("LINESTRING(1 1,2 2)"), true); } template inline void test_multilinestring_segment() { typedef bg::model::segment

S; typedef bg::model::linestring

L; typedef bg::model::multi_linestring ML; typedef test_disjoint tester; tester::apply(from_wkt("SEGMENT(0 0,2 0)"), from_wkt("MULTILINESTRING((0 0,0 2))"), false); tester::apply(from_wkt("SEGMENT(0 0,2 0)"), from_wkt("MULTILINESTRING((2 0,3 0))"), false); tester::apply(from_wkt("SEGMENT(0 0,2 0)"), from_wkt("MULTILINESTRING((1 0,3 0))"), false); tester::apply(from_wkt("SEGMENT(0 0,2 0)"), from_wkt("MULTILINESTRING((1 0,1 1))"), false); tester::apply(from_wkt("SEGMENT(0 0,2 0)"), from_wkt("MULTILINESTRING((1 1,2 2))"), true); } template inline void test_linestring_linestring() { typedef bg::model::linestring

L; typedef test_disjoint tester; tester::apply(from_wkt("LINESTRING(0 0,2 0)"), from_wkt("LINESTRING(0 0,0 2)"), false); tester::apply(from_wkt("LINESTRING(0 0,2 0)"), from_wkt("LINESTRING(2 0,3 0)"), false); tester::apply(from_wkt("LINESTRING(0 0,2 0)"), from_wkt("LINESTRING(1 0,3 0)"), false); tester::apply(from_wkt("LINESTRING(0 0,2 0)"), from_wkt("LINESTRING(1 0,1 1)"), false); tester::apply(from_wkt("LINESTRING(0 0,2 0)"), from_wkt("LINESTRING(1 1,2 2)"), true); } template inline void test_linestring_multilinestring() { typedef bg::model::linestring

L; typedef bg::model::multi_linestring ML; typedef test_disjoint tester; tester::apply(from_wkt("LINESTRING(0 0,2 0)"), from_wkt("MULTILINESTRING((0 0,0 2))"), false); tester::apply(from_wkt("LINESTRING(0 0,2 0)"), from_wkt("MULTILINESTRING((2 0,3 0))"), false); tester::apply(from_wkt("LINESTRING(0 0,2 0)"), from_wkt("MULTILINESTRING((1 0,3 0))"), false); tester::apply(from_wkt("LINESTRING(0 0,2 0)"), from_wkt("MULTILINESTRING((1 0,1 1))"), false); tester::apply(from_wkt("LINESTRING(0 0,2 0)"), from_wkt("MULTILINESTRING((1 1,2 2))"), true); } template inline void test_multilinestring_multilinestring() { typedef bg::model::linestring

L; typedef bg::model::multi_linestring ML; typedef test_disjoint tester; tester::apply(from_wkt("MULTILINESTRING((0 0,2 0))"), from_wkt("MULTILINESTRING((0 0,0 2))"), false); tester::apply(from_wkt("MULTILINESTRING((0 0,2 0))"), from_wkt("MULTILINESTRING((2 0,3 0))"), false); tester::apply(from_wkt("MULTILINESTRING((0 0,2 0))"), from_wkt("MULTILINESTRING((1 0,3 0))"), false); tester::apply(from_wkt("MULTILINESTRING((0 0,2 0))"), from_wkt("MULTILINESTRING((1 0,1 1))"), false); tester::apply(from_wkt("MULTILINESTRING((0 0,2 0))"), from_wkt("MULTILINESTRING((1 1,2 2))"), true); } //============================================================================ // linear-areal geometries template inline void test_segment_box() { typedef bg::model::segment

S; typedef bg::model::box

B; typedef test_disjoint tester; tester::apply(from_wkt("SEGMENT(0 0,2 0)"), from_wkt("BOX(0 0,2 2)"), false); tester::apply(from_wkt("SEGMENT(1 1,3 3)"), from_wkt("BOX(0 0,2 2)"), false); tester::apply(from_wkt("SEGMENT(2 2,3 3)"), from_wkt("BOX(0 0,2 2)"), false); tester::apply(from_wkt("SEGMENT(4 4,3 3)"), from_wkt("BOX(0 0,2 2)"), true); tester::apply(from_wkt("SEGMENT(0 4,4 4)"), from_wkt("BOX(0 0,2 2)"), true); tester::apply(from_wkt("SEGMENT(4 0,4 4)"), from_wkt("BOX(0 0,2 2)"), true); tester::apply(from_wkt("SEGMENT(0 -2,0 -1)"), from_wkt("BOX(0 0,1 1)"), true); tester::apply(from_wkt("SEGMENT(-2 -2,-2 -1)"), from_wkt("BOX(0 0,1 1)"), true); tester::apply(from_wkt("SEGMENT(-2 -2,-2 -2)"), from_wkt("BOX(0 0,1 1)"), true); tester::apply(from_wkt("SEGMENT(-2 0,-2 0)"), from_wkt("BOX(0 0,1 1)"), true); tester::apply(from_wkt("SEGMENT(0 -2,0 -2)"), from_wkt("BOX(0 0,1 1)"), true); tester::apply(from_wkt("SEGMENT(-2 0,-1 0)"), from_wkt("BOX(0 0,1 1)"), true); // segment degenerates to a point tester::apply(from_wkt("SEGMENT(0 0,0 0)"), from_wkt("BOX(0 0,1 1)"), false); tester::apply(from_wkt("SEGMENT(1 1,1 1)"), from_wkt("BOX(0 0,2 2)"), false); tester::apply(from_wkt("SEGMENT(2 2,2 2)"), from_wkt("BOX(0 0,2 2)"), false); tester::apply(from_wkt("SEGMENT(2 0,2 0)"), from_wkt("BOX(0 0,2 2)"), false); tester::apply(from_wkt("SEGMENT(0 2,0 2)"), from_wkt("BOX(0 0,2 2)"), false); tester::apply(from_wkt("SEGMENT(2 2,2 2)"), from_wkt("BOX(0 0,1 1)"), true); } template inline void test_segment_ring() { typedef bg::model::segment

S; typedef bg::model::ring R; // ccw, open typedef test_disjoint tester; tester::apply(from_wkt("SEGMENT(0 0,2 0)"), from_wkt("POLYGON((0 0,2 0,0 2))"), false); tester::apply(from_wkt("SEGMENT(1 0,3 3)"), from_wkt("POLYGON((0 0,2 0,0 2))"), false); tester::apply(from_wkt("SEGMENT(1 1,3 3)"), from_wkt("POLYGON((0 0,2 0,0 2))"), false); tester::apply(from_wkt("SEGMENT(2 2,3 3)"), from_wkt("POLYGON((0 0,2 0,0 2))"), true); } template inline void test_segment_polygon() { typedef bg::model::segment

S; typedef bg::model::polygon PL; // ccw, open typedef test_disjoint tester; tester::apply(from_wkt("SEGMENT(0 0,2 0)"), from_wkt("POLYGON((0 0,2 0,0 2))"), false); tester::apply(from_wkt("SEGMENT(1 0,3 3)"), from_wkt("POLYGON((0 0,2 0,0 2))"), false); tester::apply(from_wkt("SEGMENT(1 1,3 3)"), from_wkt("POLYGON((0 0,2 0,0 2))"), false); tester::apply(from_wkt("SEGMENT(2 2,3 3)"), from_wkt("POLYGON((0 0,2 0,0 2))"), true); } template inline void test_segment_multipolygon() { typedef bg::model::segment

S; typedef bg::model::polygon PL; // ccw, open typedef bg::model::multi_polygon MPL; typedef test_disjoint tester; tester::apply(from_wkt("SEGMENT(0 0,2 0)"), from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), false); tester::apply(from_wkt("SEGMENT(1 0,3 3)"), from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), false); tester::apply(from_wkt("SEGMENT(1 1,3 3)"), from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), false); tester::apply(from_wkt("SEGMENT(2 2,3 3)"), from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), true); } template inline void test_linestring_box() { typedef bg::model::linestring

L; typedef bg::model::box

B; typedef test_disjoint tester; tester::apply(from_wkt("LINESTRING(0 0,2 0)"), from_wkt("BOX(0 0,2 2)"), false); tester::apply(from_wkt("LINESTRING(1 1,3 3)"), from_wkt("BOX(0 0,2 2)"), false); tester::apply(from_wkt("LINESTRING(2 2,3 3)"), from_wkt("BOX(0 0,2 2)"), false); tester::apply(from_wkt("LINESTRING(4 4,3 3)"), from_wkt("BOX(0 0,2 2)"), true); } template inline void test_linestring_ring() { typedef bg::model::linestring

L; typedef bg::model::ring R; // ccw, open typedef test_disjoint tester; tester::apply(from_wkt("LINESTRING(0 0,2 0)"), from_wkt("POLYGON((0 0,2 0,0 2))"), false); tester::apply(from_wkt("LINESTRING(1 0,3 3)"), from_wkt("POLYGON((0 0,2 0,0 2))"), false); tester::apply(from_wkt("LINESTRING(1 1,3 3)"), from_wkt("POLYGON((0 0,2 0,0 2))"), false); tester::apply(from_wkt("LINESTRING(2 2,3 3)"), from_wkt("POLYGON((0 0,2 0,0 2))"), true); } template inline void test_linestring_polygon() { typedef bg::model::linestring

L; typedef bg::model::polygon PL; // ccw, open typedef test_disjoint tester; tester::apply(from_wkt("LINESTRING(0 0,2 0)"), from_wkt("POLYGON((0 0,2 0,0 2))"), false); tester::apply(from_wkt("LINESTRING(1 0,3 3)"), from_wkt("POLYGON((0 0,2 0,0 2))"), false); tester::apply(from_wkt("LINESTRING(1 1,3 3)"), from_wkt("POLYGON((0 0,2 0,0 2))"), false); tester::apply(from_wkt("LINESTRING(2 2,3 3)"), from_wkt("POLYGON((0 0,2 0,0 2))"), true); } template inline void test_linestring_multipolygon() { typedef bg::model::linestring

L; typedef bg::model::polygon PL; // ccw, open typedef bg::model::multi_polygon MPL; typedef test_disjoint tester; tester::apply(from_wkt("LINESTRING(0 0,2 0)"), from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), false); tester::apply(from_wkt("LINESTRING(1 0,3 3)"), from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), false); tester::apply(from_wkt("LINESTRING(1 1,3 3)"), from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), false); tester::apply(from_wkt("LINESTRING(2 2,3 3)"), from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), true); } template inline void test_multilinestring_box() { typedef bg::model::linestring

L; typedef bg::model::multi_linestring ML; typedef bg::model::box

B; typedef test_disjoint tester; tester::apply(from_wkt("MULTILINESTRING((0 0,2 0))"), from_wkt("BOX(0 0,2 2)"), false); tester::apply(from_wkt("MULTILINESTRING((1 1,3 3))"), from_wkt("BOX(0 0,2 2)"), false); tester::apply(from_wkt("MULTILINESTRING((2 2,3 3))"), from_wkt("BOX(0 0,2 2)"), false); tester::apply(from_wkt("MULTILINESTRING((4 4,3 3))"), from_wkt("BOX(0 0,2 2)"), true); } template inline void test_multilinestring_ring() { typedef bg::model::linestring

L; typedef bg::model::multi_linestring ML; typedef bg::model::ring R; // ccw, open typedef test_disjoint tester; tester::apply(from_wkt("MULTILINESTRING((0 0,2 0))"), from_wkt("POLYGON((0 0,2 0,0 2))"), false); tester::apply(from_wkt("MULTILINESTRING((1 0,3 3))"), from_wkt("POLYGON((0 0,2 0,0 2))"), false); tester::apply(from_wkt("MULTILINESTRING((1 1,3 3))"), from_wkt("POLYGON((0 0,2 0,0 2))"), false); tester::apply(from_wkt("MULTILINESTRING((2 2,3 3))"), from_wkt("POLYGON((0 0,2 0,0 2))"), true); } template inline void test_multilinestring_polygon() { typedef bg::model::linestring

L; typedef bg::model::multi_linestring ML; typedef bg::model::polygon PL; // ccw, open typedef test_disjoint tester; tester::apply(from_wkt("MULTILINESTRING((0 0,2 0))"), from_wkt("POLYGON((0 0,2 0,0 2))"), false); tester::apply(from_wkt("MULTILINESTRING((1 0,3 3))"), from_wkt("POLYGON((0 0,2 0,0 2))"), false); tester::apply(from_wkt("MULTILINESTRING((1 1,3 3))"), from_wkt("POLYGON((0 0,2 0,0 2))"), false); tester::apply(from_wkt("MULTILINESTRING((2 2,3 3))"), from_wkt("POLYGON((0 0,2 0,0 2))"), true); } template inline void test_multilinestring_multipolygon() { typedef bg::model::linestring

L; typedef bg::model::multi_linestring ML; typedef bg::model::polygon PL; // ccw, open typedef bg::model::multi_polygon MPL; typedef test_disjoint tester; tester::apply(from_wkt("MULTILINESTRING((0 0,2 0))"), from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), false); tester::apply(from_wkt("MULTILINESTRING((1 0,3 3))"), from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), false); tester::apply(from_wkt("MULTILINESTRING((1 1,3 3))"), from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), false); tester::apply(from_wkt("MULTILINESTRING((2 2,3 3))"), from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), true); } //============================================================================ // areal-areal geometries template inline void test_box_box() { typedef bg::model::box

B; typedef test_disjoint tester; tester::apply(from_wkt("BOX(2 2,3 3)"), from_wkt("BOX(0 0,2 2)"), false); tester::apply(from_wkt("BOX(1 1,3 3)"), from_wkt("BOX(0 0,2 2)"), false); tester::apply(from_wkt("BOX(3 3,4 4)"), from_wkt("BOX(0 0,2 2)"), true); } template inline void test_ring_box() { typedef bg::model::box

B; typedef bg::model::ring R; // ccw, open typedef test_disjoint tester; tester::apply(from_wkt("BOX(2 2,3 3)"), from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), false); tester::apply(from_wkt("BOX(1 1,3 3)"), from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), false); tester::apply(from_wkt("BOX(3 3,4 4)"), from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), true); } template inline void test_polygon_box() { typedef bg::model::box

B; typedef bg::model::polygon PL; // ccw, open typedef test_disjoint tester; tester::apply(from_wkt("BOX(2 2,3 3)"), from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), false); tester::apply(from_wkt("BOX(1 1,3 3)"), from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), false); tester::apply(from_wkt("BOX(3 3,4 4)"), from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), true); } template inline void test_multipolygon_box() { typedef bg::model::box

B; typedef bg::model::polygon PL; // ccw, open typedef bg::model::multi_polygon MPL; typedef test_disjoint tester; tester::apply(from_wkt("BOX(2 2,3 3)"), from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), false); tester::apply(from_wkt("BOX(1 1,3 3)"), from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), false); tester::apply(from_wkt("BOX(3 3,4 4)"), from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), true); } template inline void test_ring_ring() { typedef bg::model::ring R; // ccw, open typedef test_disjoint tester; tester::apply(from_wkt("POLYGON((2 2,2 3,3 3,3 2))"), from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), false); tester::apply(from_wkt("POLYGON((1 1,1 3,3 3,3 1))"), from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), false); tester::apply(from_wkt("POLYGON((3 3,3 4,4 4,4 3))"), from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), true); } template inline void test_polygon_ring() { typedef bg::model::ring R; // ccw, open typedef bg::model::polygon PL; // ccw, open typedef test_disjoint tester; tester::apply(from_wkt("POLYGON((2 2,2 3,3 3,3 2))"), from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), false); tester::apply(from_wkt("POLYGON((1 1,1 3,3 3,3 1))"), from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), false); tester::apply(from_wkt("POLYGON((3 3,3 4,4 4,4 3))"), from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), true); } template inline void test_multipolygon_ring() { typedef bg::model::ring R; // ccw, open typedef bg::model::polygon PL; // ccw, open typedef bg::model::multi_polygon MPL; typedef test_disjoint tester; tester::apply(from_wkt("POLYGON((2 2,2 3,3 3,3 2))"), from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), false); tester::apply(from_wkt("POLYGON((1 1,1 3,3 3,3 1))"), from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), false); tester::apply(from_wkt("POLYGON((3 3,3 4,4 4,4 3))"), from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), true); } template inline void test_polygon_polygon() { typedef bg::model::polygon PL; // ccw, open typedef test_disjoint tester; tester::apply(from_wkt("POLYGON((2 2,2 3,3 3,3 2))"), from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), false); tester::apply(from_wkt("POLYGON((1 1,1 3,3 3,3 1))"), from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), false); tester::apply(from_wkt("POLYGON((3 3,3 4,4 4,4 3))"), from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), true); } template inline void test_polygon_multipolygon() { typedef bg::model::polygon PL; // ccw, open typedef bg::model::multi_polygon MPL; typedef test_disjoint tester; tester::apply(from_wkt("POLYGON((2 2,2 3,3 3,3 2))"), from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), false); tester::apply(from_wkt("POLYGON((1 1,1 3,3 3,3 1))"), from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), false); tester::apply(from_wkt("POLYGON((3 3,3 4,4 4,4 3))"), from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), true); } template inline void test_multipolygon_multipolygon() { typedef bg::model::polygon PL; // ccw, open typedef bg::model::multi_polygon MPL; typedef test_disjoint tester; tester::apply(from_wkt("MULTIPOLYGON(((2 2,2 3,3 3,3 2)))"), from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), false); tester::apply(from_wkt("MULTIPOLYGON(((1 1,1 3,3 3,3 1)))"), from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), false); tester::apply(from_wkt("MULTIPOLYGON(((3 3,3 4,4 4,4 3)))"), from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), true); } //============================================================================ template inline void test_pointlike_pointlike() { typedef bg::model::point point_type; test_point_point(); // not implemented yet // test_point_multipoint(); // test_multipoint_multipoint(); } template inline void test_pointlike_linear() { typedef bg::model::point point_type; test_point_linestring(); test_point_multilinestring(); test_point_segment(); // not implemented yet // test_multipoint_linestring(); // test_multipoint_multilinestring(); // test_multipoint_segment(); } template inline void test_pointlike_areal() { typedef bg::model::point point_type; test_point_polygon(); test_point_multipolygon(); test_point_ring(); test_point_box(); // not implemented yet // test_multipoint_polygon(); // test_multipoint_multipolygon(); // test_multipoint_ring(); // test_multipoint_box(); } template inline void test_linear_linear() { typedef bg::model::point point_type; test_linestring_linestring(); test_linestring_multilinestring(); test_linestring_segment(); test_multilinestring_multilinestring(); test_multilinestring_segment(); test_segment_segment(); } template inline void test_linear_areal() { typedef bg::model::point point_type; test_segment_polygon(); test_segment_multipolygon(); test_segment_ring(); test_segment_box(); test_linestring_polygon(); test_linestring_multipolygon(); test_linestring_ring(); test_linestring_box(); test_multilinestring_polygon(); test_multilinestring_multipolygon(); test_multilinestring_ring(); test_multilinestring_box(); } template inline void test_areal_areal() { typedef bg::model::point point_type; test_polygon_polygon(); test_polygon_multipolygon(); test_polygon_ring(); test_polygon_box(); test_multipolygon_multipolygon(); test_multipolygon_ring(); test_multipolygon_box(); test_ring_ring(); test_ring_box(); test_box_box(); } //============================================================================ BOOST_AUTO_TEST_CASE( test_pointlike_pointlike_all ) { test_pointlike_pointlike(); test_pointlike_pointlike(); #ifdef HAVE_TTMATH test_pointlike_pointlike(); #endif } BOOST_AUTO_TEST_CASE( test_pointlike_linear_all ) { test_pointlike_linear(); test_pointlike_linear(); #ifdef HAVE_TTMATH test_pointlike_linear(); #endif } BOOST_AUTO_TEST_CASE( test_pointlike_areal_all ) { test_pointlike_areal(); test_pointlike_areal(); #ifdef HAVE_TTMATH test_pointlike_areal(); #endif } BOOST_AUTO_TEST_CASE( test_linear_linear_all ) { test_linear_linear(); test_linear_linear(); #ifdef HAVE_TTMATH test_linear_linear(); #endif } BOOST_AUTO_TEST_CASE( test_linear_areal_all ) { test_linear_areal(); test_linear_areal(); #ifdef HAVE_TTMATH test_linear_areal(); #endif } BOOST_AUTO_TEST_CASE( test_areal_areal_all ) { test_areal_areal(); test_areal_areal(); #ifdef HAVE_TTMATH test_areal_areal(); #endif }