// Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2008-2015 Bruno Lalande, Paris, France. // Copyright (c) 2009-2015 Mateusz Loskot, London, UK. // This file was modified by Oracle on 2015, 2016. // Modifications copyright (c) 2015, Oracle and/or its affiliates. // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle // Contributed and/or modified by Menelaos Karavelas, 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 #include "test_envelope.hpp" #include #include #include #include #include #include BOOST_GEOMETRY_REGISTER_C_ARRAY_CS(cs::cartesian) BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian) template void test_2d() { test_envelope

("POINT(1 1)", 1, 1, 1, 1); test_envelope >("LINESTRING(1 1,2 2)", 1, 2, 1, 2); test_envelope >("POLYGON((1 1,1 3,3 3,3 1,1 1))", 1, 3, 1, 3); test_envelope >("POLYGON((1 1,1 3,3 3,3 1,1 1))", 1, 3, 1, 3); test_envelope >("BOX(1 1,3 3)", 1, 3, 1, 3); // Triangle, closed and open, and CCW. // Note that for the envelope algorithm, // these combinations should theoretically not differ test_envelope >("POLYGON((4 1,0 7,7 9,4 1))", 0, 7, 1, 9); test_envelope >("POLYGON((4 1,0 7,7 9))", 0, 7, 1, 9); test_envelope >("POLYGON((4 1,7 9,0 7,4 1))", 0, 7, 1, 9); test_envelope >("POLYGON((4 1,7 9,0 7))", 0, 7, 1, 9); typedef std::pair segment_type; test_envelope("SEGMENT(1 1,3 3)", 1, 3, 1, 3); } template void test_3d() { test_envelope

("POINT(1 2 3)", 1, 1, 2, 2, 3, 3); test_envelope

("POINT(3 2 1)", 3, 3, 2, 2, 1, 1); test_envelope >("LINESTRING(1 1 1,2 2 2)", 1, 2, 1, 2, 1, 2); test_envelope >("BOX(1 1 1,3 3 3)", 1, 3, 1, 3, 1, 3); } template void test_empty_geometry(std::string const& wkt) { typedef typename bg::coordinate_type::type ct; ct high_val = boost::numeric::bounds::highest(); ct low_val = boost::numeric::bounds::lowest(); test_envelope(wkt, high_val, low_val, high_val, low_val); } template void test_empty() { test_empty_geometry >("LINESTRING()"); test_empty_geometry >("POLYGON(())"); test_empty_geometry >("POLYGON(())"); test_empty_geometry >("MULTIPOINT()"); test_empty_geometry < bg::model::multi_linestring > >("MULTILINESTRING()"); test_empty_geometry < bg::model::multi_polygon > >("MULTIPOLYGON()"); } template void test_invalid() { // polygon with empty exterior and interior rings test_empty_geometry >("POLYGON((),(),())"); // polygon with empty interior rings test_envelope < bg::model::polygon

>("POLYGON((1 2,1 20,22 20,22 2,1 2),(),())", 1, 22, 2, 20); // another polygon with empty interior rings test_envelope < bg::model::polygon

>("POLYGON((1 2,1 20,22 20,22 2,1 2),(),(3 4,19 4,19 18,3 18,3 4),())", 1, 22, 2, 20); // polygon with empty exterior ring test_envelope < bg::model::polygon

>("POLYGON((),(),(3 4,19 4,19 18,3 18,3 4),())", 3, 19, 4, 18); // another polygon with empty exterior ring test_envelope < bg::model::polygon

>("POLYGON((),(),(3 4,19 4,19 18,3 18,3 4),(4 5,18 5,18 17,4 17,4 5))", 3, 19, 4, 18); // yet one more polygon with empty exterior ring test_envelope < bg::model::polygon

>("POLYGON((),(),(4 5,18 5,18 17,4 17,4 5),(3 4,19 4,19 18,3 18,3 4))", 3, 19, 4, 18); // multilinestring with empty linestrings test_empty_geometry < bg::model::multi_linestring > >("MULTILINESTRING((),(),())"); // multilinestring with empty and non-empty linestrings test_envelope < bg::model::multi_linestring > >("MULTILINESTRING((),(10 20),())", 10, 10, 20, 20); // multipolygon with empty polygon test_empty_geometry < bg::model::multi_polygon > >("MULTIPOLYGON((()))"); // multipolygon with many empty polygons test_empty_geometry < bg::model::multi_polygon > >("MULTIPOLYGON(((),(),()),(()),((),(),(),(),()))"); // multipolygon with empty polygons and non-empty (valid) polygon test_envelope < bg::model::multi_polygon > >("MULTIPOLYGON(((),(),()),((10 30,10 40,20 30,10 30)),\ ((),(),()),(()))", 10, 20, 30, 40); // multipolygon with empty polygons and non-empty (valid) polygon // that has an interior ring test_envelope < bg::model::multi_polygon > >("MULTIPOLYGON(((),(),()),(()),\ ((1 2,1 20,22 20,22 2,1 2),(3 4,19 4,19 18,3 18,3 4)),(()))", 1, 22, 2, 20); // multipolygon with empty polygons and non-empty (invalid) polygon // that has an interior ring but empty exterior ring test_envelope < bg::model::multi_polygon > >("MULTIPOLYGON(((),(),()),(()),((),(3 4,19 4,19 18,3 18,3 4)),(()))", 3, 19, 4, 18); // multipolygon with empty polygons and non-empty (invalid) polygon // that has an interior ring but empty exterior ring test_envelope < bg::model::multi_polygon > >("MULTIPOLYGON(((),(),()),((),(),(3 4,19 4,19 18,3 18,3 4),()),(()))", 3, 19, 4, 18); // multipolygon with empty polygons and non-empty (invalid) polygon // that has two non-empty interior rings but empty exterior ring test_envelope < bg::model::multi_polygon > >("MULTIPOLYGON(((),(),()),\ ((),(),(3 4,19 4,19 18,3 18,3 4),(4 5,18 5,18 17,4 17,4 5),()),\ (()))", 3, 19, 4, 18); } int test_main(int, char* []) { //test_2d(); //test_2d(); //test_2d(); test_2d >(); test_2d >(); test_2d >(); test_2d >(); test_3d(); test_3d >(); test_empty >(); test_empty >(); test_empty >(); test_empty >(); test_invalid >(); test_invalid >(); test_invalid >(); test_invalid >(); return 0; }