// Boost.Geometry (aka GGL, Generic Geometry Library) // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. // This file was modified by Oracle on 2013, 2014. // Modifications copyright (c) 2013-2014 Oracle and/or its affiliates. // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include //TEST #include namespace bgdr = bg::detail::relate; std::string transposed(std::string matrix) { std::swap(matrix[1], matrix[3]); std::swap(matrix[2], matrix[6]); std::swap(matrix[5], matrix[7]); return matrix; } template void check_geometry(Geometry1 const& geometry1, Geometry2 const& geometry2, std::string const& wkt1, std::string const& wkt2, std::string const& expected) { { std::string res_str = bgdr::relate(geometry1, geometry2); bool ok = boost::equal(res_str, expected); BOOST_CHECK_MESSAGE(ok, "relate: " << wkt1 << " and " << wkt2 << " -> Expected: " << expected << " detected: " << res_str); } // changed sequence of geometries - transposed result { std::string res_str = bgdr::relate(geometry2, geometry1, bgdr::matrix9()); std::string expected_tr = transposed(expected); bool ok = boost::equal(res_str, expected_tr); BOOST_CHECK_MESSAGE(ok, "relate: " << wkt2 << " and " << wkt1 << " -> Expected: " << expected_tr << " detected: " << res_str); } { bool result = bgdr::relate(geometry1, geometry2, bgdr::mask9(expected)); // TODO: SHOULD BE !interrupted - CHECK THIS! BOOST_CHECK_MESSAGE(result, "relate: " << wkt1 << " and " << wkt2 << " -> Expected: " << expected); } if ( bg::detail::relate::interruption_enabled::value ) { // brake the expected output std::string expected_interrupt = expected; bool changed = false; BOOST_FOREACH(char & c, expected_interrupt) { if ( c >= '0' && c <= '9' ) { if ( c == '0' ) c = 'F'; else --c; changed = true; } } if ( changed ) { bool result = bgdr::relate(geometry1, geometry2, bgdr::mask9(expected_interrupt)); // TODO: SHOULD BE interrupted - CHECK THIS! BOOST_CHECK_MESSAGE(!result, "relate: " << wkt1 << " and " << wkt2 << " -> Expected interrupt for:" << expected_interrupt); } } } template void test_geometry(std::string const& wkt1, std::string const& wkt2, std::string const& expected) { Geometry1 geometry1; Geometry2 geometry2; bg::read_wkt(wkt1, geometry1); bg::read_wkt(wkt2, geometry2); check_geometry(geometry1, geometry2, wkt1, wkt2, expected); } template void test_point_point() { test_geometry("POINT(0 0)", "POINT(0 0)", "0FFFFFFF2"); test_geometry("POINT(1 0)", "POINT(0 0)", "FF0FFF0F2"); } template void test_point_multipoint() { typedef bg::model::multi_point

mpt; test_geometry("POINT(0 0)", "MULTIPOINT(0 0)", "0FFFFFFF2"); test_geometry("POINT(1 0)", "MULTIPOINT(0 0)", "FF0FFF0F2"); test_geometry("POINT(0 0)", "MULTIPOINT(0 0, 1 0)", "0FFFFF0F2"); } template void test_multipoint_multipoint() { typedef bg::model::multi_point

mpt; test_geometry("MULTIPOINT(0 0)", "MULTIPOINT(0 0)", "0FFFFFFF2"); test_geometry("MULTIPOINT(1 0)", "MULTIPOINT(0 0)", "FF0FFF0F2"); test_geometry("MULTIPOINT(0 0)", "MULTIPOINT(0 0, 1 0)", "0FFFFF0F2"); test_geometry("MULTIPOINT(0 0, 1 0)", "MULTIPOINT(0 0)", "0F0FFFFF2"); test_geometry("MULTIPOINT(0 0, 1 1)", "MULTIPOINT(0 0, 1 0)", "0F0FFF0F2"); //typedef bg::model::d2::point_xy ptf; //typedef bg::model::multi_point mptf; //test_geometry("MULTIPOINT(0 0)", "MULTIPOINT(0 0)", "0FFFFFFF2"); } template void test_point_linestring() { typedef bg::model::linestring

ls; test_geometry("POINT(0 0)", "LINESTRING(0 0, 2 2, 3 2)", "F0FFFF102"); test_geometry("POINT(1 1)", "LINESTRING(0 0, 2 2, 3 2)", "0FFFFF102"); test_geometry("POINT(3 2)", "LINESTRING(0 0, 2 2, 3 2)", "F0FFFF102"); test_geometry("POINT(1 0)", "LINESTRING(0 0, 2 2, 3 2)", "FF0FFF102"); test_geometry("POINT(0 0)", "LINESTRING(0 0, 2 2, 3 2, 0 0)", "0FFFFF1F2"); test_geometry("POINT(1 1)", "LINESTRING(0 0, 2 2, 3 2, 0 0)", "0FFFFF1F2"); test_geometry("POINT(3 2)", "LINESTRING(0 0, 2 2, 3 2, 0 0)", "0FFFFF1F2"); test_geometry("POINT(1 0)", "LINESTRING(0 0, 2 2, 3 2, 0 0)", "FF0FFF1F2"); } template void test_point_multilinestring() { typedef bg::model::linestring

ls; typedef bg::model::multi_linestring mls; test_geometry("POINT(0 0)", "MULTILINESTRING((0 0, 2 0, 2 2),(0 0, 0 2))", "0FFFFF102"); test_geometry("POINT(0 0)", "MULTILINESTRING((0 0, 2 0, 2 2),(0 0, 0 2, 2 2))", "0FFFFF1F2"); test_geometry("POINT(0 0)", "MULTILINESTRING((0 0, 2 0, 2 2),(0 0, 0 2, 2 2),(0 0, 1 1))", "F0FFFF102"); test_geometry("POINT(0 0)", "MULTILINESTRING((0 0,5 0),(0 0,0 5,5 0),(0 0,-5 0),(0 0,0 -5,-5 0))", "0FFFFF1F2"); test_geometry("POINT(5 0)", "MULTILINESTRING((0 0,5 0),(0 0,0 5,5 0),(0 0,-5 0),(0 0,0 -5,-5 0))", "0FFFFF1F2"); test_geometry("POINT(1 0)", "MULTILINESTRING((0 0,5 0),(0 0,0 5,5 0),(0 0,-5 0),(0 0,0 -5,-5 0))", "0FFFFF1F2"); } template void test_linestring_linestring() { typedef bg::model::linestring

ls; test_geometry("LINESTRING(0 0, 2 2, 3 2)", "LINESTRING(0 0, 2 2, 3 2)", "1FFF0FFF2"); test_geometry("LINESTRING(0 0,3 2)", "LINESTRING(0 0, 2 2, 3 2)", "FF1F0F1F2"); test_geometry("LINESTRING(1 0,2 2,2 3)", "LINESTRING(0 0, 2 2, 3 2)", "0F1FF0102"); test_geometry("LINESTRING(0 0,5 0)", "LINESTRING(0 0,1 1,2 0,2 -1)", "0F1F00102"); test_geometry("LINESTRING(0 0, 1 1, 2 2, 3 2)", "LINESTRING(0 0, 2 2, 3 2)", "1FFF0FFF2"); test_geometry("LINESTRING(3 2, 2 2, 1 1, 0 0)", "LINESTRING(0 0, 2 2, 3 2)", "1FFF0FFF2"); test_geometry("LINESTRING(0 0, 1 1, 2 2, 3 2)", "LINESTRING(3 2, 2 2, 0 0)", "1FFF0FFF2"); test_geometry("LINESTRING(3 2, 2 2, 1 1, 0 0)", "LINESTRING(3 2, 2 2, 0 0)", "1FFF0FFF2"); test_geometry("LINESTRING(3 1, 2 2, 1 1, 0 0)", "LINESTRING(0 0, 2 2, 3 2)", "1F1F00102"); test_geometry("LINESTRING(3 3, 2 2, 1 1, 0 0)", "LINESTRING(0 0, 2 2, 3 2)", "1F1F00102"); test_geometry("LINESTRING(0 0, 1 1, 2 2, 2 3)", "LINESTRING(0 0, 2 2, 2 3)", "1FFF0FFF2"); test_geometry("LINESTRING(2 3, 2 2, 1 1, 0 0)", "LINESTRING(0 0, 2 2, 2 3)", "1FFF0FFF2"); test_geometry("LINESTRING(0 0, 1 1, 2 2, 2 3)", "LINESTRING(2 3, 2 2, 0 0)", "1FFF0FFF2"); test_geometry("LINESTRING(2 3, 2 2, 1 1, 0 0)", "LINESTRING(2 3, 2 2, 0 0)", "1FFF0FFF2"); test_geometry("LINESTRING(1 1, 2 2, 3 2)", "LINESTRING(0 0, 2 2, 4 2)", "1FF0FF102"); test_geometry("LINESTRING(3 2, 2 2, 1 1)", "LINESTRING(0 0, 2 2, 4 2)", "1FF0FF102"); test_geometry("LINESTRING(1 1, 2 2, 3 2)", "LINESTRING(4 2, 2 2, 0 0)", "1FF0FF102"); test_geometry("LINESTRING(3 2, 2 2, 1 1)", "LINESTRING(4 2, 2 2, 0 0)", "1FF0FF102"); // test_geometry("LINESTRING(1 1, 2 2, 2 2)", "LINESTRING(0 0, 2 2, 4 2)", true); // test_geometry("LINESTRING(1 1, 2 2, 3 3)", "LINESTRING(0 0, 2 2, 4 2)", false); // test_geometry("LINESTRING(1 1, 2 2, 3 2, 3 3)", "LINESTRING(0 0, 2 2, 4 2)", false); // test_geometry("LINESTRING(1 1, 2 2, 3 1)", "LINESTRING(0 0, 2 2, 4 2)", false); // test_geometry("LINESTRING(1 1, 2 2, 3 2, 3 1)", "LINESTRING(0 0, 2 2, 4 2)", false); // test_geometry("LINESTRING(0 1, 1 1, 2 2, 3 2)", "LINESTRING(0 0, 2 2, 4 2)", false); // test_geometry("LINESTRING(0 1, 0 0, 2 2, 3 2)", "LINESTRING(0 0, 2 2, 4 2)", false); // test_geometry("LINESTRING(1 0, 1 1, 2 2, 3 2)", "LINESTRING(0 0, 2 2, 4 2)", false); // test_geometry("LINESTRING(1 0, 0 0, 2 2, 3 2)", "LINESTRING(0 0, 2 2, 4 2)", false); // test_geometry("LINESTRING(0 0)", "LINESTRING(0 0)", false); // test_geometry("LINESTRING(1 1)", "LINESTRING(0 0, 2 2)", true); // test_geometry("LINESTRING(0 0)", "LINESTRING(0 0, 2 2)", false); // test_geometry("LINESTRING(0 0, 1 1)", "LINESTRING(0 0)", false); // test_geometry("LINESTRING(0 0,5 0,3 0,6 0)", "LINESTRING(0 0,6 0)", true); // test_geometry("LINESTRING(0 0,2 2,3 3,1 1)", "LINESTRING(0 0,3 3,6 3)", true); test_geometry("LINESTRING(0 0,2 2,3 3,1 1,5 3)", "LINESTRING(0 0,3 3,6 3)", "1F100F102"); test_geometry("LINESTRING(5 3,1 1,3 3,2 2,0 0)", "LINESTRING(0 0,3 3,6 3)", "1F100F102"); test_geometry("LINESTRING(0 0,2 2,3 3,1 1,5 3)", "LINESTRING(6 3,3 3,0 0)", "1F100F102"); test_geometry("LINESTRING(5 3,1 1,3 3,2 2,0 0)", "LINESTRING(6 3,3 3,0 0)", "1F100F102"); // spikes test_geometry("LINESTRING(0 0,10 0)", "LINESTRING(1 0,9 0,2 0)", "101FF0FF2"); test_geometry("LINESTRING(0 0,2 2,3 3,1 1)", "LINESTRING(0 0,3 3,6 3)", "1FF00F102"); test_geometry("LINESTRING(0 0,2 2,3 3,1 1)", "LINESTRING(0 0,4 4,6 3)", "1FF00F102"); test_geometry("LINESTRING(0 0,2 2,3 3,4 4)", "LINESTRING(0 0,1 1,4 4)", "1FFF0FFF2"); // loop i/i i/i u/u u/u test_geometry("LINESTRING(0 0,10 0)", "LINESTRING(1 1,1 0,6 0,6 1,4 1,4 0,9 0,9 1)", "1F1FF0102"); // self-intersecting and self-touching equal test_geometry("LINESTRING(0 5,5 5,10 5,10 10,5 10,5 5,5 0)", "LINESTRING(0 5,5 5,5 10,10 10,10 5,5 5,5 0)", "1FFF0FFF2"); // self-intersecting loop and self-touching equal test_geometry("LINESTRING(0 5,5 5,10 5,10 10,5 10,5 5,10 5,10 10,5 10,5 5,5 0)", "LINESTRING(0 5,5 5,5 10,10 10,10 5,5 5,5 0)", "1FFF0FFF2"); test_geometry("LINESTRING(0 0,1 1)", "LINESTRING(0 1,1 0)", "0F1FF0102"); test_geometry("LINESTRING(0 0,1 1)", "LINESTRING(1 1,2 0)", "FF1F00102"); test_geometry("LINESTRING(0 0,1 1)", "LINESTRING(2 0,1 1)", "FF1F00102"); test_geometry("LINESTRING(0 0,1 0,2 1,3 5,4 0)", "LINESTRING(1 0,2 1,3 5)", "101FF0FF2"); test_geometry("LINESTRING(0 0,1 0,2 1,3 5,4 0)", "LINESTRING(3 5,2 1,1 0)", "101FF0FF2"); test_geometry("LINESTRING(1 0,2 1,3 5)", "LINESTRING(4 0,3 5,2 1,1 0,0 0)", "1FF0FF102"); test_geometry("LINESTRING(3 5,2 1,1 0)", "LINESTRING(4 0,3 5,2 1,1 0,0 0)", "1FF0FF102"); test_geometry("LINESTRING(0 0,10 0)", "LINESTRING(-1 -1,1 0,10 0,20 -1)", "1F10F0102"); test_geometry("LINESTRING(0 0,10 0)", "LINESTRING(20 -1,10 0,1 0,-1 -1)", "1F10F0102"); test_geometry("LINESTRING(-1 1,0 0,1 0,5 0,5 5,10 5,15 0,31 0)", "LINESTRING(-1 -1,0 0,1 0,2 0,3 1,4 0,30 0)", "101FF0102"); test_geometry("LINESTRING(-1 1,0 0,1 0,5 0,5 5,10 5,15 0,31 0)", "LINESTRING(30 0,4 0,3 1,2 0,1 0,0 0,-1 -1)", "101FF0102"); test_geometry("LINESTRING(31 0,15 0,10 5,5 5,5 0,1 0,0 0,-1 1)", "LINESTRING(-1 -1,0 0,1 0,2 0,3 1,4 0,30 0)", "101FF0102"); test_geometry("LINESTRING(31 0,15 0,10 5,5 5,5 0,1 0,0 0,-1 1)", "LINESTRING(30 0,4 0,3 1,2 0,1 0,0 0,-1 -1)", "101FF0102"); // self-IP test_geometry("LINESTRING(1 0,9 0)", "LINESTRING(0 0,10 0,10 10,5 0,0 10)", "1FF0FF102"); test_geometry("LINESTRING(1 0,5 0,9 0)", "LINESTRING(0 0,10 0,10 10,5 0,0 10)", "1FF0FF102"); test_geometry("LINESTRING(1 0,9 0)", "LINESTRING(0 0,10 0,10 10,5 10,5 -1)", "1FF0FF102"); test_geometry("LINESTRING(1 0,9 0)", "LINESTRING(0 0,10 0,5 0,5 5)", "1FF0FF102"); test_geometry("LINESTRING(1 0,7 0)", "LINESTRING(0 0,10 0,10 10,4 -1)", "1FF0FF102"); test_geometry("LINESTRING(1 0,5 0,7 0)", "LINESTRING(0 0,10 0,10 10,4 -1)", "1FF0FF102"); test_geometry("LINESTRING(1 0,7 0,8 1)", "LINESTRING(0 0,10 0,10 10,4 -1)", "1F10F0102"); test_geometry("LINESTRING(1 0,5 0,7 0,8 1)", "LINESTRING(0 0,10 0,10 10,4 -1)", "1F10F0102"); // linear ring test_geometry("LINESTRING(0 0,10 0)", "LINESTRING(5 0,9 0,5 5,1 0,5 0)", "1F1FF01F2"); test_geometry("LINESTRING(0 0,5 0,10 0)", "LINESTRING(5 0,9 0,5 5,1 0,5 0)", "1F1FF01F2"); test_geometry("LINESTRING(0 0,5 0,10 0)", "LINESTRING(5 0,10 0,5 5,1 0,5 0)", "1F10F01F2"); test_geometry("LINESTRING(0 0,5 0)", "LINESTRING(5 0,10 0,5 5,0 0,5 0)", "1FF0FF1F2"); test_geometry("LINESTRING(0 0,5 0)", "LINESTRING(5 0,10 0,5 5,5 0)", "FF10F01F2"); //to_svg("LINESTRING(0 0,5 0)", "LINESTRING(5 0,10 0,5 5,5 0)", "test_relate_00.svg"); // INVALID LINESTRINGS // 1-point LS (a Point) NOT disjoint //test_geometry("LINESTRING(1 0)", "LINESTRING(0 0,5 0)", "0FFFFF102"); //test_geometry("LINESTRING(0 0,5 0)", "LINESTRING(1 0)", "0F1FF0FF2"); //test_geometry("LINESTRING(0 0,5 0)", "LINESTRING(1 0,1 0)", "0F1FF0FF2"); //test_geometry("LINESTRING(0 0,5 0)", "LINESTRING(1 0,1 0,1 0)", "0F1FF0FF2"); // Point/Point //test_geometry("LINESTRING(0 0)", "LINESTRING(0 0)", "0FFFFFFF2"); // OTHER MASKS { namespace bgdr = bg::detail::relate; ls ls1, ls2, ls3; bg::read_wkt("LINESTRING(0 0,2 0)", ls1); bg::read_wkt("LINESTRING(2 0,4 0)", ls2); bg::read_wkt("LINESTRING(1 0,1 1)", ls3); BOOST_CHECK(bgdr::relate(ls1, ls2, bgdr::mask9("FT*******") || bgdr::mask9("F**T*****") || bgdr::mask9("F***T****"))); BOOST_CHECK(bgdr::relate(ls1, ls3, bgdr::mask9("FT*******") || bgdr::mask9("F**T*****") || bgdr::mask9("F***T****"))); BOOST_CHECK(bgdr::relate(ls3, ls1, bgdr::mask9("FT*******") || bgdr::mask9("F**T*****") || bgdr::mask9("F***T****"))); } } template void test_linestring_multi_linestring() { typedef bg::model::linestring

ls; typedef bg::model::multi_linestring mls; // LS disjoint test_geometry("LINESTRING(0 0,10 0)", "MULTILINESTRING((1 0,2 0),(1 1,2 1))", "101FF0102"); // linear ring disjoint test_geometry("LINESTRING(0 0,10 0)", "MULTILINESTRING((1 0,2 0),(1 1,2 1,2 2,1 1))", "101FF01F2"); // 2xLS forming non-simple linear ring disjoint test_geometry("LINESTRING(0 0,10 0)", "MULTILINESTRING((1 0,2 0),(1 1,2 1,2 2),(1 1,2 2))", "101FF01F2"); // INVALID LINESTRINGS // 1-point LS (a Point) disjoint //test_geometry("LINESTRING(0 0,10 0)", "MULTILINESTRING((1 0,2 0),(1 1))", "101FF00F2"); //test_geometry("LINESTRING(0 0,10 0)", "MULTILINESTRING((1 0,2 0),(1 1,1 1))", "101FF00F2"); //test_geometry("LINESTRING(0 0,10 0)", "MULTILINESTRING((1 0,2 0),(1 1,1 1,1 1))", "101FF00F2"); // 1-point LS (a Point) NOT disjoint //test_geometry("LINESTRING(0 0,10 0)", "MULTILINESTRING((1 0,9 0),(2 0))", "101FF0FF2"); //test_geometry("LINESTRING(0 0,10 0)", "MULTILINESTRING((1 0,9 0),(2 0,2 0))", "101FF0FF2"); //test_geometry("LINESTRING(0 0,10 0)", "MULTILINESTRING((1 0,9 0),(2 0,2 0,2 0))", "101FF0FF2"); } template void test_linestring_polygon() { typedef bg::model::linestring

ls; typedef bg::model::polygon

poly; typedef bg::model::ring

ring; // LS disjoint test_geometry("LINESTRING(11 0,11 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "FF1FF0212"); test_geometry("LINESTRING(11 0,11 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "FF1FF0212"); // II BB test_geometry("LINESTRING(0 0,10 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "1FFF0F212"); test_geometry("LINESTRING(5 0,5 5,10 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "1FFF0F212"); test_geometry("LINESTRING(5 1,5 5,9 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "1FF0FF212"); // IE test_geometry("LINESTRING(11 1,11 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "FF1FF0212"); // IE IB0 test_geometry("LINESTRING(11 1,10 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "FF1F00212"); // IE IB1 test_geometry("LINESTRING(11 1,10 5,10 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "F11F00212"); test_geometry("LINESTRING(11 1,10 10,0 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "F11F00212"); test_geometry("LINESTRING(11 1,10 0,0 0)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "F11F00212"); test_geometry("LINESTRING(0 -1,1 0,2 0)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "F11F00212"); // IE IB0 II test_geometry("LINESTRING(11 1,10 5,5 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "1010F0212"); // IE IB0 lring test_geometry("LINESTRING(11 1,10 5,11 5,11 1)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "F01FFF212"); // IE IB1 lring test_geometry("LINESTRING(11 1,10 5,10 10,11 5,11 1)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "F11FFF212"); // IB1 II test_geometry("LINESTRING(0 0,5 0,5 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "11F00F212"); // BI0 II IB1 test_geometry("LINESTRING(5 0,5 5,10 5,10 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "11FF0F212"); // IB1 II IB1 test_geometry("LINESTRING(1 0,2 0,3 1,4 0,5 0)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "11FF0F212"); // IB1 IE IB1 test_geometry("LINESTRING(1 0,2 0,3 -1,4 0,5 0)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "F11F0F212"); // II IB1 test_geometry("LINESTRING(5 5,10 5,10 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "11F00F212"); // IB1 II test_geometry("LINESTRING(10 10,10 5,5 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "11F00F212"); // IE IB1 test_geometry("LINESTRING(15 5,10 5,10 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "F11F00212"); // IB1 IE test_geometry("LINESTRING(10 10,10 5,15 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "F11F00212"); // II IB0 IE test_geometry("LINESTRING(5 5,10 5,15 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "1010F0212"); // non-simple polygon with hole test_geometry("LINESTRING(9 1,10 5,9 9)", "POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5))", "10F0FF212"); test_geometry("LINESTRING(10 1,10 5,10 9)", "POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5))", "F1FF0F212"); test_geometry("LINESTRING(2 8,10 5,2 2)", "POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5))", "F1FF0F212"); test_geometry("LINESTRING(10 1,10 5,2 2)", "POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5))", "F1FF0F212"); test_geometry("LINESTRING(10 1,10 5,2 8)", "POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5))", "F1FF0F212"); // non-simple polygon with hole, linear ring test_geometry("LINESTRING(9 1,10 5,9 9,1 9,1 1,9 1)", "POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5))", "10FFFF212"); test_geometry("LINESTRING(10 5,10 9,11 5,10 1,10 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5))", "F11FFF212"); test_geometry("LINESTRING(11 5,10 1,10 5,10 9,11 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5))", "F11FFF212"); // non-simple polygon with self-touching holes test_geometry("LINESTRING(7 1,8 5,7 9)", "POLYGON((0 0,0 10,10 10,10 0,0 0),(8 1,9 1,9 9,8 9,8 1),(2 2,8 5,2 8,2 2))", "10F0FF212"); test_geometry("LINESTRING(8 2,8 5,8 8)", "POLYGON((0 0,0 10,10 10,10 0,0 0),(8 1,9 1,9 9,8 9,8 1),(2 2,8 5,2 8,2 2))", "F1FF0F212"); test_geometry("LINESTRING(2 8,8 5,2 2)", "POLYGON((0 0,0 10,10 10,10 0,0 0),(8 1,9 1,9 9,8 9,8 1),(2 2,8 5,2 8,2 2))", "F1FF0F212"); // non-simple polygon self-touching test_geometry("LINESTRING(9 1,10 5,9 9)", "POLYGON((0 0,0 10,10 10,10 5,2 8,2 2,10 5,10 0,0 0))", "10F0FF212"); test_geometry("LINESTRING(10 1,10 5,10 9)", "POLYGON((0 0,0 10,10 10,10 5,2 8,2 2,10 5,10 0,0 0))", "F1FF0F212"); test_geometry("LINESTRING(2 8,10 5,2 2)", "POLYGON((0 0,0 10,10 10,10 5,2 8,2 2,10 5,10 0,0 0))", "F1FF0F212"); // non-simple polygon self-touching, linear ring test_geometry("LINESTRING(9 1,10 5,9 9,1 9,1 1,9 1)", "POLYGON((0 0,0 10,10 10,10 5,2 8,2 2,10 5,10 0,0 0))", "10FFFF212"); test_geometry("LINESTRING(10 5,10 9,11 5,10 1,10 5)", "POLYGON((0 0,0 10,10 10,10 5,2 8,2 2,10 5,10 0,0 0))", "F11FFF212"); test_geometry("LINESTRING(11 5,10 1,10 5,10 9,11 5)", "POLYGON((0 0,0 10,10 10,10 5,2 8,2 2,10 5,10 0,0 0))", "F11FFF212"); // polygons with some ring equal to the linestring test_geometry("LINESTRING(0 0,10 0,10 10,0 10,0 0)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "F1FFFF2F2"); test_geometry("LINESTRING(0 0,10 0,10 10,0 10,0 0)", "POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,5 5,2 8,2 2))", "F1FFFF212"); test_geometry("LINESTRING(2 2,5 5,2 8,2 2)", "POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,5 5,2 8,2 2))", "F1FFFF212"); // ccw { typedef bg::model::polygon ccwpoly; // IE IB0 II test_geometry("LINESTRING(11 1,10 5,5 5)", "POLYGON((0 0,10 0,10 10,0 10,0 0))", "1010F0212"); // IE IB1 II test_geometry("LINESTRING(11 1,10 1,10 5,5 5)", "POLYGON((0 0,10 0,10 10,0 10,0 0))", "1110F0212"); test_geometry("LINESTRING(11 1,10 5,10 1,5 5)", "POLYGON((0 0,10 0,10 10,0 10,0 0))", "1110F0212"); // II IB0 IE test_geometry("LINESTRING(5 1,10 5,11 1)", "POLYGON((0 0,10 0,10 10,0 10,0 0))", "1010F0212"); // IE IB1 II test_geometry("LINESTRING(5 5,10 1,10 5,11 5)", "POLYGON((0 0,10 0,10 10,0 10,0 0))", "1110F0212"); test_geometry("LINESTRING(5 5,10 5,10 1,11 5)", "POLYGON((0 0,10 0,10 10,0 10,0 0))", "1110F0212"); } } template void test_linestring_multi_polygon() { typedef bg::model::linestring

ls; typedef bg::model::polygon

poly; typedef bg::model::multi_polygon mpoly; test_geometry("LINESTRING(10 1,10 5,10 9)", "MULTIPOLYGON(((0 20,0 30,10 30,10 20,0 20)),((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5)))", "F1FF0F212"); test_geometry("LINESTRING(10 1,10 5,10 9)", "MULTIPOLYGON(((0 20,0 30,10 30,10 20,0 20)),((0 0,0 10,10 10,10 0,0 0)))", "F1FF0F212"); test_geometry("LINESTRING(10 1,10 5,2 2)", "MULTIPOLYGON(((0 20,0 30,10 30,10 20,0 20)),((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5)))", "F1FF0F212"); test_geometry("LINESTRING(10 1,10 5,2 2)", "MULTIPOLYGON(((0 20,0 30,10 30,10 20,0 20)),((0 0,0 10,10 10,10 0,0 0)))", "11F00F212"); test_geometry("LINESTRING(10 1,10 5,2 2)", "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5)),((10 5,3 3,3 7,10 5)))", "F1FF0F212"); test_geometry("LINESTRING(10 1,10 5,2 8)", "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5)),((10 5,3 3,3 7,10 5)))", "F1FF0F212"); test_geometry("LINESTRING(10 1,10 5,3 3)", "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5)),((10 5,3 3,3 7,10 5)))", "F1FF0F212"); test_geometry("LINESTRING(10 1,10 5,3 7)", "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5)),((10 5,3 3,3 7,10 5)))", "F1FF0F212"); test_geometry("LINESTRING(10 1,10 5,5 5)", "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5)),((10 5,3 3,3 7,10 5)))", "11F00F212"); test_geometry("LINESTRING(0 0,10 0,10 10,0 10,0 0)", "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((20 0,20 10,30 20,20 0)))", "F1FFFF212"); } template void test_multi_linestring_multi_polygon() { typedef bg::model::linestring

ls; typedef bg::model::polygon

poly; typedef bg::model::multi_linestring mls; typedef bg::model::multi_polygon mpoly; // polygons with some ring equal to the linestrings test_geometry("MULTILINESTRING((0 0,10 0,10 10,0 10,0 0),(20 20,50 50,20 80,20 20))", "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))", "F11FFF2F2"); test_geometry("MULTILINESTRING((0 0,10 0,10 10,0 10,0 0),(2 2,5 5,2 8,2 2))", "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),(2 2,5 5,2 8,2 2)))", "F1FFFF2F2"); test_geometry("MULTILINESTRING((0 0,10 0,10 10),(10 10,0 10,0 0))", "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))", "F1FFFF2F2"); test_geometry("MULTILINESTRING((0 0,10 0,10 10),(10 10,0 10,0 0),(20 20,50 50,20 80,20 20))", "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))", "F11FFF2F2"); } template void test_all() { test_point_point

(); test_point_multipoint

(); test_multipoint_multipoint

(); test_point_linestring

(); test_point_multilinestring

(); test_linestring_linestring

(); test_linestring_multi_linestring

(); test_linestring_polygon

(); test_linestring_multi_polygon

(); test_multi_linestring_multi_polygon

(); } int test_main( int , char* [] ) { test_all >(); test_all >(); #if defined(HAVE_TTMATH) test_all >(); #endif return 0; }