mirror of
https://github.com/boostorg/geometry.git
synced 2025-05-11 21:44:04 +00:00
[test] Distance test between pointlike areal geometries for geo and sph cs
This commit is contained in:
parent
a5e6ef069c
commit
2de71df58f
@ -348,6 +348,39 @@ struct distance_brute_force
|
||||
}
|
||||
};
|
||||
|
||||
template
|
||||
<
|
||||
typename Point,
|
||||
typename MultiPolygon,
|
||||
typename Strategy
|
||||
>
|
||||
struct distance_brute_force
|
||||
<
|
||||
Point, MultiPolygon, Strategy,
|
||||
point_tag, multi_polygon_tag, false
|
||||
>
|
||||
{
|
||||
typedef typename distance_result
|
||||
<
|
||||
Point, MultiPolygon, Strategy
|
||||
>::type distance_type;
|
||||
|
||||
static inline distance_type apply(Point const& p,
|
||||
MultiPolygon const& mp,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
return detail::distance_brute_force::one_to_many
|
||||
<
|
||||
distance_brute_force
|
||||
<
|
||||
Point,
|
||||
typename boost::range_value<MultiPolygon>::type,
|
||||
Strategy
|
||||
>
|
||||
>::apply(p, boost::begin(mp), boost::end(mp), strategy);
|
||||
}
|
||||
};
|
||||
|
||||
//=======================================================================
|
||||
|
||||
template
|
||||
@ -677,6 +710,45 @@ struct distance_brute_force
|
||||
}
|
||||
};
|
||||
|
||||
template
|
||||
<
|
||||
typename Polygon,
|
||||
typename MultiPoint,
|
||||
typename Strategy
|
||||
>
|
||||
struct distance_brute_force
|
||||
<
|
||||
Polygon, MultiPoint, Strategy,
|
||||
polygon_tag, multi_point_tag, false
|
||||
>
|
||||
{
|
||||
typedef typename distance_result
|
||||
<
|
||||
Polygon, MultiPoint, Strategy
|
||||
>::type distance_type;
|
||||
|
||||
static inline distance_type apply(Polygon const& polygon,
|
||||
MultiPoint const& mp,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
return detail::distance_brute_force::one_to_many
|
||||
<
|
||||
distance_brute_force
|
||||
<
|
||||
MultiPoint,
|
||||
typename std::iterator_traits
|
||||
<
|
||||
segment_iterator<Polygon const>
|
||||
>::value_type,
|
||||
Strategy
|
||||
>
|
||||
>::apply(mp,
|
||||
geometry::segments_begin(polygon),
|
||||
geometry::segments_end(polygon),
|
||||
strategy);
|
||||
}
|
||||
};
|
||||
|
||||
//========================================================================
|
||||
|
||||
template
|
||||
@ -732,16 +804,55 @@ struct distance_brute_force
|
||||
static inline distance_type apply(MultiPoint const& mp,
|
||||
Linear const& l,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
return detail::distance_brute_force::one_to_many
|
||||
<
|
||||
distance_brute_force
|
||||
<
|
||||
MultiPoint,
|
||||
typename std::iterator_traits
|
||||
<
|
||||
segment_iterator<Linear const>
|
||||
>::value_type,
|
||||
Strategy
|
||||
>
|
||||
>::apply(mp,
|
||||
geometry::segments_begin(l),
|
||||
geometry::segments_end(l),
|
||||
strategy);
|
||||
}
|
||||
};
|
||||
|
||||
template
|
||||
<
|
||||
typename MultiPoint,
|
||||
typename MultiPolygon,
|
||||
typename Strategy
|
||||
>
|
||||
struct distance_brute_force
|
||||
<
|
||||
MultiPoint, MultiPolygon, Strategy,
|
||||
multi_point_tag, multi_polygon_tag, false
|
||||
>
|
||||
{
|
||||
typedef typename distance_result
|
||||
<
|
||||
MultiPoint, MultiPolygon, Strategy
|
||||
>::type distance_type;
|
||||
|
||||
static inline distance_type apply(MultiPoint const& mp,
|
||||
MultiPolygon const& mpl,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
return detail::distance_brute_force::one_to_many
|
||||
<
|
||||
distance_brute_force
|
||||
<
|
||||
MultiPoint,
|
||||
typename boost::range_value<Linear>::type,
|
||||
typename boost::range_value<MultiPolygon>::type,
|
||||
Strategy
|
||||
>
|
||||
>::apply(mp, boost::begin(l), boost::end(l), strategy);
|
||||
>::apply(mp, boost::begin(mpl), boost::end(mpl), strategy);
|
||||
}
|
||||
};
|
||||
|
||||
@ -773,6 +884,48 @@ struct distance_brute_force
|
||||
}
|
||||
};
|
||||
|
||||
template
|
||||
<
|
||||
typename MultiPoint,
|
||||
typename Ring,
|
||||
typename Strategy
|
||||
>
|
||||
struct distance_brute_force
|
||||
<
|
||||
MultiPoint, Ring, Strategy,
|
||||
multi_point_tag, ring_tag, false
|
||||
>
|
||||
{
|
||||
typedef typename distance_result
|
||||
<
|
||||
MultiPoint, Ring, Strategy
|
||||
>::type distance_type;
|
||||
|
||||
static inline distance_type apply(MultiPoint const& mp,
|
||||
Ring const& ring,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
|
||||
|
||||
return detail::distance_brute_force::one_to_many
|
||||
<
|
||||
distance_brute_force
|
||||
<
|
||||
MultiPoint,
|
||||
typename std::iterator_traits
|
||||
<
|
||||
segment_iterator<Ring const>
|
||||
>::value_type,
|
||||
Strategy
|
||||
>
|
||||
>::apply(mp,
|
||||
geometry::segments_begin(ring),
|
||||
geometry::segments_end(ring),
|
||||
strategy);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template
|
||||
<
|
||||
typename MultiPoint,
|
||||
|
@ -22,85 +22,172 @@
|
||||
#include <boost/geometry/strategies/strategies.hpp>
|
||||
|
||||
#include "test_distance_geo_common.hpp"
|
||||
#include "test_empty_geometry.hpp"
|
||||
|
||||
typedef bg::cs::geographic<bg::degree> cs_type;
|
||||
typedef bg::model::point<double, 2, cs_type> point_type;
|
||||
typedef bg::model::multi_point<point_type> multi_point_type;
|
||||
typedef bg::model::segment<point_type> segment_type;
|
||||
typedef bg::model::box<point_type> box_type;
|
||||
template
|
||||
<
|
||||
typename Point,
|
||||
typename Strategy_pp,
|
||||
typename Strategy_ps
|
||||
>
|
||||
void test_distance_point_ring(Strategy_pp const& strategy_pp,
|
||||
Strategy_ps const& strategy_ps)
|
||||
{
|
||||
|
||||
namespace services = bg::strategy::distance::services;
|
||||
typedef bg::default_distance_result<point_type>::type return_type;
|
||||
#ifdef BOOST_GEOMETRY_TEST_DEBUG
|
||||
std::cout << std::endl;
|
||||
std::cout << "point/ring distance tests" << std::endl;
|
||||
#endif
|
||||
typedef bg::model::ring<Point> ring_type;
|
||||
typedef test_distance_of_geometries<Point, ring_type> tester;
|
||||
|
||||
typedef bg::srs::spheroid<double> stype;
|
||||
std::string const ring = "POLYGON((10 10,0 20, 15 30, 20 15, 15 10, 10 10))";
|
||||
|
||||
// Strategies for point-point distance
|
||||
|
||||
typedef bg::strategy::distance::andoyer<stype> andoyer_pp;
|
||||
typedef bg::strategy::distance::thomas<stype> thomas_pp;
|
||||
typedef bg::strategy::distance::vincenty<stype> vincenty_pp;
|
||||
|
||||
// Strategies for point-segment distance
|
||||
|
||||
typedef bg::strategy::distance::geographic_cross_track<bg::strategy::andoyer, stype, double>
|
||||
andoyer_ps;
|
||||
|
||||
typedef bg::strategy::distance::geographic_cross_track<bg::strategy::thomas, stype, double>
|
||||
thomas_ps;
|
||||
|
||||
typedef bg::strategy::distance::geographic_cross_track<bg::strategy::vincenty, stype, double>
|
||||
vincenty_ps;
|
||||
|
||||
// Strategies for point-box distance
|
||||
|
||||
typedef bg::strategy::distance::geographic_cross_track_point_box
|
||||
<
|
||||
bg::strategy::andoyer,
|
||||
stype,
|
||||
double
|
||||
> andoyer_pb;
|
||||
|
||||
typedef bg::strategy::distance::geographic_cross_track_point_box
|
||||
<
|
||||
bg::strategy::thomas,
|
||||
stype,
|
||||
double
|
||||
> thomas_pb;
|
||||
|
||||
typedef bg::strategy::distance::geographic_cross_track_point_box
|
||||
<
|
||||
bg::strategy::vincenty,
|
||||
stype,
|
||||
double
|
||||
> vincenty_pb;
|
||||
tester::apply("pr1", "POINT(0 10)", ring,
|
||||
ps_distance<Point>("POINT(0 10)", "SEGMENT(0 20, 10 10)", strategy_ps),
|
||||
strategy_ps, true, true, false);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
||||
template <typename Strategy>
|
||||
inline bg::default_distance_result<point_type>::type
|
||||
pp_distance(std::string const& wkt1,
|
||||
std::string const& wkt2,
|
||||
Strategy const& strategy)
|
||||
template
|
||||
<
|
||||
typename Point,
|
||||
typename Strategy_pp,
|
||||
typename Strategy_ps
|
||||
>
|
||||
void test_distance_multipoint_ring(Strategy_pp const& strategy_pp,
|
||||
Strategy_ps const& strategy_ps)
|
||||
{
|
||||
point_type p1, p2;
|
||||
bg::read_wkt(wkt1, p1);
|
||||
bg::read_wkt(wkt2, p2);
|
||||
return bg::distance(p1, p2, strategy);
|
||||
|
||||
#ifdef BOOST_GEOMETRY_TEST_DEBUG
|
||||
std::cout << std::endl;
|
||||
std::cout << "multipoint/ring distance tests" << std::endl;
|
||||
#endif
|
||||
typedef bg::model::ring<Point> ring_type;
|
||||
typedef bg::model::multi_point<Point> multi_point_type;
|
||||
typedef test_distance_of_geometries<multi_point_type, ring_type> tester;
|
||||
|
||||
std::string const ring = "POLYGON((10 10,0 20, 15 30, 20 15, 15 10, 10 10))";
|
||||
|
||||
tester::apply("pr1", "MULTIPOINT(0 10,10 0,0 0)", ring,
|
||||
ps_distance<Point>("POINT(0 10)", "SEGMENT(0 20, 10 10)", strategy_ps),
|
||||
strategy_ps, true, true, false);
|
||||
}
|
||||
|
||||
template <typename Strategy>
|
||||
inline bg::default_distance_result<point_type>::type
|
||||
ps_distance(std::string const& wkt1,
|
||||
std::string const& wkt2,
|
||||
Strategy const& strategy)
|
||||
|
||||
//===========================================================================
|
||||
|
||||
template
|
||||
<
|
||||
typename Point,
|
||||
typename Strategy_pp,
|
||||
typename Strategy_ps
|
||||
>
|
||||
void test_distance_point_polygon(Strategy_pp const& strategy_pp,
|
||||
Strategy_ps const& strategy_ps)
|
||||
{
|
||||
point_type p;
|
||||
segment_type s;
|
||||
bg::read_wkt(wkt1, p);
|
||||
bg::read_wkt(wkt2, s);
|
||||
return bg::distance(p, s, strategy);
|
||||
|
||||
#ifdef BOOST_GEOMETRY_TEST_DEBUG
|
||||
std::cout << std::endl;
|
||||
std::cout << "point/polygon distance tests" << std::endl;
|
||||
#endif
|
||||
typedef bg::model::polygon<Point> polygon_type;
|
||||
typedef test_distance_of_geometries<Point, polygon_type> tester;
|
||||
|
||||
std::string const polygon = "POLYGON((10 10,0 20, 15 30, 20 15, 15 10, 10 10))";
|
||||
|
||||
tester::apply("pr1", "POINT(0 10)", polygon,
|
||||
ps_distance<Point>("POINT(0 10)", "SEGMENT(0 20, 10 10)", strategy_ps),
|
||||
strategy_ps, true, true, false);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
||||
template
|
||||
<
|
||||
typename Point,
|
||||
typename Strategy_pp,
|
||||
typename Strategy_ps
|
||||
>
|
||||
void test_distance_multipoint_polygon(Strategy_pp const& strategy_pp,
|
||||
Strategy_ps const& strategy_ps)
|
||||
{
|
||||
|
||||
#ifdef BOOST_GEOMETRY_TEST_DEBUG
|
||||
std::cout << std::endl;
|
||||
std::cout << "multipoint/polygon distance tests" << std::endl;
|
||||
#endif
|
||||
typedef bg::model::polygon<Point> polygon_type;
|
||||
typedef bg::model::multi_point<Point> multi_point_type;
|
||||
typedef test_distance_of_geometries<multi_point_type, polygon_type> tester;
|
||||
|
||||
std::string const polygon = "POLYGON((10 10,0 20, 15 30, 20 15, 15 10, 10 10))";
|
||||
|
||||
tester::apply("pr1", "MULTIPOINT(0 10,10 0,0 0)", polygon,
|
||||
ps_distance<Point>("POINT(0 10)", "SEGMENT(0 20, 10 10)", strategy_ps),
|
||||
strategy_ps, true, true, false);
|
||||
}
|
||||
|
||||
|
||||
//===========================================================================
|
||||
|
||||
template
|
||||
<
|
||||
typename Point,
|
||||
typename Strategy_pp,
|
||||
typename Strategy_ps
|
||||
>
|
||||
void test_distance_point_multipolygon(Strategy_pp const& strategy_pp,
|
||||
Strategy_ps const& strategy_ps)
|
||||
{
|
||||
|
||||
#ifdef BOOST_GEOMETRY_TEST_DEBUG
|
||||
std::cout << std::endl;
|
||||
std::cout << "point/multipolygon distance tests" << std::endl;
|
||||
#endif
|
||||
typedef bg::model::polygon<Point> polygon_type;
|
||||
typedef bg::model::multi_polygon<polygon_type> multipolygon_type;
|
||||
typedef test_distance_of_geometries<Point, multipolygon_type> tester;
|
||||
|
||||
std::string const mpoly = "MULTIPOLYGON(((20 20, 20 30, 30 40, 20 20)),\
|
||||
((10 10,0 20, 15 30, 20 15, 15 10, 10 10)))";
|
||||
|
||||
tester::apply("pr1", "POINT(0 10)", mpoly,
|
||||
ps_distance<Point>("POINT(0 10)", "SEGMENT(0 20, 10 10)", strategy_ps),
|
||||
strategy_ps, true, true, false);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
||||
template
|
||||
<
|
||||
typename Point,
|
||||
typename Strategy_pp,
|
||||
typename Strategy_ps
|
||||
>
|
||||
void test_distance_multipoint_multipolygon(Strategy_pp const& strategy_pp,
|
||||
Strategy_ps const& strategy_ps)
|
||||
{
|
||||
|
||||
#ifdef BOOST_GEOMETRY_TEST_DEBUG
|
||||
std::cout << std::endl;
|
||||
std::cout << "point/ring distance tests" << std::endl;
|
||||
#endif
|
||||
typedef bg::model::polygon<Point> polygon_type;
|
||||
typedef bg::model::multi_polygon<polygon_type> multipolygon_type;
|
||||
typedef bg::model::multi_point<Point> multi_point_type;
|
||||
typedef test_distance_of_geometries<multi_point_type, multipolygon_type> tester;
|
||||
|
||||
std::string const mpoly = "MULTIPOLYGON(((20 20, 20 30, 30 40, 20 20)),\
|
||||
((10 10,0 20, 15 30, 20 15, 15 10, 10 10)))";
|
||||
|
||||
tester::apply("pr1", "MULTIPOINT(0 10,10 0,0 0)", mpoly,
|
||||
ps_distance<Point>("POINT(0 10)", "SEGMENT(0 20, 10 10)", strategy_ps),
|
||||
strategy_ps, true, true, false);
|
||||
}
|
||||
|
||||
|
||||
//===========================================================================
|
||||
// Cases for relative location of a point wrt to a box
|
||||
//
|
||||
@ -149,7 +236,13 @@ ps_distance(std::string const& wkt1,
|
||||
// range [-180, 540)
|
||||
//===========================================================================
|
||||
|
||||
template <typename Strategy_pp, typename Strategy_ps, typename Strategy_pb>
|
||||
template
|
||||
<
|
||||
typename Point,
|
||||
typename Strategy_pp,
|
||||
typename Strategy_ps,
|
||||
typename Strategy_pb
|
||||
>
|
||||
void test_distance_point_box(Strategy_pp const& strategy_pp,
|
||||
Strategy_ps const& strategy_ps,
|
||||
Strategy_pb const& strategy_pb)
|
||||
@ -159,93 +252,94 @@ void test_distance_point_box(Strategy_pp const& strategy_pp,
|
||||
std::cout << std::endl;
|
||||
std::cout << "point/box distance tests" << std::endl;
|
||||
#endif
|
||||
typedef test_distance_of_geometries<point_type, box_type> tester;
|
||||
typedef bg::model::box<Point> box_type;
|
||||
typedef test_distance_of_geometries<Point, box_type> tester;
|
||||
|
||||
std::string const box1 = "BOX(10 10,20 20)";
|
||||
|
||||
// case 1
|
||||
tester::apply("pb1-1a", "POINT(5 25)", box1,
|
||||
pp_distance("POINT(5 25)", "POINT(10 20)", strategy_pp),
|
||||
pp_distance<Point>("POINT(5 25)", "POINT(10 20)", strategy_pp),
|
||||
strategy_pb);
|
||||
|
||||
// case 1
|
||||
tester::apply("pb1-1b", "POINT(3 12)", box1,
|
||||
ps_distance("POINT(3 12)", "SEGMENT(10 10,10 20)", strategy_ps),
|
||||
ps_distance<Point>("POINT(3 12)", "SEGMENT(10 10,10 20)", strategy_ps),
|
||||
strategy_pb);
|
||||
|
||||
// case 1
|
||||
tester::apply("pb1-1c", "POINT(3 17)", box1,
|
||||
ps_distance("POINT(3 17)", "SEGMENT(10 10,10 20)", strategy_ps),
|
||||
ps_distance<Point>("POINT(3 17)", "SEGMENT(10 10,10 20)", strategy_ps),
|
||||
strategy_pb);
|
||||
|
||||
// case 1
|
||||
tester::apply("pb1-1d", "POINT(5 4)", box1,
|
||||
pp_distance("POINT(5 4)", "POINT(10 10)", strategy_pp),
|
||||
pp_distance<Point>("POINT(5 4)", "POINT(10 10)", strategy_pp),
|
||||
strategy_pb);
|
||||
|
||||
// case 1
|
||||
tester::apply("pb1-1e", "POINT(-100 20)", box1,
|
||||
pp_distance("POINT(-100 20)", "POINT(10 20)", strategy_pp),
|
||||
pp_distance<Point>("POINT(-100 20)", "POINT(10 20)", strategy_pp),
|
||||
strategy_pb);
|
||||
|
||||
// case 1
|
||||
tester::apply("pb1-1g", "POINT(-100 10)", box1,
|
||||
ps_distance("POINT(-100 10)", "SEGMENT(10 10,10 20)", strategy_ps),
|
||||
ps_distance<Point>("POINT(-100 10)", "SEGMENT(10 10,10 20)", strategy_ps),
|
||||
strategy_pb);
|
||||
|
||||
// case 2
|
||||
tester::apply("pb1-2a", "POINT(31 25)", box1,
|
||||
pp_distance("POINT(31 25)", "POINT(20 20)", strategy_pp),
|
||||
pp_distance<Point>("POINT(31 25)", "POINT(20 20)", strategy_pp),
|
||||
strategy_pb);
|
||||
|
||||
// case 2
|
||||
tester::apply("pb1-2b", "POINT(23 17)", box1,
|
||||
ps_distance("POINT(23 17)", "SEGMENT(20 10,20 20)", strategy_ps),
|
||||
ps_distance<Point>("POINT(23 17)", "SEGMENT(20 10,20 20)", strategy_ps),
|
||||
strategy_pb);
|
||||
|
||||
// case 2
|
||||
tester::apply("pb1-2c", "POINT(29 3)", box1,
|
||||
pp_distance("POINT(29 3)", "POINT(20 10)", strategy_pp),
|
||||
pp_distance<Point>("POINT(29 3)", "POINT(20 10)", strategy_pp),
|
||||
strategy_pb);
|
||||
|
||||
// case 2
|
||||
tester::apply("pb1-2d", "POINT(131 65)", box1,
|
||||
pp_distance("POINT(131 65)", "POINT(20 20)", strategy_pp),
|
||||
pp_distance<Point>("POINT(131 65)", "POINT(20 20)", strategy_pp),
|
||||
strategy_pb);
|
||||
|
||||
// case 2
|
||||
tester::apply("pb1-2e", "POINT(110 10)", box1,
|
||||
ps_distance("POINT(110 10)", "SEGMENT(20 10,20 20)", strategy_ps),
|
||||
ps_distance<Point>("POINT(110 10)", "SEGMENT(20 10,20 20)", strategy_ps),
|
||||
strategy_pb);
|
||||
|
||||
// case 2
|
||||
tester::apply("pb1-2f", "POINT(150 20)", box1,
|
||||
pp_distance("POINT(150 20)", "POINT(20 20)", strategy_pp),
|
||||
pp_distance<Point>("POINT(150 20)", "POINT(20 20)", strategy_pp),
|
||||
strategy_pb);
|
||||
|
||||
// case 3
|
||||
tester::apply("pb1-3a", "POINT(11 25)", box1,
|
||||
pp_distance("POINT(11 25)", "POINT(11 20)", strategy_pp),
|
||||
pp_distance<Point>("POINT(11 25)", "POINT(11 20)", strategy_pp),
|
||||
strategy_pb);
|
||||
|
||||
// case 3
|
||||
tester::apply("pb1-3b", "POINT(15 25)", box1,
|
||||
pp_distance("POINT(15 25)", "POINT(15 20)", strategy_pp),
|
||||
pp_distance<Point>("POINT(15 25)", "POINT(15 20)", strategy_pp),
|
||||
strategy_pb);
|
||||
|
||||
// case 3
|
||||
tester::apply("pb1-3c", "POINT(18 25)", box1,
|
||||
pp_distance("POINT(18 25)", "POINT(18 20)", strategy_pp),
|
||||
pp_distance<Point>("POINT(18 25)", "POINT(18 20)", strategy_pp),
|
||||
strategy_pb);
|
||||
|
||||
// case 4
|
||||
tester::apply("pb1-4a", "POINT(13 4)", box1,
|
||||
pp_distance("POINT(13 4)", "POINT(13 10)", strategy_pp),
|
||||
pp_distance<Point>("POINT(13 4)", "POINT(13 10)", strategy_pp),
|
||||
strategy_pb);
|
||||
|
||||
// case 4
|
||||
tester::apply("pb1-4b", "POINT(19 4)", box1,
|
||||
pp_distance("POINT(19 4)", "POINT(19 10)", strategy_pp),
|
||||
pp_distance<Point>("POINT(19 4)", "POINT(19 10)", strategy_pp),
|
||||
strategy_pb);
|
||||
|
||||
// case 5
|
||||
@ -253,12 +347,12 @@ void test_distance_point_box(Strategy_pp const& strategy_pp,
|
||||
|
||||
// case A
|
||||
tester::apply("pb1-A", "POINT(10 28)", box1,
|
||||
pp_distance("POINT(10 28)", "POINT(10 20)", strategy_pp),
|
||||
pp_distance<Point>("POINT(10 28)", "POINT(10 20)", strategy_pp),
|
||||
strategy_pb);
|
||||
|
||||
// case B
|
||||
tester::apply("pb1-B", "POINT(20 28)", box1,
|
||||
pp_distance("POINT(20 28)", "POINT(20 20)", strategy_pp),
|
||||
pp_distance<Point>("POINT(20 28)", "POINT(20 20)", strategy_pp),
|
||||
strategy_pb);
|
||||
|
||||
|
||||
@ -276,12 +370,12 @@ void test_distance_point_box(Strategy_pp const& strategy_pp,
|
||||
|
||||
// case G
|
||||
tester::apply("pb1-G", "POINT(10 -40)", box1,
|
||||
pp_distance("POINT(10 -40)", "POINT(10 10)", strategy_pp),
|
||||
pp_distance<Point>("POINT(10 -40)", "POINT(10 10)", strategy_pp),
|
||||
strategy_pb);
|
||||
|
||||
// case H
|
||||
tester::apply("pb1-H", "POINT(20 -50)", box1,
|
||||
pp_distance("POINT(20 -50)", "POINT(20 10)", strategy_pp),
|
||||
pp_distance<Point>("POINT(20 -50)", "POINT(20 10)", strategy_pp),
|
||||
strategy_pb);
|
||||
|
||||
// case a
|
||||
@ -298,22 +392,22 @@ void test_distance_point_box(Strategy_pp const& strategy_pp,
|
||||
|
||||
// case 1 - point is closer to western meridian
|
||||
tester::apply("pb2-1a", "POINT(160 0)", box2,
|
||||
ps_distance("POINT(160 0)", "SEGMENT(170 -60,170 80)", strategy_ps),
|
||||
ps_distance<Point>("POINT(160 0)", "SEGMENT(170 -60,170 80)", strategy_ps),
|
||||
strategy_pb);
|
||||
|
||||
// case 1 - point is closer to eastern meridian
|
||||
tester::apply("pb2-1b", "POINT(50 0)", box2,
|
||||
ps_distance("POINT(50 0)", "SEGMENT(40 -60,40 80)", strategy_ps),
|
||||
ps_distance<Point>("POINT(50 0)", "SEGMENT(40 -60,40 80)", strategy_ps),
|
||||
strategy_pb);
|
||||
|
||||
// case 3 - equivalent point POINT(390 85) is above the box
|
||||
tester::apply("pb2-3", "POINT(30 85)", box2,
|
||||
pp_distance("POINT(30 85)", "POINT(30 80)", strategy_pp),
|
||||
pp_distance<Point>("POINT(30 85)", "POINT(30 80)", strategy_pp),
|
||||
strategy_pb);
|
||||
|
||||
// case 4 - equivalent point POINT(390 -75) is below the box
|
||||
tester::apply("pb2-4", "POINT(30 -75)", box2,
|
||||
pp_distance("POINT(30 -75)", "POINT(30 -60)", strategy_pp),
|
||||
pp_distance<Point>("POINT(30 -75)", "POINT(30 -60)", strategy_pp),
|
||||
strategy_pb);
|
||||
|
||||
// case 5 - equivalent point POINT(390 0) is inside box
|
||||
@ -324,27 +418,27 @@ void test_distance_point_box(Strategy_pp const& strategy_pp,
|
||||
|
||||
// case 1 - point is closer to western meridian
|
||||
tester::apply("pb3-1a", "POINT(-170 10)", box3,
|
||||
ps_distance("POINT(-170 10)", "SEGMENT(-150 -50,-150 70)", strategy_ps),
|
||||
ps_distance<Point>("POINT(-170 10)", "SEGMENT(-150 -50,-150 70)", strategy_ps),
|
||||
strategy_pb);
|
||||
|
||||
// case 2 - point is closer to eastern meridian
|
||||
tester::apply("pb3-2a", "POINT(5 10)", box3,
|
||||
ps_distance("POINT(5 10)", "SEGMENT(-40 -50,-40 70)", strategy_ps),
|
||||
ps_distance<Point>("POINT(5 10)", "SEGMENT(-40 -50,-40 70)", strategy_ps),
|
||||
strategy_pb);
|
||||
|
||||
// case 2 - point is closer to western meridian
|
||||
tester::apply("pb3-2a", "POINT(160 10)", box3,
|
||||
ps_distance("POINT(160 10)", "SEGMENT(-150 -50,-150 70)", strategy_ps),
|
||||
ps_distance<Point>("POINT(160 10)", "SEGMENT(-150 -50,-150 70)", strategy_ps),
|
||||
strategy_pb);
|
||||
|
||||
// case 2 - point is at equal distance from eastern and western meridian
|
||||
tester::apply("pb3-2c1", "POINT(85 20)", box3,
|
||||
ps_distance("POINT(85 20)", "SEGMENT(-150 -50,-150 70)", strategy_ps),
|
||||
ps_distance<Point>("POINT(85 20)", "SEGMENT(-150 -50,-150 70)", strategy_ps),
|
||||
strategy_pb);
|
||||
|
||||
// case 2 - point is at equal distance from eastern and western meridian
|
||||
tester::apply("pb3-2c2", "POINT(85 20)", box3,
|
||||
ps_distance("POINT(85 20)", "SEGMENT(-40 -50,-40 70)", strategy_ps),
|
||||
ps_distance<Point>("POINT(85 20)", "SEGMENT(-40 -50,-40 70)", strategy_ps),
|
||||
strategy_pb);
|
||||
|
||||
// box that is symmetric wrt the prime meridian
|
||||
@ -352,75 +446,69 @@ void test_distance_point_box(Strategy_pp const& strategy_pp,
|
||||
|
||||
// case 1 - point is closer to western meridian
|
||||
tester::apply("pb4-1a", "POINT(-100 10)", box4,
|
||||
ps_distance("POINT(-100 10)", "SEGMENT(-75 -45,-75 65)", strategy_ps),
|
||||
ps_distance<Point>("POINT(-100 10)", "SEGMENT(-75 -45,-75 65)", strategy_ps),
|
||||
strategy_pb);
|
||||
|
||||
// case 2 - point is closer to eastern meridian
|
||||
tester::apply("pb4-2a", "POINT(90 15)", box4,
|
||||
ps_distance("POINT(90 15)", "SEGMENT(75 -45,75 65)", strategy_ps),
|
||||
ps_distance<Point>("POINT(90 15)", "SEGMENT(75 -45,75 65)", strategy_ps),
|
||||
strategy_pb);
|
||||
|
||||
// case 2 - point is at equal distance from eastern and western meridian
|
||||
tester::apply("pb4-2c1", "POINT(-180 20)", box4,
|
||||
ps_distance("POINT(-180 20)", "SEGMENT(-75 -45,-75 65)", strategy_ps),
|
||||
ps_distance<Point>("POINT(-180 20)", "SEGMENT(-75 -45,-75 65)", strategy_ps),
|
||||
strategy_pb);
|
||||
|
||||
// case 2 - point is at equal distance from eastern and western meridian
|
||||
tester::apply("pb4-2c2", "POINT(-180 20)", box4,
|
||||
ps_distance("POINT(-180 20)", "SEGMENT(75 -45,75 65)", strategy_ps),
|
||||
ps_distance<Point>("POINT(-180 20)", "SEGMENT(75 -45,75 65)", strategy_ps),
|
||||
strategy_pb);
|
||||
}
|
||||
|
||||
template <typename Strategy_pp, typename Strategy_ps, typename Strategy_pb>
|
||||
void test_distance_point_deg_box(Strategy_pp const& strategy_pp,
|
||||
Strategy_ps const& strategy_ps,
|
||||
Strategy_pb const& strategy_pb)
|
||||
{
|
||||
|
||||
#ifdef BOOST_GEOMETRY_TEST_DEBUG
|
||||
std::cout << std::endl;
|
||||
std::cout << "point/box distance tests" << std::endl;
|
||||
#endif
|
||||
typedef test_distance_of_geometries<point_type, box_type> tester;
|
||||
|
||||
//box degenerates to a meridian segment
|
||||
std::string const box1 = "BOX(0 10,0 20)";
|
||||
std::string const boxdeg1 = "BOX(0 10,0 20)";
|
||||
|
||||
tester::apply("pbd1", "POINT(1 10)", box1,
|
||||
ps_distance("POINT(1 10)", "SEGMENT(0 10, 0 20)", strategy_ps),
|
||||
tester::apply("pbd1", "POINT(1 10)", boxdeg1,
|
||||
ps_distance<Point>("POINT(1 10)", "SEGMENT(0 10, 0 20)", strategy_ps),
|
||||
strategy_pb);
|
||||
tester::apply("pbd2", "POINT(1 5)", box1,
|
||||
ps_distance("POINT(1 5)", "SEGMENT(0 10, 0 20)", strategy_ps),
|
||||
tester::apply("pbd2", "POINT(1 5)", boxdeg1,
|
||||
ps_distance<Point>("POINT(1 5)", "SEGMENT(0 10, 0 20)", strategy_ps),
|
||||
strategy_pb);
|
||||
tester::apply("pbd3", "POINT(1 15)", box1,
|
||||
ps_distance("POINT(1 15)", "SEGMENT(0 10, 0 20)", strategy_ps),
|
||||
tester::apply("pbd3", "POINT(1 15)", boxdeg1,
|
||||
ps_distance<Point>("POINT(1 15)", "SEGMENT(0 10, 0 20)", strategy_ps),
|
||||
strategy_pb);
|
||||
tester::apply("pbd4", "POINT(1 25)", box1,
|
||||
ps_distance("POINT(1 25)", "SEGMENT(0 10, 0 20)", strategy_ps),
|
||||
tester::apply("pbd4", "POINT(1 25)", boxdeg1,
|
||||
ps_distance<Point>("POINT(1 25)", "SEGMENT(0 10, 0 20)", strategy_ps),
|
||||
strategy_pb);
|
||||
|
||||
//box degenerates to a horizontal line; that is not a geodesic segment
|
||||
std::string const box2 = "BOX(10 10,20 10)";
|
||||
std::string const boxdeg2 = "BOX(10 10,20 10)";
|
||||
|
||||
tester::apply("pbd5", "POINT(15 15)", box2,
|
||||
pp_distance("POINT(15 15)", "POINT(15 10)", strategy_pp),
|
||||
tester::apply("pbd5", "POINT(15 15)", boxdeg2,
|
||||
pp_distance<Point>("POINT(15 15)", "POINT(15 10)", strategy_pp),
|
||||
strategy_pb);
|
||||
tester::apply("pbd6", "POINT(5 15)", box2,
|
||||
pp_distance("POINT(5 15)", "POINT(10 10)", strategy_pp),
|
||||
tester::apply("pbd6", "POINT(5 15)", boxdeg2,
|
||||
pp_distance<Point>("POINT(5 15)", "POINT(10 10)", strategy_pp),
|
||||
strategy_pb);
|
||||
tester::apply("pbd7", "POINT(25 15)", box2,
|
||||
pp_distance("POINT(25 15)", "POINT(20 10)", strategy_pp),
|
||||
tester::apply("pbd7", "POINT(25 15)", boxdeg2,
|
||||
pp_distance<Point>("POINT(25 15)", "POINT(20 10)", strategy_pp),
|
||||
strategy_pb);
|
||||
|
||||
//box degenerates to a point
|
||||
std::string const box3 = "BOX(0 10,0 10)";
|
||||
std::string const boxdeg3 = "BOX(0 10,0 10)";
|
||||
|
||||
tester::apply("pbd8", "POINT(1 11)", box3,
|
||||
pp_distance("POINT(1 11)", "POINT(0 10)", strategy_pp),
|
||||
tester::apply("pbd8", "POINT(1 11)", boxdeg3,
|
||||
pp_distance<Point>("POINT(1 11)", "POINT(0 10)", strategy_pp),
|
||||
strategy_pb);
|
||||
}
|
||||
|
||||
template <typename Strategy_pp, typename Strategy_ps, typename Strategy_pb>
|
||||
template
|
||||
<
|
||||
typename Point,
|
||||
typename Strategy_pp,
|
||||
typename Strategy_ps,
|
||||
typename Strategy_pb
|
||||
>
|
||||
void test_distance_multipoint_box(Strategy_pp const& strategy_pp,
|
||||
Strategy_ps const& strategy_ps,
|
||||
Strategy_pb const& strategy_pb)
|
||||
@ -430,16 +518,18 @@ void test_distance_multipoint_box(Strategy_pp const& strategy_pp,
|
||||
std::cout << std::endl;
|
||||
std::cout << "multipoint/box distance tests" << std::endl;
|
||||
#endif
|
||||
typedef bg::model::box<Point> box_type;
|
||||
typedef bg::model::multi_point<Point> multi_point_type;
|
||||
typedef test_distance_of_geometries<multi_point_type, box_type> tester;
|
||||
|
||||
std::string const box1 = "BOX(10 10,20 20)";
|
||||
|
||||
tester::apply("mpb1-1a", "MULTIPOINT(5 25,25 26)", box1,
|
||||
pp_distance("POINT(5 25)", "POINT(10 20)", strategy_pp),
|
||||
pp_distance<Point>("POINT(5 25)", "POINT(10 20)", strategy_pp),
|
||||
strategy_pb, true, false, false);
|
||||
|
||||
tester::apply("mpb1-2e", "MULTIPOINT(110 10,110 9,110 0)", box1,
|
||||
ps_distance("POINT(110 10)", "SEGMENT(20 10,20 20)", strategy_ps),
|
||||
ps_distance<Point>("POINT(110 10)", "SEGMENT(20 10,20 20)", strategy_ps),
|
||||
strategy_pb, true, false, false);
|
||||
}
|
||||
|
||||
@ -447,17 +537,41 @@ void test_distance_multipoint_box(Strategy_pp const& strategy_pp,
|
||||
//===========================================================================
|
||||
//===========================================================================
|
||||
|
||||
template
|
||||
<
|
||||
typename Point,
|
||||
typename Strategy_pp,
|
||||
typename Strategy_ps,
|
||||
typename Strategy_pb
|
||||
>
|
||||
void test_all_pl_ar(Strategy_pp pp_strategy,
|
||||
Strategy_ps ps_strategy,
|
||||
Strategy_pb pb_strategy)
|
||||
{
|
||||
test_distance_point_ring<Point>(pp_strategy, ps_strategy);
|
||||
test_distance_multipoint_ring<Point>(pp_strategy, ps_strategy);
|
||||
|
||||
test_distance_point_polygon<Point>(pp_strategy, ps_strategy);
|
||||
test_distance_multipoint_polygon<Point>(pp_strategy, ps_strategy);
|
||||
|
||||
test_distance_point_multipolygon<Point>(pp_strategy, ps_strategy);
|
||||
test_distance_multipoint_multipolygon<Point>(pp_strategy, ps_strategy);
|
||||
|
||||
test_distance_point_box<Point>(pp_strategy, ps_strategy, pb_strategy);
|
||||
test_distance_multipoint_box<Point>(pp_strategy, ps_strategy, pb_strategy);
|
||||
|
||||
test_more_empty_input_pointlike_areal<Point>(ps_strategy);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( test_all_pointlike_areal )
|
||||
{
|
||||
test_distance_point_box(vincenty_pp(), vincenty_ps(), vincenty_pb());
|
||||
test_distance_point_box(thomas_pp(), thomas_ps(), thomas_pb());
|
||||
test_distance_point_box(andoyer_pp(), andoyer_ps(), andoyer_pb());
|
||||
typedef bg::model::point<double, 2, bg::cs::spherical_equatorial<bg::degree> >
|
||||
sph_point;
|
||||
test_all_pl_ar<sph_point>(spherical_pp(), spherical_ps(), spherical_pb());
|
||||
|
||||
test_distance_point_deg_box(vincenty_pp(), vincenty_ps(), vincenty_pb());
|
||||
test_distance_point_deg_box(thomas_pp(), thomas_ps(), thomas_pb());
|
||||
test_distance_point_deg_box(andoyer_pp(), andoyer_ps(), andoyer_pb());
|
||||
typedef bg::model::point<double, 2, bg::cs::geographic<bg::degree> > geo_point;
|
||||
|
||||
test_distance_multipoint_box(vincenty_pp(), vincenty_ps(), vincenty_pb());
|
||||
test_distance_multipoint_box(thomas_pp(), thomas_ps(), thomas_pb());
|
||||
test_distance_multipoint_box(andoyer_pp(), andoyer_ps(), andoyer_pb());
|
||||
test_all_pl_ar<geo_point>(vincenty_pp(), vincenty_ps(), vincenty_pb());
|
||||
test_all_pl_ar<geo_point>(thomas_pp(), thomas_ps(), thomas_pb());
|
||||
test_all_pl_ar<geo_point>(andoyer_pp(), andoyer_ps(), andoyer_pb());
|
||||
}
|
||||
|
@ -71,6 +71,34 @@ typedef bg::strategy::distance::geographic_cross_track<bg::strategy::thomas, sty
|
||||
typedef bg::strategy::distance::geographic_cross_track<bg::strategy::vincenty, stype, double>
|
||||
vincenty_ps;
|
||||
|
||||
// Spherical strategy for point-box distance
|
||||
|
||||
typedef bg::strategy::distance::cross_track_point_box<> spherical_pb;
|
||||
|
||||
// Geo strategies for point-box distance
|
||||
|
||||
typedef bg::strategy::distance::geographic_cross_track_point_box
|
||||
<
|
||||
bg::strategy::andoyer,
|
||||
stype,
|
||||
double
|
||||
> andoyer_pb;
|
||||
|
||||
typedef bg::strategy::distance::geographic_cross_track_point_box
|
||||
<
|
||||
bg::strategy::thomas,
|
||||
stype,
|
||||
double
|
||||
> thomas_pb;
|
||||
|
||||
typedef bg::strategy::distance::geographic_cross_track_point_box
|
||||
<
|
||||
bg::strategy::vincenty,
|
||||
stype,
|
||||
double
|
||||
> vincenty_pb;
|
||||
|
||||
|
||||
//===========================================================================
|
||||
|
||||
template <typename Point, typename Strategy>
|
||||
|
@ -140,4 +140,39 @@ void test_more_empty_input_linear_areal(Strategy const& strategy)
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename Point, typename Strategy>
|
||||
void test_more_empty_input_pointlike_areal(Strategy const& strategy)
|
||||
{
|
||||
#ifdef BOOST_GEOMETRY_TEST_DEBUG
|
||||
std::cout << std::endl;
|
||||
std::cout << "testing on empty inputs... " << std::flush;
|
||||
#endif
|
||||
bg::model::multi_point<Point> multipoint_empty;
|
||||
|
||||
bg::model::polygon<Point> polygon_empty;
|
||||
bg::model::multi_polygon<bg::model::polygon<Point> > multipolygon_empty;
|
||||
|
||||
Point point = from_wkt<Point>("POINT(0 0)");
|
||||
bg::model::polygon<Point> polygon =
|
||||
from_wkt<bg::model::polygon<Point> >("POLYGON((0 0,1 0,1 1,0 1,0 0))");
|
||||
|
||||
// 1st geometry is empty
|
||||
test_empty_input(multipoint_empty, polygon, strategy);
|
||||
test_empty_input(polygon_empty, point, strategy);
|
||||
test_empty_input(multipolygon_empty, point, strategy);
|
||||
|
||||
// 2nd geometry is empty
|
||||
test_empty_input(point, polygon_empty, strategy);
|
||||
test_empty_input(point, multipolygon_empty, strategy);
|
||||
test_empty_input(polygon, multipoint_empty, strategy);
|
||||
|
||||
// both geometries are empty
|
||||
test_empty_input(multipoint_empty, polygon_empty, strategy);
|
||||
test_empty_input(multipoint_empty, multipolygon_empty, strategy);
|
||||
|
||||
#ifdef BOOST_GEOMETRY_TEST_DEBUG
|
||||
std::cout << "done!" << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // BOOST_GEOMETRY_TEST_EMPTY_GEOMETRY_HPP
|
||||
|
Loading…
x
Reference in New Issue
Block a user