// Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test // Copyright (c) 2007-2025 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2008-2012 Bruno Lalande, Paris, France. // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. // This file was modified by Oracle on 2021. // Modifications copyright (c) 2021, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. // 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) #include template void test_mixed_orientation_and_closure() { namespace model = boost::geometry::model; // Ring, (counter)clockwise, closed/open check, model::ring>( "POLYGON((1 1,2 2,3 0,1 1))", "POLYGON((1 1,2 2,3 0,1 1))", 4); check, model::ring>( "POLYGON((1 1,2 2,3 0,1 1))", "POLYGON((1 1,3 0,2 2,1 1))", 4); check, model::ring>( "POLYGON((1 1,2 2,3 0,1 1))", "POLYGON((1 1,2 2,3 0))", 3); check, model::ring>( "POLYGON((1 1,2 2,3 0,1 1))", "POLYGON((1 1,3 0,2 2))", 3); check, model::ring>( "POLYGON((1 1,3 0,2 2,1 1))", "POLYGON((1 1,2 2,3 0,1 1))", 4); check, model::ring>( "POLYGON((1 1,3 0,2 2,1 1))", "POLYGON((1 1,3 0,2 2,1 1))", 4); check, model::ring>( "POLYGON((1 1,3 0,2 2,1 1))", "POLYGON((1 1,2 2,3 0))", 3); check, model::ring>( "POLYGON((1 1,3 0,2 2,1 1))", "POLYGON((1 1,3 0,2 2))", 3); check, model::ring>( "POLYGON((1 1,2 2,3 0))", "POLYGON((1 1,2 2,3 0,1 1))", 4); check, model::ring>( "POLYGON((1 1,2 2,3 0))", "POLYGON((1 1,3 0,2 2,1 1))", 4); check, model::ring>( "POLYGON((1 1,2 2,3 0))", "POLYGON((1 1,2 2,3 0))", 3); check, model::ring>( "POLYGON((1 1,2 2,3 0))", "POLYGON((1 1,3 0,2 2))", 3); check, model::ring>( "POLYGON((1 1,3 0,2 2))", "POLYGON((1 1,2 2,3 0,1 1))", 4); check, model::ring>( "POLYGON((1 1,3 0,2 2))", "POLYGON((1 1,3 0,2 2,1 1))", 4); check, model::ring>( "POLYGON((1 1,3 0,2 2))", "POLYGON((1 1,2 2,3 0))", 3); check, model::ring>( "POLYGON((1 1,3 0,2 2))", "POLYGON((1 1,3 0,2 2))", 3); // Polygon (using ring underneath, so most combinations can be omitted) check, model::polygon>( "POLYGON((0 0,0 5,5 5,5 0,0 0),(1 1,3 2,2 4,1 1))", "POLYGON((0 0,5 0,5 5,0 5,0 0),(1 1,2 4,3 2,1 1))"); check, model::polygon>( "POLYGON((0 0,0 5,5 5,5 0,0 0),(1 1,3 2,2 4,1 1))", "POLYGON((0 0,5 0,5 5,0 5,0 0),(1 1,2 4,3 2,1 1))", 7); check, model::ring>("POLYGON((1 1,2 2,3 0,1 1))", "POLYGON((1 1,3 0,2 2,1 1))"); using box1_t = model::box; check>("BOX(0 0,2 2)", "POLYGON((0 0,2 0,2 2,0 2,0 0))", 5); check>("BOX(0 0,2 2)", "POLYGON((0 0,0 2,2 2,2 0))", 4); check>("BOX(0 0,2 2)", "POLYGON((0 0,2 0,2 2,0 2))", 4); check>("BOX(0 0,2 2)", "POLYGON((0 0,2 0,2 2,0 2,0 0))", 5); check>("BOX(0 0,2 2)", "POLYGON((0 0,0 2,2 2,2 0,0 0))", 4); check>("BOX(0 0,2 2)", "POLYGON((0 0,2 0,2 2,0 2,0 0))", 4); } template void test_mixed_point_types() { namespace model = boost::geometry::model; const std::string point_simplex = "POINT(0 0)"; const std::string ls_simplex = "LINESTRING(1 1,2 2)"; const std::string mls_simplex = "MULTILINESTRING((1 1,2 2),(3 3,4 4))"; const std::string mpoint_simplex = "MULTIPOINT((1 1),(2 2))"; const std::string box_simplex = "BOX(0 0,1 1)"; const std::string ring_simplex = "POLYGON((0 0,0 1,1 1,1 0,0 0))"; const std::string poly_simplex = "POLYGON((0 0,0 5,5 5,5 0,0 0),(2 2,3 2,3 3,2 2))"; const std::string mpoly_simplex = "MULTIPOLYGON(" "((0 0,0 5,5 5,5 0,0 0),(2 2,3 2,3 3,2 2))," "((6 6,6 7,7 7,7 6,6 6))" ")"; using segment1_t = model::segment; using segment2_t = model::segment; using ls1_t = model::linestring; using ls2_t = model::linestring; using box1_t = model::box; using box2_t = model::box; using ring1_t = model::ring; using ring2_t = model::ring; using poly1_t = model::polygon; using poly2_t = model::polygon; using mpoint1_t = model::multi_point; using mpoint2_t = model::multi_point; using mls1_t = model::multi_linestring; using mls2_t = model::multi_linestring; using mpoly1_t = model::multi_polygon; using mpoly2_t = model::multi_polygon; check(point_simplex); check(ring_simplex); check(ls_simplex); check(ls_simplex); check(ring_simplex); check(poly_simplex); check(mpoint_simplex); check(mls_simplex); check(mpoly_simplex); check(point_simplex, "POLYGON((0 0,0 0,0 0,0 0,0 0))"); check(ls_simplex); check(box_simplex, "LINESTRING(0 0,0 1,1 1,1 0,0 0)"); check(box_simplex, ring_simplex); check(box_simplex, ring_simplex); check(ring_simplex); check(ring_simplex); // Interior rings are omitted going from polygon to ring check(poly_simplex, "POLYGON((0 0,0 5,5 5,5 0,0 0))"); // single -> multi check(point_simplex, "MULTIPOINT((0 0))"); check(ls_simplex, "MULTILINESTRING((1 1,2 2))"); check(ls_simplex, "MULTILINESTRING((1 1,2 2))"); check(ls_simplex, "MULTIPOINT((1 1),(2 2))"); check(box_simplex, "MULTIPOINT((0 0),(0 1),(1 1),(1 0))"); check(ring_simplex, "MULTIPOINT((0 0),(0 1),(1 1),(1 0),(0 0))"); check(ring_simplex, "MULTIPOINT((0 0),(0 1),(1 1),(1 0),(0 0))"); check(mls_simplex, "MULTIPOINT((1 1),(2 2),(3 3),(4 4))"); check(mpoly_simplex, "MULTIPOINT((0 0),(0 5),(5 5),(5 0),(0 0),(2 2),(3 2),(3 3),(2 2),(6 6),(6 7),(7 7),(7 6),(6 6))"); check(ring_simplex, "MULTILINESTRING((0 0,0 1,1 1,1 0,0 0))"); check(ring_simplex, "MULTILINESTRING((0 0,0 1,1 1,1 0,0 0))"); check(poly_simplex, "MULTILINESTRING((0 0,0 5,5 5,5 0,0 0),(2 2,3 2,3 3,2 2))"); check(mpoly_simplex, "MULTILINESTRING((0 0,0 5,5 5,5 0,0 0),(2 2,3 2,3 3,2 2),(6 6,6 7,7 7,7 6,6 6))"); check(box_simplex, "MULTIPOLYGON(((0 0,0 1,1 1,1 0,0 0)))"); check(ring_simplex, "MULTIPOLYGON(((0 0,0 1,1 1,1 0,0 0)))"); check(ring_simplex, "MULTIPOLYGON(((0 0,0 1,1 1,1 0,0 0)))"); check(poly_simplex, "MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0),(2 2,3 2,3 3,2 2)))"); } template void test_mixed_point_types_3d() { namespace model = boost::geometry::model; check("POINT(1 2 3)"); check, model::segment>( "LINESTRING(1 2 3,4 5 6)"); check, model::linestring>( "LINESTRING(1 2 3,4 5 6,7 8 9)"); check, model::linestring>( "LINESTRING(1 2 3,4 5 6)", "LINESTRING(1 2 3,4 5 6)", 2); } template void test_mixed_types() { test_mixed_point_types(); test_mixed_point_types(); test_mixed_orientation_and_closure(); test_mixed_orientation_and_closure(); } template void test_mixed_types_3d() { test_mixed_point_types_3d(); test_mixed_point_types_3d(); } void test_array() { int a[2] = {1, 2}; int b[2]; bg::convert(a, b); BOOST_CHECK_EQUAL(b[0], 1); BOOST_CHECK_EQUAL(b[1], 2); } int test_main(int, char* []) { test_mixed_types < bg::model::point, bg::model::point >(); test_mixed_types < boost::tuple, bg::model::point >(); test_mixed_types_3d < boost::tuple, bg::model::point >(); test_array(); return 0; }