[DEV] add v1.76.0

This commit is contained in:
2021-10-05 21:37:46 +02:00
parent a97e9ae7d4
commit d0115b733d
45133 changed files with 4744437 additions and 1026325 deletions

View File

@@ -0,0 +1,17 @@
# Boost.Geometry (aka GGL, Generic Geometry Library)
#
# Copyright (c) 2020 Oracle and/or its affiliates.
#
# Contributed and/or modified by Vissarion Fisikopoulos, 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)
test-suite boost-geometry-algorithms-convex_hull
:
[ run convex_hull.cpp : : : : algorithms_convex_hull ]
[ run convex_hull_multi.cpp : : : : algorithms_convex_hull_multi ]
[ run convex_hull_robust.cpp : : : : algorithms_convex_hull_robust ]
[ run convex_hull_sph_geo.cpp : : : : algorithms_convex_hull_sph_geo ]
;

View File

@@ -0,0 +1,87 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Unit Test
// Copyright (c) 2007-2012 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 2015.
// Modifications copyright (c) 2015 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 <cstddef>
#include <string>
#include "test_convex_hull.hpp"
#include <boost/geometry/geometries/geometries.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
template <typename P>
void test_all()
{
typedef boost::geometry::strategies::convex_hull::cartesian<> strategy;
// from sample linestring
test_geometry<bg::model::linestring<P>, strategy >(
"linestring(1.1 1.1, 2.5 2.1, 3.1 3.1, 4.9 1.1, 3.1 1.9)", 5, 4, 3.8);
// rectangular, with concavity
test_geometry<bg::model::polygon<P>, strategy >(
"polygon((1 1, 1 4, 3 4, 3 3, 4 3, 4 4, 5 4, 5 1, 1 1))",
9, 5, 12.0);
// from sample polygon, with concavity
test_geometry<bg::model::polygon<P>, strategy >(
"polygon((2.0 1.3, 2.4 1.7, 2.8 1.8, 3.4 1.2, 3.7 1.6,3.4 2.0, 4.1 3.0"
", 5.3 2.6, 5.4 1.2, 4.9 0.8, 2.9 0.7,2.0 1.3))",
12, 8, 5.245);
test_geometry<bg::model::ring<P>, strategy >(
"polygon((2.0 1.3, 2.4 1.7, 2.8 1.8, 3.4 1.2, 3.7 1.6,3.4 2.0, 4.1 3.0"
", 5.3 2.6, 5.4 1.2, 4.9 0.8, 2.9 0.7,2.0 1.3))",
12, 8, 5.245);
test_geometry<bg::model::box<P>, strategy >("box(0 0,2 2)", 4, 5, 4);
// https://svn.boost.org/trac/boost/ticket/6443
{
test_geometry<bg::model::ring<P>, strategy >(
"polygon((0 0, 2 0))", // note that this polygon is very invalid
2, 4, 0, 4);
}
// degenerated hulls
test_geometry<bg::model::multi_point<P>, strategy >(
"multipoint(0 0)",
1, 4, 0, 0);
test_geometry<bg::model::multi_point<P>, strategy >(
"multipoint(0 0, 2 0)",
2, 4, 0, 4);
test_geometry<bg::model::linestring<P>, strategy >(
"linestring(0 0, 2 0)",
2, 4, 0, 4);
test_empty_input<bg::model::linestring<P> >();
test_empty_input<bg::model::ring<P> >();
test_empty_input<bg::model::polygon<P> >();
}
int test_main(int, char* [])
{
//test_all<bg::model::d2::point_xy<int> >();
test_all<bg::model::d2::point_xy<float> >();
test_all<bg::model::d2::point_xy<double> >();
return 0;
}

View File

@@ -0,0 +1,92 @@
// 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 2014, 2015.
// Modifications copyright (c) 2014-2015 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 <cstddef>
#include <iterator>
#include <string>
#include "test_convex_hull.hpp"
#include <boost/geometry/geometries/geometries.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/core/point_order.hpp>
#include <boost/geometry/core/point_type.hpp>
#include <boost/geometry/views/detail/range_type.hpp>
#include <boost/geometry/algorithms/detail/for_each_range.hpp>
#include <boost/geometry/geometries/multi_point.hpp>
#include <boost/geometry/geometries/multi_linestring.hpp>
#include <boost/geometry/geometries/multi_polygon.hpp>
template <typename P>
void test_all()
{
typedef boost::geometry::strategies::convex_hull::cartesian<> strategy;
typedef bg::model::multi_point<P> mp;
typedef bg::model::multi_linestring<bg::model::linestring<P> > ml;
typedef bg::model::multi_polygon<bg::model::polygon<P> > mpoly;
// All points below in upper-points and lower-points
test_geometry<mp, strategy>("MULTIPOINT((0 0),(5 0),(1 1),(4 1))", 0, 5, 4.0);
test_geometry<mp, strategy>("MULTIPOINT((0 1),(5 1),(1 0),(4 0))", 0, 5, 4.0);
// All points in vertical line (this delivers an empty polygon with 3 points
// and closing point for closed)
test_geometry<mp, strategy>("MULTIPOINT((1 0),(5 0),(3 0),(4 0),(2 0))", 0, 4, 0.0);
// One point only
test_geometry<mp, strategy>("MULTIPOINT((1 0))", 0, 4, 0.0);
// Problem of 6019, reproduced by the convex hull robustness test:
test_geometry<mp, strategy>("MULTIPOINT((2 9),(1 3),(9 4),(1 1),(1 0),(7 9),(2 5),(3 7),(3 6),(2 4))",
0, 6, 48.0);
// Ticket 6019:
test_geometry<mp, strategy>("MULTIPOINT((0 53),(0 103),(0 53),(0 3),(0 3),(0 0),(1 0),\
(1 1),(2 1),(2 0),(2 0),(2 0),(3 0),(3 1),(4 1),(4 0),(5 0),(0 3),\
(10 3),(10 2),(10 2),(10 2),(5 2),(5 0),(5 0),(55 0),(105 0))",
0, 4, 5407.5);
// Ticket 6021:
test_geometry<mp, strategy>("multipoint((0 53), (0 103), (1 53))", 3, 4, 25);
test_geometry<mp, strategy>("multipoint((1.1 1.1), (2.5 2.1), (3.1 3.1), (4.9 1.1), (3.1 1.9))", 5, 4, 3.8);
test_geometry<ml, strategy>("multilinestring((2 4, 3 4, 3 5), (4 3,4 4,5 4))", 6, 5, 3.0);
test_geometry<mpoly, strategy>("multipolygon(((1 4,1 6,2 5,3 5,4 6,4 4,1 4)), ((4 2,4 3,6 3,6 2,4 2)))", 12, 7, 14.0);
test_empty_input<mp>();
test_empty_input<ml>();
test_empty_input<mpoly>();
}
int test_main(int, char* [])
{
//test_all<bg::model::d2::point_xy<int> >();
//test_all<bg::model::d2::point_xy<float> >();
test_all<bg::model::d2::point_xy<double> >();
return 0;
}

View File

@@ -0,0 +1,109 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Unit Test
// Copyright (c) 2020 Oracle and/or its affiliates.
// Contributed and/or modified by Vissarion Fisikopoulos, 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)
#include <cstddef>
#include <string>
#include "test_convex_hull.hpp"
#include <boost/geometry/geometries/geometries.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
template <typename CT, typename CTmp>
void test_all()
{
typedef bg::model::d2::point_xy<CT> P;
typedef bg::model::d2::point_xy<CTmp> Pmp;
// from sample polygon, with concavity
auto polygon_wkt0 = "polygon((2.0 1.3, 2.4 1.7, 2.8 1.8, 3.4 1.2, 3.7 1.6,\
3.4 2.0, 4.1 3.0, 5.3 2.6, 5.4 1.2, 4.9 0.8, 2.9 0.7,2.0 1.3))";
test_geometry<bg::model::polygon<P>, robust_cartesian>(
polygon_wkt0, 12, 8, 5.245);
test_geometry<bg::model::polygon<P>, non_robust_cartesian_sbt>(
polygon_wkt0, 12, 8, 5.245);
test_geometry<bg::model::polygon<P>, non_robust_cartesian_fast>(
polygon_wkt0, 12, 8, 5.245);
test_geometry<bg::model::polygon<Pmp>, non_robust_cartesian_sbt>(
polygon_wkt0, 12, 8, 5.245);
// some colinear cases are ok with non robust predicate
auto polygon_wkt1 = "polygon((0.50000000000001621 0.50000000000001243,\
7.3000000000000173 7.3000000000000167,\
24.00000000000005 24.000000000000053,\
24.000000000000068 24.000000000000071,\
0 1,8 4,25 26,26 25,19 11))";
test_geometry<bg::model::polygon<P>, robust_cartesian >(
polygon_wkt1, 9, 7, 137.25);
test_geometry<bg::model::polygon<P>, non_robust_cartesian_sbt >(
polygon_wkt1, 9, 7, 137.25);
test_geometry<bg::model::polygon<P>, non_robust_cartesian_fast >(
polygon_wkt1, 9, 7, 137.25);
test_geometry<bg::model::polygon<Pmp>, non_robust_cartesian_sbt >(
polygon_wkt1, 9, 7, 137.25);
// slightly non-convex result but areas equal
auto polygon_wkt2 = "polygon((27.643564356435643 -21.881188118811881,\
83.366336633663366 15.544554455445542,\
4.0 4.0,\
73.415841584158414 8.8613861386138595,\
27.643564356435643 -21.881188118811881))";
test_geometry<bg::model::polygon<P>, robust_cartesian >(
polygon_wkt2, 5, 4, 1163.5247524752476);
test_geometry<bg::model::polygon<P>, non_robust_cartesian_sbt >(
polygon_wkt2, 5, 5, 1163.5247524752476);
test_geometry<bg::model::polygon<P>, non_robust_cartesian_fast >(
polygon_wkt2, 5, 4, 1163.5247524752476);
test_geometry<bg::model::polygon<Pmp>, non_robust_cartesian_sbt >(
polygon_wkt2, 5, 4, 1163.5247524752476);
// wrong orientation / sign in area
// here non_robust_cartesian_sbt computes wrong result with mp arithmetic
// correct results double checked with CGAL 5.1
auto polygon_wkt3 = "polygon((200.0 49.200000000000003,\
100.0 49.600000000000001,\
-233.33333333333334 50.93333333333333,\
166.66666666666669 49.333333333333336,\
200.0 49.200000000000003))";
test_geometry<bg::model::polygon<P>, robust_cartesian, precise_cartesian >(
polygon_wkt3, 5, 4, 1.4210854715202004e-14);
test_geometry<bg::model::polygon<P>, non_robust_cartesian_sbt, precise_cartesian >(
polygon_wkt3, 5, 4, -1.4210854715202004e-14);
test_geometry<bg::model::polygon<P>, non_robust_cartesian_fast, precise_cartesian >(
polygon_wkt3, 5, 4, 1.4210854715202004e-14);
test_geometry<bg::model::polygon<Pmp>, non_robust_cartesian_sbt >(
polygon_wkt3, 5, 5, 1.69333333333333265e-13);
// missing one point could lead in arbitrary large errors in area
auto polygon_wkt4 = "polygon((0.10000000000000001 0.10000000000000001,\
0.20000000000000001 0.20000000000000004,\
0.79999999999999993 0.80000000000000004,\
1.267650600228229e30 1.2676506002282291e30,\
0.10000000000000001 0.10000000000000001))";
test_geometry<bg::model::polygon<P>, robust_cartesian, precise_cartesian>(
polygon_wkt4, 5, 5, -0.315);
test_geometry<bg::model::polygon<P>, non_robust_cartesian_sbt, precise_cartesian>(
polygon_wkt4, 5, 4, 0);
test_geometry<bg::model::polygon<P>, non_robust_cartesian_fast, precise_cartesian>(
polygon_wkt4, 5, 4, -0.015);
test_geometry<bg::model::polygon<Pmp>, non_robust_cartesian_sbt>(
polygon_wkt4, 5, 5, 3.472078301e+13);
}
int test_main(int, char* [])
{
using boost::multiprecision::cpp_dec_float_50;
test_all<double, cpp_dec_float_50>();
return 0;
}

View File

@@ -0,0 +1,77 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Unit Test
// Copyright (c) 2020 Oracle and/or its affiliates.
// Contributed and/or modified by Vissarion Fisikopoulos, 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)
#include <cstddef>
#include <string>
#include "test_convex_hull.hpp"
#include <boost/geometry/geometries/geometries.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
void test_all()
{
typedef bg::model::point<double, 2, bg::cs::spherical_equatorial<bg::degree> >
SphericalPoint;
typedef bg::model::point<double, 2, bg::cs::geographic<bg::degree> > GeoPoint;
test_geometry_sph_geo
<
bg::model::polygon<SphericalPoint>,
bg::model::polygon<GeoPoint>
>("polygon((0 0,2 1,2 -1,0 0))", 4, 4,
0.00060931217091786914, 24621363089.253811);
test_geometry_sph_geo
<
bg::model::polygon<SphericalPoint>,
bg::model::polygon<GeoPoint>
>("polygon((0 0,1 1,0 1,0 0))", 4, 4,
0.00015229324228191774, 6153921163.326375);
//polygon crossing antimeridian
test_geometry_sph_geo
<
bg::model::polygon<SphericalPoint>,
bg::model::polygon<GeoPoint>
>("polygon((359 0,1 1,1 -1,359 0))", 4, 4,
0.00060931217091786914, 24621363089.253811);
test_geometry_sph_geo
<
bg::model::polygon<SphericalPoint>,
bg::model::polygon<GeoPoint>
>("polygon((1 1, 1 4, 3 4, 3 3, 4 3, 4 4, 5 4, 5 1, 1 1))",
9, 5, 0.003652987070377825, 147615606532.65408);
// calculate convex hull with a non-default spherical side strategy
test_geometry
<
bg::model::polygon<SphericalPoint>,
sphrerical_side_by_cross_track<>
>("polygon((359 0,1 1,1 -1,359 0))", 4, 4,
0.00060931217091786914);
test_empty_input<bg::model::linestring<SphericalPoint>>();
test_empty_input<bg::model::ring<SphericalPoint>>();
test_empty_input<bg::model::polygon<SphericalPoint>>();
test_empty_input<bg::model::linestring<GeoPoint>>();
test_empty_input<bg::model::ring<GeoPoint>>();
test_empty_input<bg::model::polygon<GeoPoint>>();
}
int test_main(int, char* [])
{
test_all();
return 0;
}

View File

@@ -0,0 +1,347 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Unit Test
// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
// This file was modified by Oracle on 2014, 2015.
// Modifications copyright (c) 2014-2015 Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Contributed and/or modified by Menelaos Karavelas, 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)
#ifndef BOOST_GEOMETRY_TEST_CONVEX_HULL_HPP
#define BOOST_GEOMETRY_TEST_CONVEX_HULL_HPP
#include <boost/variant/variant.hpp>
#include <geometry_test_common.hpp>
#include <boost/geometry/algorithms/convex_hull.hpp>
#include <boost/geometry/algorithms/area.hpp>
#include <boost/geometry/algorithms/is_empty.hpp>
#include <boost/geometry/algorithms/num_points.hpp>
#include <boost/geometry/algorithms/perimeter.hpp>
#include <boost/geometry/strategies/strategies.hpp>
#include <boost/geometry/strategies/area/services.hpp>
#include <boost/geometry/strategies/spherical/side_by_cross_track.hpp>
#include <boost/geometry/strategy/cartesian/side_robust.hpp>
#include <boost/geometry/strategy/cartesian/side_non_robust.hpp>
#include <boost/geometry/strategy/cartesian/precise_area.hpp>
#include <boost/geometry/io/wkt/wkt.hpp>
#include <boost/geometry/geometries/polygon.hpp>
struct robust_cartesian : boost::geometry::strategies::detail::cartesian_base
{
static auto side()
{
return boost::geometry::strategy::side::side_robust<>();
}
};
struct non_robust_cartesian_fast : boost::geometry::strategies::detail::cartesian_base
{
static auto side()
{
return boost::geometry::strategy::side::side_non_robust<>();
}
};
struct non_robust_cartesian_sbt : boost::geometry::strategies::detail::cartesian_base
{
static auto side()
{
return boost::geometry::strategy::side::side_by_triangle<>();
}
};
template <typename CalculationType = void>
struct sphrerical_side_by_cross_track : boost::geometry::strategies::detail::spherical_base<void>
{
static auto side()
{
return boost::geometry::strategy::side::side_by_cross_track<>();
}
};
struct precise_cartesian : boost::geometry::strategies::detail::cartesian_base
{
template <typename Geometry>
static auto area(Geometry const&)
{
return boost::geometry::strategy::area::precise_cartesian<>();
}
};
template <typename Geometry, typename Hull, typename AreaStrategy>
void check_convex_hull(Geometry const& geometry, Hull const& hull,
std::size_t /*size_original*/, std::size_t size_hull,
double expected_area, double expected_perimeter,
bool reverse, AreaStrategy area_strategy)
{
std::size_t n = bg::num_points(hull);
BOOST_CHECK_MESSAGE(n == size_hull,
"convex hull: " << bg::wkt(geometry)
<< " -> " << bg::wkt(hull)
<< " type "
<< (typeid(typename bg::coordinate_type<Hull>::type).name())
<< " -> Expected: " << size_hull
<< " detected: " << n);
// We omit this check as it is not important for the hull algorithm
// BOOST_CHECK(bg::num_points(geometry) == size_original);
auto ah = bg::area(hull, area_strategy);
if (reverse)
{
ah = -ah;
}
BOOST_CHECK_CLOSE(ah, expected_area, 0.001);
if ( expected_perimeter >= 0 )
{
auto ph = bg::perimeter(hull);
BOOST_CHECK_CLOSE(ph, expected_perimeter, 0.001);
}
}
namespace resolve_variant {
struct closure_visitor : public boost::static_visitor<bg::closure_selector>
{
template <typename Geometry>
bg::closure_selector operator()(Geometry const&) const
{
return bg::closure<Geometry>::value;
}
};
template <typename Geometry>
inline bg::closure_selector get_closure(Geometry const&)
{
return bg::closure<Geometry>::value;
}
template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
inline bg::closure_selector get_closure(boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& v)
{
return boost::apply_visitor(closure_visitor(), v);
}
} // namespace resolve_variant
template
<
typename Hull,
typename Strategy,
typename AreaStrategy
>
struct test_convex_hull
{
template <typename Geometry>
static void apply(Geometry const& geometry,
std::size_t size_original,
std::size_t size_hull_closed,
double expected_area,
double expected_perimeter,
bool reverse)
{
bool const is_original_closed = resolve_variant::get_closure(geometry) != bg::open;
static bool const is_hull_closed = bg::closure<Hull>::value != bg::open;
// convex_hull_insert() uses the original Geometry as a source of the info
// about the order and closure
std::size_t const size_hull_from_orig = is_original_closed ?
size_hull_closed : size_hull_closed - 1;
std::size_t const size_hull = is_hull_closed ? size_hull_closed :
size_hull_closed - 1;
Hull hull;
// Test version with strategy
bg::clear(hull);
bg::convex_hull(geometry, hull.outer(), Strategy());
check_convex_hull(geometry, hull, size_original, size_hull,
expected_area, expected_perimeter, false, AreaStrategy());
// Test version with output iterator and strategy
bg::clear(hull);
bg::detail::convex_hull::convex_hull_insert(
geometry,
std::back_inserter(hull.outer()), Strategy());
check_convex_hull(geometry, hull, size_original, size_hull_from_orig,
expected_area, expected_perimeter, reverse, AreaStrategy());
}
};
template
<
typename Hull,
typename AreaStrategy
>
struct test_convex_hull<Hull, robust_cartesian, AreaStrategy>
{
template <typename Geometry>
static void apply(Geometry const& geometry,
std::size_t size_original,
std::size_t size_hull_closed,
double expected_area,
double expected_perimeter,
bool reverse)
{
bool const is_original_closed = resolve_variant::get_closure(geometry) != bg::open;
static bool const is_hull_closed = bg::closure<Hull>::value != bg::open;
// convex_hull_insert() uses the original Geometry as a source of the info
// about the order and closure
std::size_t const size_hull_from_orig = is_original_closed ?
size_hull_closed : size_hull_closed - 1;
std::size_t const size_hull = is_hull_closed ? size_hull_closed :
size_hull_closed - 1;
Hull hull;
// Test version with output iterator
bg::detail::convex_hull::convex_hull_insert(geometry,
std::back_inserter(hull.outer()));
check_convex_hull(geometry, hull, size_original, size_hull_from_orig,
expected_area, expected_perimeter, reverse,
AreaStrategy());
// Test version with ring as output
bg::clear(hull);
bg::convex_hull(geometry, hull.outer());
check_convex_hull(geometry, hull, size_original, size_hull, expected_area,
expected_perimeter, false, AreaStrategy());
// Test version with polygon as output
bg::clear(hull);
bg::convex_hull(geometry, hull);
check_convex_hull(geometry, hull, size_original, size_hull, expected_area,
expected_perimeter, false, AreaStrategy());
// Test version with strategy
bg::clear(hull);
bg::convex_hull(geometry, hull.outer(), robust_cartesian());
check_convex_hull(geometry, hull, size_original, size_hull, expected_area,
expected_perimeter, false, AreaStrategy());
// Test version with output iterator and strategy
bg::clear(hull);
bg::detail::convex_hull::convex_hull_insert(geometry,
std::back_inserter(hull.outer()), robust_cartesian());
check_convex_hull(geometry, hull, size_original, size_hull_from_orig,
expected_area, expected_perimeter, reverse, AreaStrategy());
}
};
template
<
typename Geometry,
typename Strategy,
typename AreaStrategy,
bool Clockwise,
bool Closed
>
void test_geometry_order(std::string const& wkt,
std::size_t size_original,
std::size_t size_hull_closed,
double expected_area,
double expected_perimeter = -1.0)
{
typedef bg::model::polygon
<
typename bg::point_type<Geometry>::type,
Clockwise,
Closed
> hull_type;
Geometry geometry;
bg::read_wkt(wkt, geometry);
test_convex_hull<hull_type, Strategy, AreaStrategy>::apply(geometry, size_original,
size_hull_closed, expected_area, expected_perimeter, !Clockwise);
boost::variant<Geometry> v(geometry);
test_convex_hull<hull_type, Strategy, AreaStrategy>::apply(v, size_original,
size_hull_closed, expected_area, expected_perimeter, !Clockwise);
}
template
<
typename Geometry,
typename Strategy,
typename AreaStrategy = typename bg::strategies::area::services::default_strategy
<
Geometry
>::type
>
void test_geometry(std::string const& wkt,
std::size_t size_original,
std::size_t size_hull_closed,
double expected_area,
double expected_perimeter = -1.0)
{
test_geometry_order<Geometry, Strategy, AreaStrategy, true, true>(
wkt, size_original, size_hull_closed, expected_area, expected_perimeter);
test_geometry_order<Geometry, Strategy, AreaStrategy, false, true>(
wkt, size_original, size_hull_closed, expected_area, expected_perimeter);
test_geometry_order<Geometry, Strategy, AreaStrategy, true, false>(
wkt, size_original, size_hull_closed, expected_area, expected_perimeter);
test_geometry_order<Geometry, Strategy, AreaStrategy, false, false>(
wkt, size_original, size_hull_closed, expected_area, expected_perimeter);
}
template <class SGeometry, class GGeometry>
void test_geometry_sph_geo(std::string const& wkt,
std::size_t size_original,
std::size_t size_hull_closed,
double spherical_expected_area,
double geographic_expected_area)
{
typedef boost::geometry::strategies::convex_hull::spherical<> SphericalStrategy;
test_geometry<SGeometry, SphericalStrategy>(wkt, size_original,
size_hull_closed, spherical_expected_area);
typedef boost::geometry::strategies::convex_hull::geographic<> GeoStrategy;
test_geometry<GGeometry, GeoStrategy>(wkt, size_original,
size_hull_closed, geographic_expected_area);
}
template <typename Geometry>
void test_empty_input()
{
Geometry geometry;
bg::model::polygon
<
typename bg::point_type<Geometry>::type
> hull;
bg::convex_hull(geometry, hull);
BOOST_CHECK_MESSAGE(bg::is_empty(hull), "Output convex hull should be empty" );
}
#endif