Merge branch 'develop' of https://github.com/boostorg/geometry into feature/shortest_points_new_strategies_all_cartesian

This commit is contained in:
Vissarion Fisikopoulos
2021-10-20 13:04:41 +03:00
54 changed files with 1355 additions and 784 deletions

View File

@@ -26,7 +26,16 @@ test-suite boost-geometry-algorithms-buffer
[ run buffer_multi_linestring.cpp : : : <define>BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE : algorithms_buffer_multi_linestring ]
[ run buffer_multi_polygon.cpp : : : <define>BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE : algorithms_buffer_multi_polygon ]
[ run buffer_linestring_aimes.cpp : : : <define>BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE : algorithms_buffer_linestring_aimes ]
# Uncomment next line if you want to test this manually; requires access to data/ folder
# TODO
# [ run buffer_linestring.cpp : : : <define>BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE <define>BOOST_GEOMETRY_NO_ROBUSTNESS : algorithms_buffer_linestring_norescale ]
# [ run buffer_multi_linestring.cpp : : : <define>BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE <define>BOOST_GEOMETRY_NO_ROBUSTNESS : algorithms_buffer_multi_linestring_norescale ]
[ run buffer_ring.cpp : : : <define>BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE <define>BOOST_GEOMETRY_NO_ROBUSTNESS : algorithms_buffer_ring_norescale ]
[ run buffer_polygon.cpp : : : <define>BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE <define>BOOST_GEOMETRY_NO_ROBUSTNESS : algorithms_buffer_polygon_norescale ]
[ run buffer_multi_point.cpp : : : <define>BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE <define>BOOST_GEOMETRY_NO_ROBUSTNESS : algorithms_buffer_multi_point_norescale ]
[ run buffer_multi_polygon.cpp : : : <define>BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE <define>BOOST_GEOMETRY_NO_ROBUSTNESS : algorithms_buffer_multi_polygon_norescale ]
[ run buffer_linestring_aimes.cpp : : : <define>BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE <define>BOOST_GEOMETRY_NO_ROBUSTNESS : algorithms_buffer_linestring_aimes_norescale ]
# Uncomment next lines if you want to test this manually; requires access to data/ folder
# [ run buffer_countries.cpp : : : <define>BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE : algorithms_buffer_countries ]
# [ run buffer_countries.cpp : : : <define>BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE <define>BOOST_GEOMETRY_NO_ROBUSTNESS : algorithms_buffer_countries_norescale ]
;

View File

@@ -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 <boost/variant/variant.hpp>
#include <geometry_test_common.hpp>
#include <boost/geometry/geometries/geometries.hpp>
@@ -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<G, typename bg::point_type<G>::type>;
variant_t v = g, vo;
bg::densify(v, vo, max_distance);
check(v, vo, def_s);
bg::model::geometry_collection<variant_t> gc{v}, gco;
bg::densify(gc, gco, max_distance);
check(gc, gco, def_s);
}
{

View File

@@ -491,6 +491,24 @@ void test_variant()
//BOOST_CHECK_CLOSE(bg::distance(point, v2, s), bg::distance(point, point, s), 0.0001);
}
template <typename T>
void test_geometry_collection()
{
using point_type = bg::model::point<T, 2, bg::cs::cartesian>;
using segment_type = bg::model::segment<point_type>;
using box_type = bg::model::box<point_type>;
using variant_type = boost::variant<point_type, segment_type, box_type>;
using gc_type = bg::model::geometry_collection<variant_type>;
point_type p1 {1, 3}, p2 {2, 3};
segment_type s1 {{2, 2}, {4, 4}}, s2 {{3, 2}, {5, 4}};
gc_type gc1 {p1, s1}, gc2 {p2, s2};
BOOST_CHECK_CLOSE(bg::distance(p1, gc2), bg::distance(p1, p2), 0.0001);
BOOST_CHECK_CLOSE(bg::distance(gc1, s2), bg::distance(s1, s2), 0.0001);
BOOST_CHECK_CLOSE(bg::distance(gc1, gc2), bg::distance(s1, s2), 0.0001);
}
int test_main(int, char* [])
{
#ifdef TEST_ARRAY
@@ -525,5 +543,7 @@ int test_main(int, char* [])
test_variant<double>();
test_variant<int>();
test_geometry_collection<double>();
return 0;
}

View File

@@ -21,6 +21,7 @@
#include <boost/geometry/algorithms/envelope.hpp>
#include <boost/geometry/geometries/box.hpp>
#include <boost/geometry/geometries/geometry_collection.hpp>
#include <boost/geometry/strategies/strategies.hpp>
#include <boost/geometry/io/wkt/read.hpp>
@@ -97,6 +98,10 @@ void test_envelope(std::string const& wkt,
check_result<box_type, bg::dimension<Geometry>::type::value>
::apply(b, x1, y1, z1, x2, y2, z2);
bg::model::geometry_collection<boost::variant<Geometry>> gc{v};
bg::envelope(gc, b);
check_result<box_type, bg::dimension<Geometry>::type::value>
::apply(b, x1, y1, z1, x2, y2, z2);
}

View File

@@ -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 <boost/geometry/algorithms/intersection.hpp>
#include <boost/geometry/algorithms/reverse.hpp>
#include <boost/geometry/geometries/geometry_collection.hpp>
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<point_type>; // cw, closed
using variant_type = boost::variant
<
linestring_type, multi_linestring_type, polygon_type
>;
using gc_type = bg::model::geometry_collection<variant_type>;
typedef test_valid_variant<gc_type> test;
gc_type gc;
linestring_type valid_linestring =
from_wkt<linestring_type>("LINESTRING(0 0,1 0)");
multi_linestring_type invalid_multi_linestring =
from_wkt<multi_linestring_type>("MULTILINESTRING((0 0,1 0),(0 0))");
polygon_type valid_polygon =
from_wkt<polygon_type>("POLYGON((0 0,1 1,1 0,0 0))");
polygon_type invalid_polygon =
from_wkt<polygon_type>("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);
}

View File

@@ -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<point, true, false> open_polygon;
typedef bg::model::multi_polygon<open_polygon> open_multi_polygon;
using variant = boost::variant<linestring, polygon>;
using open_variant = boost::variant<linestring, open_polygon>;
using geometry_collection = bg::model::geometry_collection<variant>;
using open_geometry_collection = bg::model::geometry_collection<open_variant>;
test_num_points<point>("POINT(0 0)", 1u);
test_num_points<linestring>("LINESTRING(0 0,1 1)", 2u);
test_num_points<segment>("LINESTRING(0 0,1 1)", 2u);
@@ -89,6 +99,12 @@ int test_main(int, char* [])
test_num_points<open_multi_polygon>("MULTIPOLYGON(((0 0,0 10,10 10,10 0)),((0 10,1 10,1 9)))", 7u, 9u);
test_num_points<open_multi_polygon>("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((0 10,1 10,1 9,0 10)))", 7u, 9u);
test_num_points<variant>("POLYGON((0 0,1 1,0 1,0 0))", 4u);
test_num_points<open_variant>("POLYGON((0 0,1 1,0 1))", 3u, 4u);
test_num_points<geometry_collection>("GEOMETRYCOLLECTION(POLYGON((0 0,1 1,0 1,0 0)),LINESTRING(0 0,1 1))", 6u);
test_num_points<open_geometry_collection>("GEOMETRYCOLLECTION(POLYGON((0 0,1 1,0 1)),LINESTRING(0 0,1 1))", 5u, 6u);
return 0;
}

View File

@@ -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<linestring, polygon_cw_closed>;
using geometry_collection = bg::model::geometry_collection<variant>;
using tester = test_num_segments<geometry_collection>;
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);
}

View File

@@ -16,16 +16,15 @@
test-suite boost-geometry-algorithms-difference
:
[ run difference.cpp : : : <define>BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE
: algorithms_difference ]
[ run difference.cpp : : : <define>BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE : algorithms_difference ]
[ run difference_multi.cpp : : : <define>BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE : algorithms_difference_multi ]
[ run difference.cpp : : : <define>BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE <define>BOOST_GEOMETRY_NO_ROBUSTNESS : algorithms_difference_norescale ]
[ run difference_multi.cpp : : : <define>BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE <define>BOOST_GEOMETRY_NO_ROBUSTNESS : algorithms_difference_multi_norescale ]
[ run difference_multi_spike.cpp : : : <define>BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE : algorithms_difference_multi_spike ]
[ run difference_areal_linear.cpp : : : : algorithms_difference_areal_linear ]
[ run difference_l_a_sph.cpp : : : : algorithms_difference_l_a_sph ]
[ run difference_linear_linear.cpp : : : : algorithms_difference_linear_linear ]
[ run difference_multi.cpp : : : <define>BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE
: algorithms_difference_multi ]
[ run difference_multi_areal_linear.cpp : : : : algorithms_difference_multi_areal_linear ]
[ run difference_multi_spike.cpp : : : <define>BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE
: algorithms_difference_multi_spike ]
[ run difference_pl_a.cpp : : : : algorithms_difference_pl_a ]
[ run difference_pl_l.cpp : : : : algorithms_difference_pl_l ]
[ run difference_pl_pl.cpp : : : : algorithms_difference_pl_pl ]

View File

@@ -51,7 +51,7 @@ void test_spikes_in_ticket_8364()
"MULTIPOLYGON(((1032 2556,1778 2556,1032 2130,1032 2556)),((3234 2580,3234 2556,1778 2556,2136 2760,3234 2580)))",
count_set(1, 2), -1, expectation_limits(2615783, 2616030), // SQL Server: 2616029.55616044
1, -1, expectation_limits(161054, 161134), // SQL Server: 161054.560110092
count_set(1, 3));
count_set(1, 3), ignore_validity);
}
template <typename P, bool ClockWise, bool Closed>

View File

@@ -16,12 +16,12 @@
test-suite boost-geometry-algorithms-intersection
:
[ run intersection.cpp : : : <define>BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE
: algorithms_intersection ]
[ run intersection.cpp : : : <define>BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE : algorithms_intersection ]
[ run intersection_multi.cpp : : : <define>BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE : algorithms_intersection_multi ]
[ run intersection.cpp : : : <define>BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE <define>BOOST_GEOMETRY_NO_ROBUSTNESS : algorithms_intersection_norescale ]
[ run intersection_multi.cpp : : : <define>BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE <define>BOOST_GEOMETRY_NO_ROBUSTNESS : algorithms_intersection_multi_norescale ]
[ run intersection_areal_areal_linear.cpp : : : : algorithms_intersection_areal_areal_linear ]
[ run intersection_linear_linear.cpp : : : : algorithms_intersection_linear_linear ]
[ run intersection_multi.cpp : : : <define>BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE
: algorithms_intersection_multi ]
[ run intersection_pl_a.cpp : : : : algorithms_intersection_pl_a ]
[ run intersection_pl_l.cpp : : : : algorithms_intersection_pl_l ]
[ run intersection_pl_pl.cpp : : : : algorithms_intersection_pl_pl ]

View File

@@ -16,14 +16,14 @@
test-suite boost-geometry-algorithms-union
:
[ run union.cpp : : : <define>BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE
: algorithms_union ]
[ run union.cpp : : : <define>BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE : algorithms_union ]
[ run union_multi.cpp : : : <define>BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE : algorithms_union_multi ]
[ run union.cpp : : : <define>BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE <define>BOOST_GEOMETRY_NO_ROBUSTNESS : algorithms_union_norescale ]
[ run union_multi.cpp : : : <define>BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE <define>BOOST_GEOMETRY_NO_ROBUSTNESS : algorithms_union_multi_norescale ]
[ run union_aa_geo.cpp : : : : algorithms_union_aa_geo ]
[ run union_aa_sph.cpp : : : : algorithms_union_aa_sph ]
[ run union_linear_linear.cpp : : : : algorithms_union_linear_linear ]
[ run union_multi.cpp : : : <define>BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE
: algorithms_union_multi ]
[ run union_pl_pl.cpp : : : : algorithms_union_pl_pl ]
[ run union_tupled.cpp : : : : algorithms_union_tupled ]
[ run union_other_types.cpp : : : : algorithms_union_other_types ]
[ run union_other_types.cpp : : : <define>BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE : algorithms_union_other_types ]
;

View File

@@ -113,6 +113,7 @@ int test_main(int, char* [])
using bg::model::d2::point_xy;
#if ! defined(BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE)
// Standard floating point types
test_areal<point_xy<float>>({exclude::hard});
test_areal<point_xy<double>>({});
@@ -121,23 +122,30 @@ int test_main(int, char* [])
// Standard integer types
test_areal<point_xy<std::int16_t>>({exclude::fp});
test_areal<point_xy<std::int32_t>>({exclude::fp});
#endif
test_areal<point_xy<std::int64_t>>({exclude::fp});
// Boost multi precision (integer)
test_areal<point_xy<bm::int128_t>>({exclude::fp});
#if ! defined(BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE)
test_areal<point_xy<bm::checked_int128_t>>({exclude::fp});
#endif
// Boost multi precision (floating point)
#if ! defined(BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE)
test_areal<point_xy<bm::number<bm::cpp_bin_float<5>>>>();
test_areal<point_xy<bm::number<bm::cpp_bin_float<10>>>>();
test_areal<point_xy<bm::number<bm::cpp_bin_float<50>>>>();
#endif
test_areal<point_xy<bm::number<bm::cpp_bin_float<100>>>>();
test_areal<point_xy<bm::number<bm::cpp_dec_float<50>>>>({});
// Boost multi precision (rational)
test_areal<point_xy<bm::cpp_rational>>({exclude::fp});
#if ! defined(BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE)
test_areal<point_xy<bm::checked_cpp_rational>>({exclude::fp});
#endif
// Boost multi precision float128 wrapper, is currently NOT supported
// and it is limited to certain compilers anyway
@@ -146,8 +154,10 @@ int test_main(int, char* [])
// Boost rational (tests compilation)
// (the rectangular case is correct; other input might give wrong results)
// The int16 version throws a <zero denominator> exception
#if ! defined(BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE)
test_areal<point_xy<boost::rational<std::int16_t>>>({exclude::all});
test_areal<point_xy<boost::rational<std::int32_t>>>({exclude::fp});
#endif
test_areal<point_xy<boost::rational<std::int64_t>>>({exclude::fp});
return 0;

View File

@@ -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<bg::model::segment<P> >(
"SEGMENT(0 0, 1 1)",
"SEGMENT(0 0, 1 1)", 1.0);
test_geometry<bg::model::box<P> >(
"BOX(0 0, 1 1)",
"BOX(0 0, 1 1)", 1.0);
test_geometry<bg::model::multi_point<P> >(
"MULTIPOINT(0 0, 1 1, 2 2)",
"MULTIPOINT(0 0, 1 1, 2 2)", 1.0);
// RING: check compilation and behaviour
test_geometry<bg::model::ring<P> >(

View File

@@ -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 <geometry_test_common.hpp>
#include <boost/geometry/algorithms/perimeter.hpp>
#include <boost/geometry/geometries/geometry_collection.hpp>
#include <boost/geometry/strategies/strategies.hpp>
#include <boost/geometry/io/wkt/read.hpp>
@@ -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<Geometry> v(geometry);
perimeter = bg::perimeter(v);
BOOST_CHECK_CLOSE(perimeter, expected_perimeter, 0.0001);
bg::model::geometry_collection<boost::variant<Geometry>> 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<Geometry> v(geometry);
perimeter = bg::perimeter(v, strategy);
BOOST_CHECK_CLOSE(perimeter, expected_perimeter, 0.0001);
bg::model::geometry_collection<boost::variant<Geometry>> gc{v};
perimeter = bg::perimeter(gc, strategy);
BOOST_CHECK_CLOSE(perimeter, expected_perimeter, 0.0001);
}
template <typename Geometry>
@@ -65,12 +91,7 @@ void test_geometry(std::string const& wkt, double expected_perimeter)
{
Geometry geometry;
bg::read_wkt(wkt, geometry);
boost::variant<Geometry> v(geometry);
test_perimeter(geometry, expected_perimeter);
#if !defined(BOOST_GEOMETRY_TEST_DEBUG)
test_perimeter(v, expected_perimeter);
#endif
}
template <typename Geometry, typename Strategy>

View File

@@ -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 <boost/geometry/algorithms/equals.hpp>
#include <boost/geometry/algorithms/simplify.hpp>
#include <boost/geometry/algorithms/distance.hpp>
#include <boost/geometry/geometries/geometry_collection.hpp>
#include <boost/geometry/strategies/strategies.hpp>
#include <boost/geometry/io/wkt/wkt.hpp>
#include <boost/variant/variant.hpp>
template <typename Geometry, typename Tag = typename bg::tag<Geometry>::type>
struct boost_variant_type
{
using type = boost::variant<Geometry, typename bg::point_type<Geometry>::type>;
};
template <typename Geometry>
struct boost_variant_type<Geometry, bg::point_tag>
{
using type = boost::variant<Geometry>;
};
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<Geometry> v(geometry);
using variant_t = typename boost_variant_type<Geometry>::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<double>
> dp;
BOOST_CONCEPT_ASSERT((bg::concepts::SimplifyStrategy<dp, point_type>));
check_geometry(geometry, expected, distance);
check_geometry(v, expected, distance);
BOOST_CONCEPT_ASSERT( (bg::concepts::SimplifyStrategy<dp, point_type>) );
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<variant_t>;
gc_t gc{v};
gc_t gc_simplified;
bg::simplify(gc, gc_simplified, distance);
bg::detail::visit_breadth_first([&](auto const& g)
{
test_equality<Geometry>::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<Geometry> v(geometry);
typename boost_variant_type<Geometry>::type v(geometry);
BOOST_CONCEPT_ASSERT( (bg::concepts::SimplifyStrategy<Strategy,
typename bg::point_type<Geometry>::type>) );