diff --git a/test/algorithms/densify.cpp b/test/algorithms/densify.cpp index bf723bbc1..78aa81ea3 100644 --- a/test/algorithms/densify.cpp +++ b/test/algorithms/densify.cpp @@ -1,7 +1,7 @@ // Boost.Geometry // Unit Test -// Copyright (c) 2017-2018, Oracle and/or its affiliates. +// Copyright (c) 2017-2021, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -9,6 +9,8 @@ // http://www.boost.org/users/license.html +#include + #include #include @@ -159,6 +161,17 @@ inline void test_geometry(std::string const& wkt, Check const& check) bg::densify(g, o, max_distance); check_result(g, o, max_distance, def_s, check); + + using variant_t = boost::variant::type>; + variant_t v = g, vo; + bg::densify(v, vo, max_distance); + + check(v, vo, def_s); + + bg::model::geometry_collection gc{v}, gco; + bg::densify(gc, gco, max_distance); + + check(gc, gco, def_s); } { diff --git a/test/algorithms/envelope_expand/test_envelope.hpp b/test/algorithms/envelope_expand/test_envelope.hpp index 64792366c..0873d81ba 100644 --- a/test/algorithms/envelope_expand/test_envelope.hpp +++ b/test/algorithms/envelope_expand/test_envelope.hpp @@ -21,6 +21,7 @@ #include #include +#include #include #include @@ -97,6 +98,10 @@ void test_envelope(std::string const& wkt, check_result::type::value> ::apply(b, x1, y1, z1, x2, y2, z2); + bg::model::geometry_collection> gc{v}; + bg::envelope(gc, b); + check_result::type::value> + ::apply(b, x1, y1, z1, x2, y2, z2); } diff --git a/test/algorithms/is_valid.cpp b/test/algorithms/is_valid.cpp index 9c9ca4dde..f74b0b23c 100644 --- a/test/algorithms/is_valid.cpp +++ b/test/algorithms/is_valid.cpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2014-2018, Oracle and/or its affiliates. +// Copyright (c) 2014-2021, Oracle and/or its affiliates. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -27,6 +27,8 @@ #include #include +#include + BOOST_AUTO_TEST_CASE( test_is_valid_point ) { #ifdef BOOST_GEOMETRY_TEST_DEBUG @@ -1414,3 +1416,40 @@ BOOST_AUTO_TEST_CASE( test_is_valid_variant ) vg = invalid_polygon; test::apply("v04", vg, false); } + +BOOST_AUTO_TEST_CASE( test_is_valid_geometry_collection ) +{ +#ifdef BOOST_GEOMETRY_TEST_DEBUG + std::cout << std::endl << std::endl; + std::cout << "************************************" << std::endl; + std::cout << " is_valid: geometry collection" << std::endl; + std::cout << "************************************" << std::endl; +#endif + + using polygon_type = bg::model::polygon; // cw, closed + using variant_type = boost::variant + < + linestring_type, multi_linestring_type, polygon_type + >; + using gc_type = bg::model::geometry_collection; + + typedef test_valid_variant test; + + gc_type gc; + + linestring_type valid_linestring = + from_wkt("LINESTRING(0 0,1 0)"); + multi_linestring_type invalid_multi_linestring = + from_wkt("MULTILINESTRING((0 0,1 0),(0 0))"); + polygon_type valid_polygon = + from_wkt("POLYGON((0 0,1 1,1 0,0 0))"); + polygon_type invalid_polygon = + from_wkt("POLYGON((0 0,2 2,2 0,1 0))"); + + gc = {valid_linestring, valid_polygon}; + test::apply("gc01", gc, true); + gc = {invalid_multi_linestring, valid_polygon}; + test::apply("gc02", gc, false); + gc = {valid_linestring, invalid_polygon}; + test::apply("gc03", gc, false); +} diff --git a/test/algorithms/num_points.cpp b/test/algorithms/num_points.cpp index 6d24f43f0..997023701 100644 --- a/test/algorithms/num_points.cpp +++ b/test/algorithms/num_points.cpp @@ -6,6 +6,10 @@ // Copyright (c) 2009-2015 Mateusz Loskot, London, UK. // Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland. +// 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 + // 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) @@ -67,6 +71,12 @@ int test_main(int, char* []) typedef bg::model::polygon open_polygon; typedef bg::model::multi_polygon open_multi_polygon; + using variant = boost::variant; + using open_variant = boost::variant; + + using geometry_collection = bg::model::geometry_collection; + using open_geometry_collection = bg::model::geometry_collection; + test_num_points("POINT(0 0)", 1u); test_num_points("LINESTRING(0 0,1 1)", 2u); test_num_points("LINESTRING(0 0,1 1)", 2u); @@ -89,6 +99,12 @@ int test_main(int, char* []) test_num_points("MULTIPOLYGON(((0 0,0 10,10 10,10 0)),((0 10,1 10,1 9)))", 7u, 9u); test_num_points("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((0 10,1 10,1 9,0 10)))", 7u, 9u); + test_num_points("POLYGON((0 0,1 1,0 1,0 0))", 4u); + test_num_points("POLYGON((0 0,1 1,0 1))", 3u, 4u); + + test_num_points("GEOMETRYCOLLECTION(POLYGON((0 0,1 1,0 1,0 0)),LINESTRING(0 0,1 1))", 6u); + test_num_points("GEOMETRYCOLLECTION(POLYGON((0 0,1 1,0 1)),LINESTRING(0 0,1 1))", 5u, 6u); + return 0; } diff --git a/test/algorithms/num_segments.cpp b/test/algorithms/num_segments.cpp index f6f0ddbf1..7b1143d7c 100644 --- a/test/algorithms/num_segments.cpp +++ b/test/algorithms/num_segments.cpp @@ -1,9 +1,10 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2014, Oracle and/or its affiliates. +// Copyright (c) 2014-2021, Oracle and/or its affiliates. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle +// 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 @@ -289,3 +290,16 @@ BOOST_AUTO_TEST_CASE( test_variant ) variant_geometry = p_closed; tester::apply(variant_geometry, 4); } + +BOOST_AUTO_TEST_CASE( test_geometry_collection ) +{ + using variant = boost::variant; + using geometry_collection = bg::model::geometry_collection; + + using tester = test_num_segments; + + geometry_collection gc; + bg::read_wkt("GEOMETRYCOLLECTION(LINESTRING(0 0,1 1,2 2),POLYGON((0 0,0 1,1 1,1 0,0 0)))", gc); + + tester::apply(gc, 6); +} diff --git a/test/algorithms/simplify.cpp b/test/algorithms/simplify.cpp index 9ee2fbbdc..6ef7c6cb0 100644 --- a/test/algorithms/simplify.cpp +++ b/test/algorithms/simplify.cpp @@ -5,6 +5,10 @@ // 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. @@ -222,6 +226,18 @@ void test_all() "POINT(0 0)", "POINT(0 0)", 1.0); + test_geometry >( + "SEGMENT(0 0, 1 1)", + "SEGMENT(0 0, 1 1)", 1.0); + + test_geometry >( + "BOX(0 0, 1 1)", + "BOX(0 0, 1 1)", 1.0); + + test_geometry >( + "MULTIPOINT(0 0, 1 1, 2 2)", + "MULTIPOINT(0 0, 1 1, 2 2)", 1.0); + // RING: check compilation and behaviour test_geometry >( diff --git a/test/algorithms/test_perimeter.hpp b/test/algorithms/test_perimeter.hpp index 32a5defb6..0ba9a675e 100644 --- a/test/algorithms/test_perimeter.hpp +++ b/test/algorithms/test_perimeter.hpp @@ -2,6 +2,11 @@ // Unit Test // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. + +// 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 + // 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) @@ -15,6 +20,7 @@ #include #include +#include #include #include @@ -37,6 +43,16 @@ void test_perimeter(Geometry const& geometry, long double expected_perimeter) #endif BOOST_CHECK_CLOSE(perimeter, expected_perimeter, 0.0001); + + boost::variant v(geometry); + perimeter = bg::perimeter(v); + + BOOST_CHECK_CLOSE(perimeter, expected_perimeter, 0.0001); + + bg::model::geometry_collection> gc{v}; + perimeter = bg::perimeter(gc); + + BOOST_CHECK_CLOSE(perimeter, expected_perimeter, 0.0001); } @@ -58,6 +74,16 @@ void test_perimeter(Geometry const& geometry, long double expected_perimeter, St #endif BOOST_CHECK_CLOSE(perimeter, expected_perimeter, 0.0001); + + boost::variant v(geometry); + perimeter = bg::perimeter(v, strategy); + + BOOST_CHECK_CLOSE(perimeter, expected_perimeter, 0.0001); + + bg::model::geometry_collection> gc{v}; + perimeter = bg::perimeter(gc, strategy); + + BOOST_CHECK_CLOSE(perimeter, expected_perimeter, 0.0001); } template @@ -65,12 +91,7 @@ void test_geometry(std::string const& wkt, double expected_perimeter) { Geometry geometry; bg::read_wkt(wkt, geometry); - boost::variant v(geometry); - test_perimeter(geometry, expected_perimeter); -#if !defined(BOOST_GEOMETRY_TEST_DEBUG) - test_perimeter(v, expected_perimeter); -#endif } template diff --git a/test/algorithms/test_simplify.hpp b/test/algorithms/test_simplify.hpp index 2ae96d58b..352c5e881 100644 --- a/test/algorithms/test_simplify.hpp +++ b/test/algorithms/test_simplify.hpp @@ -2,6 +2,11 @@ // Unit Test // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. + +// 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 + // 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) @@ -18,11 +23,24 @@ #include #include #include +#include #include #include #include +template ::type> +struct boost_variant_type +{ + using type = boost::variant::type>; +}; + +template +struct boost_variant_type +{ + using type = boost::variant; +}; + template < typename GeometryForTag, @@ -158,8 +176,9 @@ void test_geometry(std::string const& wkt, bg::read_wkt(wkt, geometry); bg::read_wkt(expected_wkt, expected); - boost::variant v(geometry); - + using variant_t = typename boost_variant_type::type; + variant_t v(geometry); + // Define default strategy for testing typedef bg::strategy::simplify::douglas_peucker < @@ -167,15 +186,27 @@ void test_geometry(std::string const& wkt, bg::strategy::distance::projected_point > dp; + BOOST_CONCEPT_ASSERT((bg::concepts::SimplifyStrategy)); + check_geometry(geometry, expected, distance); check_geometry(v, expected, distance); - - - BOOST_CONCEPT_ASSERT( (bg::concepts::SimplifyStrategy) ); - + check_geometry(geometry, expected, distance, dp()); check_geometry(v, expected, distance, dp()); + // For now check GC here because it's not supported by equals() + { + using gc_t = bg::model::geometry_collection; + gc_t gc{v}; + gc_t gc_simplified; + bg::simplify(gc, gc_simplified, distance); + bg::detail::visit_breadth_first([&](auto const& g) + { + test_equality::apply(g, expected); + return false; + }, gc_simplified); + } + // Check inserter (if applicable) test_inserter < @@ -217,7 +248,7 @@ void test_geometry(std::string const& wkt, bg::correct_closure(geometry); bg::correct_closure(expected); - boost::variant v(geometry); + typename boost_variant_type::type v(geometry); BOOST_CONCEPT_ASSERT( (bg::concepts::SimplifyStrategy::type>) );