mirror of
https://github.com/boostorg/geometry.git
synced 2025-05-11 21:44:04 +00:00
[test] Distance test between linear areal geometries for geo and sph cs
This commit is contained in:
parent
b2242b34c0
commit
a5e6ef069c
@ -146,7 +146,6 @@ struct distance_brute_force
|
||||
: not_implemented<Geometry1, Geometry2>
|
||||
{};
|
||||
|
||||
|
||||
template
|
||||
<
|
||||
typename Geometry1,
|
||||
@ -169,6 +168,7 @@ struct distance_brute_force<Geometry1, Geometry2, Strategy, Tag1, Tag2, true>
|
||||
}
|
||||
};
|
||||
|
||||
//===================================================================
|
||||
|
||||
template
|
||||
<
|
||||
@ -197,90 +197,6 @@ struct distance_brute_force
|
||||
> : detail::distance_brute_force::distance_from_bg
|
||||
{};
|
||||
|
||||
|
||||
template
|
||||
<
|
||||
typename Point,
|
||||
typename Box,
|
||||
typename Strategy
|
||||
>
|
||||
struct distance_brute_force
|
||||
<
|
||||
Point, Box, Strategy,
|
||||
point_tag, box_tag, false
|
||||
> : detail::distance_brute_force::distance_from_bg
|
||||
{};
|
||||
|
||||
template
|
||||
<
|
||||
typename Box1,
|
||||
typename Box2,
|
||||
typename Strategy
|
||||
>
|
||||
struct distance_brute_force
|
||||
<
|
||||
Box1, Box2, Strategy,
|
||||
box_tag, box_tag, false
|
||||
> : detail::distance_brute_force::distance_from_bg
|
||||
{};
|
||||
|
||||
template
|
||||
<
|
||||
typename Segment,
|
||||
typename Box,
|
||||
typename Strategy
|
||||
>
|
||||
struct distance_brute_force
|
||||
<
|
||||
Segment, Box, Strategy,
|
||||
segment_tag, box_tag, false
|
||||
> : detail::distance_brute_force::distance_from_bg
|
||||
{};
|
||||
|
||||
template
|
||||
<
|
||||
typename Segment1,
|
||||
typename Segment2,
|
||||
typename Strategy
|
||||
>
|
||||
struct distance_brute_force
|
||||
<
|
||||
Segment1, Segment2, Strategy,
|
||||
segment_tag, segment_tag, false
|
||||
> : detail::distance_brute_force::distance_from_bg
|
||||
{};
|
||||
|
||||
template
|
||||
<
|
||||
typename Linear,
|
||||
typename Box,
|
||||
typename Strategy
|
||||
>
|
||||
struct distance_brute_force
|
||||
<
|
||||
Linear, Box, Strategy,
|
||||
linear_tag, box_tag, false
|
||||
>
|
||||
{
|
||||
typedef typename distance_result
|
||||
<
|
||||
Linear, Box, Strategy
|
||||
>::type distance_type;
|
||||
|
||||
static inline distance_type apply(Linear const& linear,
|
||||
Box const& box,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
return detail::distance_brute_force::one_to_many
|
||||
<
|
||||
detail::distance_brute_force::distance_from_bg
|
||||
>::apply(box,
|
||||
geometry::segments_begin(linear),
|
||||
geometry::segments_end(linear),
|
||||
strategy);
|
||||
}
|
||||
};
|
||||
|
||||
template
|
||||
<
|
||||
typename Point,
|
||||
@ -312,6 +228,97 @@ struct distance_brute_force
|
||||
}
|
||||
};
|
||||
|
||||
template
|
||||
<
|
||||
typename Point,
|
||||
typename Ring,
|
||||
typename Strategy
|
||||
>
|
||||
struct distance_brute_force
|
||||
<
|
||||
Point, Ring, Strategy,
|
||||
point_tag, ring_tag, false
|
||||
>
|
||||
{
|
||||
typedef typename distance_result
|
||||
<
|
||||
Point, Ring, Strategy
|
||||
>::type distance_type;
|
||||
|
||||
static inline distance_type apply(Point const& point,
|
||||
Ring const& ring,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
return detail::distance_brute_force::one_to_many
|
||||
<
|
||||
distance_brute_force
|
||||
<
|
||||
Point,
|
||||
typename std::iterator_traits
|
||||
<
|
||||
segment_iterator<Ring const>
|
||||
>::value_type,
|
||||
Strategy
|
||||
>
|
||||
>::apply(point,
|
||||
geometry::segments_begin(ring),
|
||||
geometry::segments_end(ring),
|
||||
strategy);
|
||||
}
|
||||
};
|
||||
|
||||
//TODO iterate over exterior rings
|
||||
template
|
||||
<
|
||||
typename Point,
|
||||
typename Polygon,
|
||||
typename Strategy
|
||||
>
|
||||
struct distance_brute_force
|
||||
<
|
||||
Point, Polygon, Strategy,
|
||||
point_tag, polygon_tag, false
|
||||
>
|
||||
{
|
||||
typedef typename distance_result
|
||||
<
|
||||
Point, Polygon, Strategy
|
||||
>::type distance_type;
|
||||
|
||||
static inline distance_type apply(Point const& point,
|
||||
Polygon const& polygon,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
return detail::distance_brute_force::one_to_many
|
||||
<
|
||||
distance_brute_force
|
||||
<
|
||||
Point,
|
||||
typename std::iterator_traits
|
||||
<
|
||||
segment_iterator<Polygon const>
|
||||
>::value_type,
|
||||
Strategy
|
||||
>
|
||||
>::apply(point,
|
||||
geometry::segments_begin(polygon),
|
||||
geometry::segments_end(polygon),
|
||||
strategy);
|
||||
}
|
||||
};
|
||||
|
||||
template
|
||||
<
|
||||
typename Point,
|
||||
typename Box,
|
||||
typename Strategy
|
||||
>
|
||||
struct distance_brute_force
|
||||
<
|
||||
Point, Box, Strategy,
|
||||
point_tag, box_tag, false
|
||||
> : detail::distance_brute_force::distance_from_bg
|
||||
{};
|
||||
|
||||
template
|
||||
<
|
||||
@ -341,165 +348,7 @@ struct distance_brute_force
|
||||
}
|
||||
};
|
||||
|
||||
template
|
||||
<
|
||||
typename MultiPoint1,
|
||||
typename MultiPoint2,
|
||||
typename Strategy
|
||||
>
|
||||
struct distance_brute_force
|
||||
<
|
||||
MultiPoint1, MultiPoint2, Strategy,
|
||||
multi_point_tag, multi_point_tag, false
|
||||
>
|
||||
{
|
||||
typedef typename distance_result
|
||||
<
|
||||
MultiPoint1, MultiPoint2, Strategy
|
||||
>::type distance_type;
|
||||
|
||||
static inline distance_type apply(MultiPoint1 const& mp1,
|
||||
MultiPoint2 const& mp2,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
return detail::distance_brute_force::one_to_many
|
||||
<
|
||||
distance_brute_force
|
||||
<
|
||||
MultiPoint1,
|
||||
typename boost::range_value<MultiPoint2>::type,
|
||||
Strategy
|
||||
>
|
||||
>::apply(mp1, boost::begin(mp2), boost::end(mp2), strategy);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template
|
||||
<
|
||||
typename MultiPoint,
|
||||
typename Linear,
|
||||
typename Strategy
|
||||
>
|
||||
struct distance_brute_force
|
||||
<
|
||||
MultiPoint, Linear, Strategy,
|
||||
multi_point_tag, linear_tag, false
|
||||
>
|
||||
{
|
||||
typedef typename distance_result
|
||||
<
|
||||
MultiPoint, Linear, Strategy
|
||||
>::type distance_type;
|
||||
|
||||
static inline distance_type apply(MultiPoint const& mp,
|
||||
Linear const& linear,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
return detail::distance_brute_force::one_to_many
|
||||
<
|
||||
distance_brute_force
|
||||
<
|
||||
Linear,
|
||||
typename boost::range_value<MultiPoint>::type,
|
||||
Strategy
|
||||
>
|
||||
>::apply(linear, boost::begin(mp), boost::end(mp), strategy);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template
|
||||
<
|
||||
typename Linear,
|
||||
typename MultiPoint,
|
||||
typename Strategy
|
||||
>
|
||||
struct distance_brute_force
|
||||
<
|
||||
Linear, MultiPoint, Strategy,
|
||||
linear_tag, multi_point_tag, false
|
||||
>
|
||||
{
|
||||
typedef typename distance_result
|
||||
<
|
||||
Linear, MultiPoint, Strategy
|
||||
>::type distance_type;
|
||||
|
||||
static inline distance_type apply(Linear const& linear,
|
||||
MultiPoint const& multipoint,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
return distance_brute_force
|
||||
<
|
||||
MultiPoint, Linear, Strategy,
|
||||
multi_point_tag, linear_tag, false
|
||||
>::apply(multipoint, linear, strategy);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template
|
||||
<
|
||||
typename MultiPoint,
|
||||
typename Segment,
|
||||
typename Strategy
|
||||
>
|
||||
struct distance_brute_force
|
||||
<
|
||||
MultiPoint, Segment, Strategy,
|
||||
multi_point_tag, segment_tag, false
|
||||
>
|
||||
{
|
||||
typedef typename distance_result
|
||||
<
|
||||
MultiPoint, Segment, Strategy
|
||||
>::type distance_type;
|
||||
|
||||
static inline distance_type apply(MultiPoint const& mp,
|
||||
Segment const& segment,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
return detail::distance_brute_force::one_to_many
|
||||
<
|
||||
detail::distance_brute_force::distance_from_bg
|
||||
>::apply(segment, boost::begin(mp), boost::end(mp), strategy);
|
||||
}
|
||||
};
|
||||
|
||||
template
|
||||
<
|
||||
typename MultiPoint,
|
||||
typename Box,
|
||||
typename Strategy
|
||||
>
|
||||
struct distance_brute_force
|
||||
<
|
||||
MultiPoint, Box, Strategy,
|
||||
multi_point_tag, box_tag, false
|
||||
>
|
||||
{
|
||||
typedef typename distance_result
|
||||
<
|
||||
MultiPoint, Box, Strategy
|
||||
>::type distance_type;
|
||||
|
||||
static inline distance_type apply(MultiPoint const& mp,
|
||||
Box const& box,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
return detail::distance_brute_force::one_to_many
|
||||
<
|
||||
distance_brute_force
|
||||
<
|
||||
Box,
|
||||
typename boost::range_value<MultiPoint>::type,
|
||||
Strategy
|
||||
>
|
||||
>::apply(box, boost::begin(mp), boost::end(mp), strategy);
|
||||
}
|
||||
};
|
||||
|
||||
//=======================================================================
|
||||
|
||||
template
|
||||
<
|
||||
@ -572,6 +421,508 @@ struct distance_brute_force
|
||||
}
|
||||
};
|
||||
|
||||
template
|
||||
<
|
||||
typename Linear,
|
||||
typename Ring,
|
||||
typename Strategy
|
||||
>
|
||||
struct distance_brute_force
|
||||
<
|
||||
Linear, Ring, Strategy,
|
||||
linear_tag, ring_tag, false
|
||||
>
|
||||
{
|
||||
typedef typename distance_result
|
||||
<
|
||||
Linear, Ring, Strategy
|
||||
>::type distance_type;
|
||||
|
||||
static inline distance_type apply(Linear const& linear,
|
||||
Ring const& ring,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
return detail::distance_brute_force::one_to_many
|
||||
<
|
||||
distance_brute_force
|
||||
<
|
||||
Linear,
|
||||
typename std::iterator_traits
|
||||
<
|
||||
segment_iterator<Ring const>
|
||||
>::value_type,
|
||||
Strategy
|
||||
>
|
||||
>::apply(linear,
|
||||
geometry::segments_begin(ring),
|
||||
geometry::segments_end(ring),
|
||||
strategy);
|
||||
}
|
||||
};
|
||||
|
||||
template
|
||||
<
|
||||
typename Linear,
|
||||
typename Polygon,
|
||||
typename Strategy
|
||||
>
|
||||
struct distance_brute_force
|
||||
<
|
||||
Linear, Polygon, Strategy,
|
||||
linear_tag, polygon_tag, false
|
||||
>
|
||||
{
|
||||
typedef typename distance_result
|
||||
<
|
||||
Linear, Polygon, Strategy
|
||||
>::type distance_type;
|
||||
|
||||
static inline distance_type apply(Linear const& linear,
|
||||
Polygon const& polygon,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
return detail::distance_brute_force::one_to_many
|
||||
<
|
||||
distance_brute_force
|
||||
<
|
||||
Linear,
|
||||
typename std::iterator_traits
|
||||
<
|
||||
segment_iterator<Polygon const>
|
||||
>::value_type,
|
||||
Strategy
|
||||
>
|
||||
>::apply(linear,
|
||||
geometry::segments_begin(polygon),
|
||||
geometry::segments_end(polygon),
|
||||
strategy);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template
|
||||
<
|
||||
typename Linear,
|
||||
typename Box,
|
||||
typename Strategy
|
||||
>
|
||||
struct distance_brute_force
|
||||
<
|
||||
Linear, Box, Strategy,
|
||||
linear_tag, box_tag, false
|
||||
>
|
||||
{
|
||||
typedef typename distance_result
|
||||
<
|
||||
Linear, Box, Strategy
|
||||
>::type distance_type;
|
||||
|
||||
static inline distance_type apply(Linear const& linear,
|
||||
Box const& box,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
return detail::distance_brute_force::one_to_many
|
||||
<
|
||||
detail::distance_brute_force::distance_from_bg
|
||||
>::apply(box,
|
||||
geometry::segments_begin(linear),
|
||||
geometry::segments_end(linear),
|
||||
strategy);
|
||||
}
|
||||
};
|
||||
|
||||
template
|
||||
<
|
||||
typename Linear,
|
||||
typename MultiPoint,
|
||||
typename Strategy
|
||||
>
|
||||
struct distance_brute_force
|
||||
<
|
||||
Linear, MultiPoint, Strategy,
|
||||
linear_tag, multi_point_tag, false
|
||||
>
|
||||
{
|
||||
typedef typename distance_result
|
||||
<
|
||||
Linear, MultiPoint, Strategy
|
||||
>::type distance_type;
|
||||
|
||||
static inline distance_type apply(Linear const& linear,
|
||||
MultiPoint const& mp,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
return detail::distance_brute_force::one_to_many
|
||||
<
|
||||
distance_brute_force
|
||||
<
|
||||
Linear,
|
||||
typename boost::range_value<MultiPoint>::type,
|
||||
Strategy
|
||||
>
|
||||
>::apply(linear, boost::begin(mp), boost::end(mp), strategy);
|
||||
}
|
||||
};
|
||||
|
||||
template
|
||||
<
|
||||
typename Linear,
|
||||
typename MultiPolygon,
|
||||
typename Strategy
|
||||
>
|
||||
struct distance_brute_force
|
||||
<
|
||||
Linear, MultiPolygon, Strategy,
|
||||
linear_tag, multi_polygon_tag, false
|
||||
>
|
||||
{
|
||||
typedef typename distance_result
|
||||
<
|
||||
Linear, MultiPolygon, Strategy
|
||||
>::type distance_type;
|
||||
|
||||
static inline distance_type apply(Linear const& linear,
|
||||
MultiPolygon const& mp,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
return detail::distance_brute_force::one_to_many
|
||||
<
|
||||
distance_brute_force
|
||||
<
|
||||
Linear,
|
||||
typename boost::range_value<MultiPolygon>::type,
|
||||
Strategy
|
||||
>
|
||||
>::apply(linear, boost::begin(mp), boost::end(mp), strategy);
|
||||
}
|
||||
};
|
||||
|
||||
//=================================================================
|
||||
|
||||
template
|
||||
<
|
||||
typename Polygon,
|
||||
typename Segment,
|
||||
typename Strategy
|
||||
>
|
||||
struct distance_brute_force
|
||||
<
|
||||
Polygon, Segment, Strategy,
|
||||
polygon_tag, segment_tag, false
|
||||
>
|
||||
{
|
||||
typedef typename distance_result
|
||||
<
|
||||
Polygon, Segment, Strategy
|
||||
>::type distance_type;
|
||||
|
||||
static inline distance_type apply(Polygon const& polygon,
|
||||
Segment const& segment,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
return detail::distance_brute_force::one_to_many
|
||||
<
|
||||
distance_brute_force
|
||||
<
|
||||
Segment,
|
||||
typename std::iterator_traits
|
||||
<
|
||||
segment_iterator<Polygon const>
|
||||
>::value_type,
|
||||
Strategy
|
||||
>
|
||||
>::apply(segment,
|
||||
geometry::segments_begin(polygon),
|
||||
geometry::segments_end(polygon),
|
||||
strategy);
|
||||
}
|
||||
};
|
||||
|
||||
template
|
||||
<
|
||||
typename Polygon,
|
||||
typename Linear,
|
||||
typename Strategy
|
||||
>
|
||||
struct distance_brute_force
|
||||
<
|
||||
Polygon, Linear, Strategy,
|
||||
polygon_tag, linear_tag, false
|
||||
>
|
||||
{
|
||||
typedef typename distance_result
|
||||
<
|
||||
Polygon, Linear, Strategy
|
||||
>::type distance_type;
|
||||
|
||||
static inline distance_type apply(Polygon const& polygon,
|
||||
Linear const& linear,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
return detail::distance_brute_force::one_to_many
|
||||
<
|
||||
distance_brute_force
|
||||
<
|
||||
Linear,
|
||||
typename std::iterator_traits
|
||||
<
|
||||
segment_iterator<Polygon const>
|
||||
>::value_type,
|
||||
Strategy
|
||||
>
|
||||
>::apply(linear,
|
||||
geometry::segments_begin(polygon),
|
||||
geometry::segments_end(polygon),
|
||||
strategy);
|
||||
}
|
||||
};
|
||||
|
||||
//========================================================================
|
||||
|
||||
template
|
||||
<
|
||||
typename MultiPoint1,
|
||||
typename MultiPoint2,
|
||||
typename Strategy
|
||||
>
|
||||
struct distance_brute_force
|
||||
<
|
||||
MultiPoint1, MultiPoint2, Strategy,
|
||||
multi_point_tag, multi_point_tag, false
|
||||
>
|
||||
{
|
||||
typedef typename distance_result
|
||||
<
|
||||
MultiPoint1, MultiPoint2, Strategy
|
||||
>::type distance_type;
|
||||
|
||||
static inline distance_type apply(MultiPoint1 const& mp1,
|
||||
MultiPoint2 const& mp2,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
return detail::distance_brute_force::one_to_many
|
||||
<
|
||||
distance_brute_force
|
||||
<
|
||||
MultiPoint1,
|
||||
typename boost::range_value<MultiPoint2>::type,
|
||||
Strategy
|
||||
>
|
||||
>::apply(mp1, boost::begin(mp2), boost::end(mp2), strategy);
|
||||
}
|
||||
};
|
||||
|
||||
template
|
||||
<
|
||||
typename MultiPoint,
|
||||
typename Linear,
|
||||
typename Strategy
|
||||
>
|
||||
struct distance_brute_force
|
||||
<
|
||||
MultiPoint, Linear, Strategy,
|
||||
multi_point_tag, linear_tag, false
|
||||
>
|
||||
{
|
||||
typedef typename distance_result
|
||||
<
|
||||
MultiPoint, Linear, Strategy
|
||||
>::type distance_type;
|
||||
|
||||
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 boost::range_value<Linear>::type,
|
||||
Strategy
|
||||
>
|
||||
>::apply(mp, boost::begin(l), boost::end(l), strategy);
|
||||
}
|
||||
};
|
||||
|
||||
template
|
||||
<
|
||||
typename MultiPoint,
|
||||
typename Segment,
|
||||
typename Strategy
|
||||
>
|
||||
struct distance_brute_force
|
||||
<
|
||||
MultiPoint, Segment, Strategy,
|
||||
multi_point_tag, segment_tag, false
|
||||
>
|
||||
{
|
||||
typedef typename distance_result
|
||||
<
|
||||
MultiPoint, Segment, Strategy
|
||||
>::type distance_type;
|
||||
|
||||
static inline distance_type apply(MultiPoint const& mp,
|
||||
Segment const& segment,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
return detail::distance_brute_force::one_to_many
|
||||
<
|
||||
detail::distance_brute_force::distance_from_bg
|
||||
>::apply(segment, boost::begin(mp), boost::end(mp), strategy);
|
||||
}
|
||||
};
|
||||
|
||||
template
|
||||
<
|
||||
typename MultiPoint,
|
||||
typename Box,
|
||||
typename Strategy
|
||||
>
|
||||
struct distance_brute_force
|
||||
<
|
||||
MultiPoint, Box, Strategy,
|
||||
multi_point_tag, box_tag, false
|
||||
>
|
||||
{
|
||||
typedef typename distance_result
|
||||
<
|
||||
MultiPoint, Box, Strategy
|
||||
>::type distance_type;
|
||||
|
||||
static inline distance_type apply(MultiPoint const& mp,
|
||||
Box const& box,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
return detail::distance_brute_force::one_to_many
|
||||
<
|
||||
distance_brute_force
|
||||
<
|
||||
Box,
|
||||
typename boost::range_value<MultiPoint>::type,
|
||||
Strategy
|
||||
>
|
||||
>::apply(box, boost::begin(mp), boost::end(mp), strategy);
|
||||
}
|
||||
};
|
||||
|
||||
//=====================================================================
|
||||
|
||||
template
|
||||
<
|
||||
typename MultiPolygon,
|
||||
typename Segment,
|
||||
typename Strategy
|
||||
>
|
||||
struct distance_brute_force
|
||||
<
|
||||
MultiPolygon, Segment, Strategy,
|
||||
multi_polygon_tag, segment_tag, false
|
||||
>
|
||||
{
|
||||
typedef typename distance_result
|
||||
<
|
||||
MultiPolygon, Segment, Strategy
|
||||
>::type distance_type;
|
||||
|
||||
static inline distance_type apply(MultiPolygon const& mp,
|
||||
Segment const& segment,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
return detail::distance_brute_force::one_to_many
|
||||
<
|
||||
distance_brute_force
|
||||
<
|
||||
Segment,
|
||||
typename boost::range_value<MultiPolygon>::type,
|
||||
Strategy
|
||||
>
|
||||
>::apply(segment, boost::begin(mp), boost::end(mp), strategy);
|
||||
}
|
||||
};
|
||||
|
||||
//========================================================================
|
||||
|
||||
template
|
||||
<
|
||||
typename Segment1,
|
||||
typename Segment2,
|
||||
typename Strategy
|
||||
>
|
||||
struct distance_brute_force
|
||||
<
|
||||
Segment1, Segment2, Strategy,
|
||||
segment_tag, segment_tag, false
|
||||
> : detail::distance_brute_force::distance_from_bg
|
||||
{};
|
||||
|
||||
template
|
||||
<
|
||||
typename Segment,
|
||||
typename Ring,
|
||||
typename Strategy
|
||||
>
|
||||
struct distance_brute_force
|
||||
<
|
||||
Segment, Ring, Strategy,
|
||||
segment_tag, ring_tag, false
|
||||
>
|
||||
{
|
||||
typedef typename distance_result
|
||||
<
|
||||
Segment, Ring, Strategy
|
||||
>::type distance_type;
|
||||
|
||||
static inline distance_type apply(Segment const& segment,
|
||||
Ring const& ring,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
return detail::distance_brute_force::one_to_many
|
||||
<
|
||||
distance_brute_force
|
||||
<
|
||||
Segment,
|
||||
typename std::iterator_traits
|
||||
<
|
||||
segment_iterator<Ring const>
|
||||
>::value_type,
|
||||
Strategy
|
||||
>
|
||||
>::apply(segment,
|
||||
geometry::segments_begin(ring),
|
||||
geometry::segments_end(ring),
|
||||
strategy);
|
||||
}
|
||||
};
|
||||
|
||||
template
|
||||
<
|
||||
typename Segment,
|
||||
typename Box,
|
||||
typename Strategy
|
||||
>
|
||||
struct distance_brute_force
|
||||
<
|
||||
Segment, Box, Strategy,
|
||||
segment_tag, box_tag, false
|
||||
> : detail::distance_brute_force::distance_from_bg
|
||||
{};
|
||||
|
||||
//====================================================================
|
||||
|
||||
template
|
||||
<
|
||||
typename Box1,
|
||||
typename Box2,
|
||||
typename Strategy
|
||||
>
|
||||
struct distance_brute_force
|
||||
<
|
||||
Box1, Box2, Strategy,
|
||||
box_tag, box_tag, false
|
||||
> : detail::distance_brute_force::distance_from_bg
|
||||
{};
|
||||
|
||||
} // namespace dispatch
|
||||
|
||||
|
||||
|
@ -22,66 +22,205 @@
|
||||
#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::linestring<point_type> linestring_type;
|
||||
typedef bg::model::multi_linestring<linestring_type> multi_linestring_type;
|
||||
typedef bg::model::box<point_type> box_type;
|
||||
|
||||
namespace services = bg::strategy::distance::services;
|
||||
typedef bg::default_distance_result<point_type>::type return_type;
|
||||
|
||||
typedef bg::srs::spheroid<double> stype;
|
||||
|
||||
// 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;
|
||||
|
||||
//===========================================================================
|
||||
|
||||
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_segment_polygon(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 << "segment/polygon distance tests" << std::endl;
|
||||
#endif
|
||||
typedef bg::model::segment<Point> segment_type;
|
||||
typedef bg::model::polygon<Point> polygon_type;
|
||||
typedef test_distance_of_geometries<segment_type, polygon_type> tester;
|
||||
|
||||
std::string const polygon = "POLYGON((10 10,0 20, 15 30, 20 15, 15 10, 10 10))";
|
||||
|
||||
tester::apply("s-r-1", "SEGMENT(0 0, 0 10)", polygon,
|
||||
ps_distance<Point>("POINT(0 10)", "SEGMENT(0 20, 10 10)", strategy_ps),
|
||||
strategy_ps, true, false, 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_linestring_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 << "linestring/polygon distance tests" << std::endl;
|
||||
#endif
|
||||
typedef bg::model::linestring<Point> linestring_type;
|
||||
typedef bg::model::polygon<Point> polygon_type;
|
||||
typedef test_distance_of_geometries<linestring_type, polygon_type> tester;
|
||||
|
||||
std::string const polygon = "POLYGON((10 10,0 20, 15 30, 20 15, 15 10, 10 10))";
|
||||
|
||||
tester::apply("l-r-1", "LINESTRING(0 0, 0 10)", polygon,
|
||||
ps_distance<Point>("POINT(0 10)", "SEGMENT(0 20, 10 10)", strategy_ps),
|
||||
strategy_ps, true, false, false);
|
||||
}
|
||||
|
||||
template <typename Point, typename Strategy_pp, typename Strategy_ps>
|
||||
void test_distance_multi_linestring_polygon(Strategy_pp const& strategy_pp,
|
||||
Strategy_ps const& strategy_ps)
|
||||
{
|
||||
|
||||
template <typename Strategy_pp, typename Strategy_ps>
|
||||
#ifdef BOOST_GEOMETRY_TEST_DEBUG
|
||||
std::cout << std::endl;
|
||||
std::cout << "multilinestring/polygon distance tests" << std::endl;
|
||||
#endif
|
||||
typedef bg::model::linestring<Point> linestring_type;
|
||||
typedef bg::model::multi_linestring<linestring_type> multi_linestring_type;
|
||||
typedef bg::model::polygon<Point> polygon_type;
|
||||
typedef test_distance_of_geometries<multi_linestring_type, polygon_type> tester;
|
||||
|
||||
std::string const polygon = "POLYGON((10 10,0 20, 15 30, 20 15, 15 10, 10 10))";
|
||||
|
||||
tester::apply("ml-r-1", "MULTILINESTRING((0 0, 0 10)(0 0, 10 0))", polygon,
|
||||
ps_distance<Point>("POINT(0 10)", "SEGMENT(0 20, 10 10)", strategy_ps),
|
||||
strategy_ps, true, false, false);
|
||||
}
|
||||
|
||||
//=====================================================================
|
||||
|
||||
template <typename Point, typename Strategy_pp, typename Strategy_ps>
|
||||
void test_distance_segment_multi_polygon(Strategy_pp const& strategy_pp,
|
||||
Strategy_ps const& strategy_ps)
|
||||
{
|
||||
|
||||
#ifdef BOOST_GEOMETRY_TEST_DEBUG
|
||||
std::cout << std::endl;
|
||||
std::cout << "segment/multi_polygon distance tests" << std::endl;
|
||||
#endif
|
||||
typedef bg::model::segment<Point> segment_type;
|
||||
typedef bg::model::polygon<Point> polygon_type;
|
||||
typedef bg::model::multi_polygon<polygon_type> multi_polygon_type;
|
||||
typedef test_distance_of_geometries<segment_type, multi_polygon_type> tester;
|
||||
|
||||
std::string const mp = "MULTIPOLYGON(((20 20, 20 30, 30 40, 20 20)),\
|
||||
((10 10,0 20, 15 30, 20 15, 15 10, 10 10)))";
|
||||
|
||||
tester::apply("s-r-1", "SEGMENT(0 0, 0 10)", mp,
|
||||
ps_distance<Point>("POINT(0 10)", "SEGMENT(0 20, 10 10)", strategy_ps),
|
||||
strategy_ps, true, false, false);
|
||||
}
|
||||
|
||||
template <typename Point, typename Strategy_pp, typename Strategy_ps>
|
||||
void test_distance_linestring_multi_polygon(Strategy_pp const& strategy_pp,
|
||||
Strategy_ps const& strategy_ps)
|
||||
{
|
||||
|
||||
#ifdef BOOST_GEOMETRY_TEST_DEBUG
|
||||
std::cout << std::endl;
|
||||
std::cout << "linestring/multi_polygon distance tests" << std::endl;
|
||||
#endif
|
||||
typedef bg::model::linestring<Point> linestring_type;
|
||||
typedef bg::model::polygon<Point> polygon_type;
|
||||
typedef bg::model::multi_polygon<polygon_type> multi_polygon_type;
|
||||
typedef test_distance_of_geometries<linestring_type, multi_polygon_type> tester;
|
||||
|
||||
std::string const mp = "MULTIPOLYGON(((20 20, 20 30, 30 40, 20 20)),\
|
||||
((10 10,0 20, 15 30, 20 15, 15 10, 10 10)))";
|
||||
|
||||
tester::apply("l-r-1", "LINESTRING(0 0, 0 10)", mp,
|
||||
ps_distance<Point>("POINT(0 10)", "SEGMENT(0 20, 10 10)", strategy_ps),
|
||||
strategy_ps, true, false, false);
|
||||
}
|
||||
|
||||
template <typename Point, typename Strategy_pp, typename Strategy_ps>
|
||||
void test_distance_multi_linestring_multi_polygon(Strategy_pp const& strategy_pp,
|
||||
Strategy_ps const& strategy_ps)
|
||||
{
|
||||
|
||||
#ifdef BOOST_GEOMETRY_TEST_DEBUG
|
||||
std::cout << std::endl;
|
||||
std::cout << "multilinestring/multi_polygon distance tests" << std::endl;
|
||||
#endif
|
||||
typedef bg::model::linestring<Point> linestring_type;
|
||||
typedef bg::model::multi_linestring<linestring_type> multi_linestring_type;
|
||||
typedef bg::model::polygon<Point> polygon_type;
|
||||
typedef bg::model::multi_polygon<polygon_type> multi_polygon_type;
|
||||
typedef test_distance_of_geometries<multi_linestring_type, multi_polygon_type> tester;
|
||||
|
||||
std::string const polygon = "MULTIPOLYGON(((20 20, 20 30, 30 40, 20 20)),\
|
||||
((10 10,0 20, 15 30, 20 15, 15 10, 10 10)))";
|
||||
|
||||
tester::apply("ml-r-1", "MULTILINESTRING((0 0, 0 10)(0 0, 10 0))", polygon,
|
||||
ps_distance<Point>("POINT(0 10)", "SEGMENT(0 20, 10 10)", strategy_ps),
|
||||
strategy_ps, true, false, false);
|
||||
}
|
||||
|
||||
//=====================================================================
|
||||
|
||||
template <typename Point, typename Strategy_pp, typename Strategy_ps>
|
||||
void test_distance_segment_ring(Strategy_pp const& strategy_pp,
|
||||
Strategy_ps const& strategy_ps)
|
||||
{
|
||||
|
||||
#ifdef BOOST_GEOMETRY_TEST_DEBUG
|
||||
std::cout << std::endl;
|
||||
std::cout << "segment/ring distance tests" << std::endl;
|
||||
#endif
|
||||
typedef bg::model::segment<Point> segment_type;
|
||||
typedef bg::model::ring<Point> ring_type;
|
||||
typedef test_distance_of_geometries<segment_type, ring_type> tester;
|
||||
|
||||
std::string const ring = "POLYGON((10 10,0 20, 15 30, 20 15, 15 10, 10 10))";
|
||||
|
||||
tester::apply("s-r-1", "SEGMENT(0 0, 0 10)", ring,
|
||||
ps_distance<Point>("POINT(0 10)", "SEGMENT(0 20, 10 10)", strategy_ps),
|
||||
strategy_ps, true, false, false);
|
||||
}
|
||||
|
||||
template <typename Point, typename Strategy_pp, typename Strategy_ps>
|
||||
void test_distance_linestring_ring(Strategy_pp const& strategy_pp,
|
||||
Strategy_ps const& strategy_ps)
|
||||
{
|
||||
|
||||
#ifdef BOOST_GEOMETRY_TEST_DEBUG
|
||||
std::cout << std::endl;
|
||||
std::cout << "linestring/ring distance tests" << std::endl;
|
||||
#endif
|
||||
typedef bg::model::linestring<Point> linestring_type;
|
||||
typedef bg::model::ring<Point> ring_type;
|
||||
typedef test_distance_of_geometries<linestring_type, ring_type> tester;
|
||||
|
||||
std::string const ring = "POLYGON((10 10,0 20, 15 30, 20 15, 15 10, 10 10))";
|
||||
|
||||
tester::apply("l-r-1", "LINESTRING(0 0, 0 10)", ring,
|
||||
ps_distance<Point>("POINT(0 10)", "SEGMENT(0 20, 10 10)", strategy_ps),
|
||||
strategy_ps, true, false, false);
|
||||
}
|
||||
|
||||
template <typename Point, typename Strategy_pp, typename Strategy_ps>
|
||||
void test_distance_multi_linestring_ring(Strategy_pp const& strategy_pp,
|
||||
Strategy_ps const& strategy_ps)
|
||||
{
|
||||
|
||||
#ifdef BOOST_GEOMETRY_TEST_DEBUG
|
||||
std::cout << std::endl;
|
||||
std::cout << "multilinestring/ring distance tests" << std::endl;
|
||||
#endif
|
||||
typedef bg::model::linestring<Point> linestring_type;
|
||||
typedef bg::model::multi_linestring<linestring_type> multi_linestring_type;
|
||||
typedef bg::model::ring<Point> ring_type;
|
||||
typedef test_distance_of_geometries<multi_linestring_type, ring_type> tester;
|
||||
|
||||
std::string const ring = "POLYGON((10 10,0 20, 15 30, 20 15, 15 10, 10 10))";
|
||||
|
||||
tester::apply("ml-r-1", "MULTILINESTRING((0 0, 0 10)(0 0, 10 0))", ring,
|
||||
ps_distance<Point>("POINT(0 10)", "SEGMENT(0 20, 10 10)", strategy_ps),
|
||||
strategy_ps, true, false, false);
|
||||
}
|
||||
|
||||
//======================================================================
|
||||
|
||||
template <typename Point, typename Strategy_pp, typename Strategy_ps>
|
||||
void test_distance_segment_box(Strategy_pp const& strategy_pp,
|
||||
Strategy_ps const& strategy_ps)
|
||||
{
|
||||
@ -90,168 +229,170 @@ void test_distance_segment_box(Strategy_pp const& strategy_pp,
|
||||
std::cout << std::endl;
|
||||
std::cout << "segment/box distance tests" << std::endl;
|
||||
#endif
|
||||
typedef bg::model::segment<Point> segment_type;
|
||||
typedef bg::model::box<Point> box_type;
|
||||
typedef test_distance_of_geometries<segment_type, box_type> tester;
|
||||
|
||||
std::string const box_north = "BOX(10 10,20 20)";
|
||||
|
||||
tester::apply("sb1-1a", "SEGMENT(0 0, 0 20)", box_north,
|
||||
pp_distance("POINT(0 20)", "POINT(10 20)", strategy_pp),
|
||||
pp_distance<Point>("POINT(0 20)", "POINT(10 20)", strategy_pp),
|
||||
strategy_ps);
|
||||
//segment with slope
|
||||
tester::apply("sb1-1b", "SEGMENT(10 5, 20 6)", box_north,
|
||||
pp_distance("POINT(20 6)", "POINT(20 10)", strategy_pp),
|
||||
pp_distance<Point>("POINT(20 6)", "POINT(20 10)", strategy_pp),
|
||||
strategy_ps);
|
||||
tester::apply("sb1-2", "SEGMENT(0 0, 0 10)", box_north,
|
||||
ps_distance("POINT(0 10)", "SEGMENT(10 10,10 20)", strategy_ps),
|
||||
ps_distance<Point>("POINT(0 10)", "SEGMENT(10 10,10 20)", strategy_ps),
|
||||
strategy_ps);
|
||||
tester::apply("sb1-3", "SEGMENT(0 0, 0 15)", box_north,
|
||||
ps_distance("POINT(0 15)", "SEGMENT(10 10,10 20)", strategy_ps),
|
||||
ps_distance<Point>("POINT(0 15)", "SEGMENT(10 10,10 20)", strategy_ps),
|
||||
strategy_ps);
|
||||
tester::apply("sb1-4", "SEGMENT(0 0, 0 25)", box_north,
|
||||
ps_distance("POINT(10 20)", "SEGMENT(0 0,0 25)", strategy_ps),
|
||||
ps_distance<Point>("POINT(10 20)", "SEGMENT(0 0,0 25)", strategy_ps),
|
||||
strategy_ps);
|
||||
tester::apply("sb1-5", "SEGMENT(0 10, 0 25)", box_north,
|
||||
ps_distance("POINT(10 20)", "SEGMENT(0 0,0 25)", strategy_ps),
|
||||
ps_distance<Point>("POINT(10 20)", "SEGMENT(0 0,0 25)", strategy_ps),
|
||||
strategy_ps);
|
||||
|
||||
tester::apply("sb2-2", "SEGMENT(0 5, 15 5)", box_north,
|
||||
ps_distance("POINT(10 10)", "SEGMENT(0 5,15 5)", strategy_ps),
|
||||
ps_distance<Point>("POINT(10 10)", "SEGMENT(0 5,15 5)", strategy_ps),
|
||||
strategy_ps);
|
||||
tester::apply("sb2-3a", "SEGMENT(0 5, 20 5)", box_north,
|
||||
ps_distance("POINT(10 10)", "SEGMENT(0 5,20 5)", strategy_ps),
|
||||
ps_distance<Point>("POINT(10 10)", "SEGMENT(0 5,20 5)", strategy_ps),
|
||||
strategy_ps);
|
||||
|
||||
// Test segments below box
|
||||
tester::apply("test_b1", "SEGMENT(0 5, 9 5)", box_north,
|
||||
ps_distance("POINT(10 10)", "SEGMENT(0 5, 9 5)", strategy_ps),
|
||||
ps_distance<Point>("POINT(10 10)", "SEGMENT(0 5, 9 5)", strategy_ps),
|
||||
strategy_ps);
|
||||
tester::apply("test_b2", "SEGMENT(0 5, 10 5)", box_north,
|
||||
ps_distance("POINT(10 10)", "SEGMENT(0 5, 10 5)", strategy_ps),
|
||||
ps_distance<Point>("POINT(10 10)", "SEGMENT(0 5, 10 5)", strategy_ps),
|
||||
strategy_ps);
|
||||
tester::apply("test_b3", "SEGMENT(0 5, 11 5)", box_north,
|
||||
ps_distance("POINT(10 10)", "SEGMENT(0 5, 11 5)", strategy_ps),
|
||||
ps_distance<Point>("POINT(10 10)", "SEGMENT(0 5, 11 5)", strategy_ps),
|
||||
strategy_ps);
|
||||
tester::apply("test_b4", "SEGMENT(0 5, 20 5)", box_north,
|
||||
ps_distance("POINT(10 10)", "SEGMENT(0 5,20 5)", strategy_ps),
|
||||
ps_distance<Point>("POINT(10 10)", "SEGMENT(0 5,20 5)", strategy_ps),
|
||||
strategy_ps);
|
||||
tester::apply("test_b5", "SEGMENT(0 5, 22 5)", box_north,
|
||||
ps_distance("POINT(11 10)", "SEGMENT(0 5,22 5)", strategy_ps),
|
||||
ps_distance<Point>("POINT(11 10)", "SEGMENT(0 5,22 5)", strategy_ps),
|
||||
strategy_ps);
|
||||
tester::apply("test_b6", "SEGMENT(10 5, 20 5)", box_north,
|
||||
ps_distance("POINT(15 10)", "SEGMENT(10 5,20 5)", strategy_ps),
|
||||
ps_distance<Point>("POINT(15 10)", "SEGMENT(10 5,20 5)", strategy_ps),
|
||||
strategy_ps);
|
||||
tester::apply("test_b7", "SEGMENT(10 5, 22 5)", box_north,
|
||||
ps_distance("POINT(16 10)", "SEGMENT(10 5,22 5)", strategy_ps),
|
||||
ps_distance<Point>("POINT(16 10)", "SEGMENT(10 5,22 5)", strategy_ps),
|
||||
strategy_ps);
|
||||
tester::apply("test_b8", "SEGMENT(12 5, 22 5)", box_north,
|
||||
ps_distance("POINT(17 10)", "SEGMENT(12 5,22 5)", strategy_ps),
|
||||
ps_distance<Point>("POINT(17 10)", "SEGMENT(12 5,22 5)", strategy_ps),
|
||||
strategy_ps);
|
||||
tester::apply("test_b9", "SEGMENT(18 5, 22 5)", box_north,
|
||||
ps_distance("POINT(20 10)", "SEGMENT(18 5,22 5)", strategy_ps),
|
||||
ps_distance<Point>("POINT(20 10)", "SEGMENT(18 5,22 5)", strategy_ps),
|
||||
strategy_ps);
|
||||
tester::apply("test_b10", "SEGMENT(18 5, 24 5)", box_north,
|
||||
ps_distance("POINT(20 10)", "SEGMENT(18 5,24 5)", strategy_ps),
|
||||
ps_distance<Point>("POINT(20 10)", "SEGMENT(18 5,24 5)", strategy_ps),
|
||||
strategy_ps);
|
||||
tester::apply("test_b11", "SEGMENT(20 5, 24 5)", box_north,
|
||||
ps_distance("POINT(20 10)", "SEGMENT(20 5,24 5)", strategy_ps),
|
||||
ps_distance<Point>("POINT(20 10)", "SEGMENT(20 5,24 5)", strategy_ps),
|
||||
strategy_ps);
|
||||
tester::apply("test_b12", "SEGMENT(22 5, 24 5)", box_north,
|
||||
ps_distance("POINT(20 10)", "SEGMENT(22 5,24 5)", strategy_ps),
|
||||
ps_distance<Point>("POINT(20 10)", "SEGMENT(22 5,24 5)", strategy_ps),
|
||||
strategy_ps);
|
||||
tester::apply("test_b13", "SEGMENT(0 5, 125 5)", box_north,
|
||||
ps_distance("POINT(20 10)", "SEGMENT(0 5, 125 5)", strategy_ps),
|
||||
ps_distance<Point>("POINT(20 10)", "SEGMENT(0 5, 125 5)", strategy_ps),
|
||||
strategy_ps);
|
||||
|
||||
// Test segments above box
|
||||
tester::apply("test_a1", "SEGMENT(0 25, 9 25)", box_north,
|
||||
ps_distance("POINT(10 20)", "SEGMENT(0 25, 9 25)", strategy_ps),
|
||||
ps_distance<Point>("POINT(10 20)", "SEGMENT(0 25, 9 25)", strategy_ps),
|
||||
strategy_ps);
|
||||
tester::apply("test_a2", "SEGMENT(0 25, 10 25)", box_north,
|
||||
ps_distance("POINT(10 20)", "SEGMENT(0 25, 10 25)", strategy_ps),
|
||||
ps_distance<Point>("POINT(10 20)", "SEGMENT(0 25, 10 25)", strategy_ps),
|
||||
strategy_ps);
|
||||
tester::apply("test_a3", "SEGMENT(0 25, 11 25)", box_north,
|
||||
ps_distance("POINT(11 20)", "SEGMENT(0 25, 11 25)", strategy_ps),
|
||||
ps_distance<Point>("POINT(11 20)", "SEGMENT(0 25, 11 25)", strategy_ps),
|
||||
strategy_ps);
|
||||
tester::apply("test_a4", "SEGMENT(0 25, 20 25)", box_north,
|
||||
ps_distance("POINT(20 20)", "SEGMENT(0 25, 20 25)", strategy_ps),
|
||||
ps_distance<Point>("POINT(20 20)", "SEGMENT(0 25, 20 25)", strategy_ps),
|
||||
strategy_ps);
|
||||
tester::apply("test_a5", "SEGMENT(0 25, 22 25)", box_north,
|
||||
ps_distance("POINT(20 20)", "SEGMENT(0 25, 22 25)", strategy_ps),
|
||||
ps_distance<Point>("POINT(20 20)", "SEGMENT(0 25, 22 25)", strategy_ps),
|
||||
strategy_ps);
|
||||
tester::apply("test_a6", "SEGMENT(10 25, 20 25)", box_north,
|
||||
ps_distance("POINT(20 20)", "SEGMENT(10 25, 20 25)", strategy_ps),
|
||||
ps_distance<Point>("POINT(20 20)", "SEGMENT(10 25, 20 25)", strategy_ps),
|
||||
strategy_ps);
|
||||
tester::apply("test_a7", "SEGMENT(10 25, 22 25)", box_north,
|
||||
ps_distance("POINT(10 20)", "SEGMENT(10 25, 22 25)", strategy_ps),
|
||||
ps_distance<Point>("POINT(10 20)", "SEGMENT(10 25, 22 25)", strategy_ps),
|
||||
strategy_ps);
|
||||
tester::apply("test_a8", "SEGMENT(12 25, 22 25)", box_north,
|
||||
ps_distance("POINT(12 20)", "SEGMENT(12 25, 22 25)", strategy_ps),
|
||||
ps_distance<Point>("POINT(12 20)", "SEGMENT(12 25, 22 25)", strategy_ps),
|
||||
strategy_ps);
|
||||
tester::apply("test_a9", "SEGMENT(18 25, 22 25)", box_north,
|
||||
ps_distance("POINT(18 20)", "SEGMENT(18 25, 22 25)", strategy_ps),
|
||||
ps_distance<Point>("POINT(18 20)", "SEGMENT(18 25, 22 25)", strategy_ps),
|
||||
strategy_ps);
|
||||
tester::apply("test_a10", "SEGMENT(18 25, 24 25)", box_north,
|
||||
ps_distance("POINT(18 20)", "SEGMENT(18 25, 24 25)", strategy_ps),
|
||||
ps_distance<Point>("POINT(18 20)", "SEGMENT(18 25, 24 25)", strategy_ps),
|
||||
strategy_ps);
|
||||
tester::apply("test_a11", "SEGMENT(20 25, 24 25)", box_north,
|
||||
ps_distance("POINT(20 20)", "SEGMENT(20 25, 24 25)", strategy_ps),
|
||||
ps_distance<Point>("POINT(20 20)", "SEGMENT(20 25, 24 25)", strategy_ps),
|
||||
strategy_ps);
|
||||
tester::apply("test_a12", "SEGMENT(22 25, 24 25)", box_north,
|
||||
ps_distance("POINT(20 20)", "SEGMENT(22 25, 24 25)", strategy_ps),
|
||||
ps_distance<Point>("POINT(20 20)", "SEGMENT(22 25, 24 25)", strategy_ps),
|
||||
strategy_ps);
|
||||
|
||||
// Segments left-right of box
|
||||
tester::apply("test_l1", "SEGMENT(0 5, 9 5)", box_north,
|
||||
ps_distance("POINT(10 10)", "SEGMENT(0 5, 9 5)", strategy_ps),
|
||||
ps_distance<Point>("POINT(10 10)", "SEGMENT(0 5, 9 5)", strategy_ps),
|
||||
strategy_ps);
|
||||
tester::apply("test_l2", "SEGMENT(0 10, 9 10)", box_north,
|
||||
ps_distance("POINT(9 10)", "SEGMENT(10 10, 10 20)", strategy_ps),
|
||||
ps_distance<Point>("POINT(9 10)", "SEGMENT(10 10, 10 20)", strategy_ps),
|
||||
strategy_ps);
|
||||
tester::apply("test_l3", "SEGMENT(0 10, 9 15)", box_north,
|
||||
ps_distance("POINT(9 15)", "SEGMENT(10 10, 10 20)", strategy_ps),
|
||||
ps_distance<Point>("POINT(9 15)", "SEGMENT(10 10, 10 20)", strategy_ps),
|
||||
strategy_ps);
|
||||
tester::apply("test_l4", "SEGMENT(0 10, 0 15)", box_north,
|
||||
ps_distance("POINT(0 15)", "SEGMENT(10 10, 10 20)", strategy_ps),
|
||||
ps_distance<Point>("POINT(0 15)", "SEGMENT(10 10, 10 20)", strategy_ps),
|
||||
strategy_ps);
|
||||
tester::apply("test_l5", "SEGMENT(1 10, 0 15)", box_north,
|
||||
ps_distance("POINT(1 10)", "SEGMENT(10 10, 10 20)", strategy_ps),
|
||||
ps_distance<Point>("POINT(1 10)", "SEGMENT(10 10, 10 20)", strategy_ps),
|
||||
strategy_ps);
|
||||
tester::apply("test_l6", "SEGMENT(0 20, 9 21)", box_north,
|
||||
ps_distance("POINT(9 21)", "SEGMENT(10 10, 10 20)", strategy_ps),
|
||||
ps_distance<Point>("POINT(9 21)", "SEGMENT(10 10, 10 20)", strategy_ps),
|
||||
strategy_ps);
|
||||
tester::apply("test_r1", "SEGMENT(21 5, 29 5)", box_north,
|
||||
ps_distance("POINT(20 10)", "SEGMENT(21 5, 29 5)", strategy_ps),
|
||||
ps_distance<Point>("POINT(20 10)", "SEGMENT(21 5, 29 5)", strategy_ps),
|
||||
strategy_ps);
|
||||
tester::apply("test_r2", "SEGMENT(21 10, 29 10)", box_north,
|
||||
ps_distance("POINT(21 10)", "SEGMENT(20 10, 20 20)", strategy_ps),
|
||||
ps_distance<Point>("POINT(21 10)", "SEGMENT(20 10, 20 20)", strategy_ps),
|
||||
strategy_ps);
|
||||
tester::apply("test_r3", "SEGMENT(21 10, 29 15)", box_north,
|
||||
ps_distance("POINT(21 10)", "SEGMENT(20 10, 20 20)", strategy_ps),
|
||||
ps_distance<Point>("POINT(21 10)", "SEGMENT(20 10, 20 20)", strategy_ps),
|
||||
strategy_ps);
|
||||
tester::apply("test_r4", "SEGMENT(21 10, 21 15)", box_north,
|
||||
ps_distance("POINT(21 15)", "SEGMENT(20 10, 20 20)", strategy_ps),
|
||||
ps_distance<Point>("POINT(21 15)", "SEGMENT(20 10, 20 20)", strategy_ps),
|
||||
strategy_ps);
|
||||
tester::apply("test_r5", "SEGMENT(21 10, 22 15)", box_north,
|
||||
ps_distance("POINT(21 10)", "SEGMENT(20 10, 20 20)", strategy_ps),
|
||||
ps_distance<Point>("POINT(21 10)", "SEGMENT(20 10, 20 20)", strategy_ps),
|
||||
strategy_ps);
|
||||
tester::apply("test_r6", "SEGMENT(29 20, 21 21)", box_north,
|
||||
ps_distance("POINT(21 21)", "SEGMENT(20 10, 20 20)", strategy_ps),
|
||||
ps_distance<Point>("POINT(21 21)", "SEGMENT(20 10, 20 20)", strategy_ps),
|
||||
strategy_ps);
|
||||
|
||||
//Segments on corners of box
|
||||
//left-top corner
|
||||
//generic
|
||||
tester::apply("test_c1", "SEGMENT(9 19.5, 11 21)", box_north,
|
||||
ps_distance("POINT(10 20)", "SEGMENT(9 19.5, 11 21)", strategy_ps),
|
||||
ps_distance<Point>("POINT(10 20)", "SEGMENT(9 19.5, 11 21)", strategy_ps),
|
||||
strategy_ps);
|
||||
//degenerate
|
||||
tester::apply("test_c2", "SEGMENT(9 19, 11 21)", box_north,
|
||||
ps_distance("POINT(10 20)", "SEGMENT(9 19, 11 21)", strategy_ps),
|
||||
ps_distance<Point>("POINT(10 20)", "SEGMENT(9 19, 11 21)", strategy_ps),
|
||||
strategy_ps);
|
||||
//left-bottom corner
|
||||
//generic
|
||||
tester::apply("test_c3", "SEGMENT(8.5 11, 11 9)", box_north,
|
||||
ps_distance("POINT(10 10)", "SEGMENT(8.5 11, 11 9)", strategy_ps),
|
||||
ps_distance<Point>("POINT(10 10)", "SEGMENT(8.5 11, 11 9)", strategy_ps),
|
||||
strategy_ps);
|
||||
//degenerate
|
||||
tester::apply("test_c4", "SEGMENT(9 11, 11 9)", box_north,
|
||||
@ -260,16 +401,16 @@ void test_distance_segment_box(Strategy_pp const& strategy_pp,
|
||||
//right-top corner
|
||||
//generic
|
||||
tester::apply("test_c5", "SEGMENT(19 21, 21 19.5)", box_north,
|
||||
ps_distance("POINT(20 20)", "SEGMENT(19 21, 21 19.5)", strategy_ps),
|
||||
ps_distance<Point>("POINT(20 20)", "SEGMENT(19 21, 21 19.5)", strategy_ps),
|
||||
strategy_ps);
|
||||
//degenerate
|
||||
tester::apply("test_c6", "SEGMENT(19 21, 21 19)", box_north,
|
||||
ps_distance("POINT(20 20)", "SEGMENT(19 21, 21 19)", strategy_ps),
|
||||
ps_distance<Point>("POINT(20 20)", "SEGMENT(19 21, 21 19)", strategy_ps),
|
||||
strategy_ps);
|
||||
//right-bottom corner
|
||||
//generic
|
||||
tester::apply("test_c7", "SEGMENT(19 9, 21 10.5)", box_north,
|
||||
ps_distance("POINT(20 10)", "SEGMENT(19 9, 21 10.5)", strategy_ps),
|
||||
ps_distance<Point>("POINT(20 10)", "SEGMENT(19 9, 21 10.5)", strategy_ps),
|
||||
strategy_ps);
|
||||
tester::apply("test_c7", "SEGMENT(19 9, 21 11)", box_north,
|
||||
0,
|
||||
@ -279,29 +420,29 @@ void test_distance_segment_box(Strategy_pp const& strategy_pp,
|
||||
std::string const box_south = "BOX(10 -20,20 -10)";
|
||||
|
||||
tester::apply("test_ns1", "SEGMENT(10 20, 15 30)", box_south,
|
||||
ps_distance("POINT(10 -10)", "SEGMENT(10 20, 15 30)", strategy_ps),
|
||||
ps_distance<Point>("POINT(10 -10)", "SEGMENT(10 20, 15 30)", strategy_ps),
|
||||
strategy_ps);
|
||||
tester::apply("test_ns2", "SEGMENT(0 10, 12 10)", box_south,
|
||||
pp_distance("POINT(12 10)", "POINT(12 -10)", strategy_pp),
|
||||
pp_distance<Point>("POINT(12 10)", "POINT(12 -10)", strategy_pp),
|
||||
strategy_ps);
|
||||
tester::apply("test_ns3", "SEGMENT(10 10, 20 10)", box_south,
|
||||
pp_distance("POINT(10 10)", "POINT(10 -10)", strategy_pp),
|
||||
pp_distance<Point>("POINT(10 10)", "POINT(10 -10)", strategy_pp),
|
||||
strategy_ps);
|
||||
tester::apply("test_ns4", "SEGMENT(0 -10, 12 -10)", box_north,
|
||||
pp_distance("POINT(12 10)", "POINT(12 -10)", strategy_pp),
|
||||
pp_distance<Point>("POINT(12 10)", "POINT(12 -10)", strategy_pp),
|
||||
strategy_ps);
|
||||
tester::apply("test_ns5", "SEGMENT(10 -10, 20 -10)", box_north,
|
||||
pp_distance("POINT(10 -10)", "POINT(10 10)", strategy_pp),
|
||||
pp_distance<Point>("POINT(10 -10)", "POINT(10 10)", strategy_pp),
|
||||
strategy_ps);
|
||||
|
||||
//Box crossing equator
|
||||
std::string const box_crossing_eq = "BOX(10 -10,20 10)";
|
||||
|
||||
tester::apply("test_cr1", "SEGMENT(10 20, 15 30)", box_crossing_eq,
|
||||
pp_distance("POINT(10 10)", "POINT(10 20)", strategy_pp),
|
||||
pp_distance<Point>("POINT(10 10)", "POINT(10 20)", strategy_pp),
|
||||
strategy_ps);
|
||||
tester::apply("test_cr2", "SEGMENT(10 -20, 15 -30)", box_crossing_eq,
|
||||
pp_distance("POINT(10 10)", "POINT(10 20)", strategy_pp),
|
||||
pp_distance<Point>("POINT(10 10)", "POINT(10 20)", strategy_pp),
|
||||
strategy_ps);
|
||||
|
||||
//Box crossing prime meridian
|
||||
@ -309,37 +450,37 @@ void test_distance_segment_box(Strategy_pp const& strategy_pp,
|
||||
std::string const box_crossing_mer = "BOX(-10 10,15 20)";
|
||||
|
||||
tester::apply("test_cr3", "SEGMENT(-5 25, 10 30)", box_crossing_mer,
|
||||
pp_distance("POINT(-5 25)", "POINT(-5 20)", strategy_pp),
|
||||
pp_distance<Point>("POINT(-5 25)", "POINT(-5 20)", strategy_pp),
|
||||
strategy_ps);
|
||||
tester::apply("test_cr4", "SEGMENT(-5 5, 10 7)", box_crossing_mer,
|
||||
pp_distance("POINT(10 7)", "POINT(10 10)", strategy_pp),
|
||||
pp_distance<Point>("POINT(10 7)", "POINT(10 10)", strategy_pp),
|
||||
strategy_ps);
|
||||
tester::apply("test_cr5", "SEGMENT(-5 5, 10 5)", box_crossing_mer,
|
||||
ps_distance("POINT(2.5 10)", "SEGMENT(-5 5, 10 5)", strategy_ps),
|
||||
ps_distance<Point>("POINT(2.5 10)", "SEGMENT(-5 5, 10 5)", strategy_ps),
|
||||
strategy_ps);
|
||||
|
||||
|
||||
//Geometries in south hemisphere
|
||||
tester::apply("test_south1", "SEGMENT(10 -30, 15 -30)", box_south,
|
||||
ps_distance("POINT(10 -20)", "SEGMENT(10 -30, 15 -30)", strategy_ps),
|
||||
ps_distance<Point>("POINT(10 -20)", "SEGMENT(10 -30, 15 -30)", strategy_ps),
|
||||
strategy_ps);
|
||||
|
||||
//Segments in boxes corner
|
||||
tester::apply("corner1", "SEGMENT(17 21, 25 20)", box_north,
|
||||
ps_distance("POINT(20 20)", "SEGMENT(17 21, 25 20)", strategy_ps),
|
||||
ps_distance<Point>("POINT(20 20)", "SEGMENT(17 21, 25 20)", strategy_ps),
|
||||
strategy_ps);
|
||||
tester::apply("corner2", "SEGMENT(17 21, 0 20)", box_north,
|
||||
ps_distance("POINT(10 20)", "SEGMENT(17 21, 0 20)", strategy_ps),
|
||||
ps_distance<Point>("POINT(10 20)", "SEGMENT(17 21, 0 20)", strategy_ps),
|
||||
strategy_ps);
|
||||
tester::apply("corner3", "SEGMENT(17 5, 0 10)", box_north,
|
||||
ps_distance("POINT(10 10)", "SEGMENT(17 5, 0 10)", strategy_ps),
|
||||
ps_distance<Point>("POINT(10 10)", "SEGMENT(17 5, 0 10)", strategy_ps),
|
||||
strategy_ps);
|
||||
tester::apply("corner4", "SEGMENT(17 5, 25 9)", box_north,
|
||||
ps_distance("POINT(20 10)", "SEGMENT(17 5, 25 9)", strategy_ps),
|
||||
ps_distance<Point>("POINT(20 10)", "SEGMENT(17 5, 25 9)", strategy_ps),
|
||||
strategy_ps);
|
||||
}
|
||||
|
||||
template <typename Strategy_ps>
|
||||
template <typename Point, typename Strategy_ps>
|
||||
void test_distance_linestring_box(Strategy_ps const& strategy_ps)
|
||||
{
|
||||
|
||||
@ -347,12 +488,14 @@ void test_distance_linestring_box(Strategy_ps const& strategy_ps)
|
||||
std::cout << std::endl;
|
||||
std::cout << "linestring/box distance tests" << std::endl;
|
||||
#endif
|
||||
typedef bg::model::linestring<Point> linestring_type;
|
||||
typedef bg::model::box<Point> box_type;
|
||||
typedef test_distance_of_geometries<linestring_type, box_type> tester;
|
||||
|
||||
std::string const box_north = "BOX(10 10,20 20)";
|
||||
|
||||
tester::apply("sl1", "LINESTRING(0 20, 15 21, 25 19.9, 21 5, 15 5, 0 10)", box_north,
|
||||
ps_distance("POINT(20 20)", "SEGMENT(15 21, 25 19.9)", strategy_ps),
|
||||
ps_distance<Point>("POINT(20 20)", "SEGMENT(15 21, 25 19.9)", strategy_ps),
|
||||
strategy_ps, true, false, false);
|
||||
|
||||
tester::apply("sl2", "LINESTRING(0 20, 15 21, 25 19.9, 21 5, 15 5, 15 15)", box_north,
|
||||
@ -362,7 +505,7 @@ void test_distance_linestring_box(Strategy_ps const& strategy_ps)
|
||||
0, strategy_ps, true, false, false);
|
||||
}
|
||||
|
||||
template <typename Strategy_ps>
|
||||
template <typename Point, typename Strategy_ps>
|
||||
void test_distance_multi_linestring_box(Strategy_ps const& strategy_ps)
|
||||
{
|
||||
|
||||
@ -370,31 +513,54 @@ void test_distance_multi_linestring_box(Strategy_ps const& strategy_ps)
|
||||
std::cout << std::endl;
|
||||
std::cout << "multi_linestring/box distance tests" << std::endl;
|
||||
#endif
|
||||
typedef bg::model::linestring<Point> linestring_type;
|
||||
typedef bg::model::multi_linestring<linestring_type> multi_linestring_type;
|
||||
typedef bg::model::box<Point> box_type;
|
||||
typedef test_distance_of_geometries<multi_linestring_type, box_type> tester;
|
||||
|
||||
std::string const box_north = "BOX(10 10,20 20)";
|
||||
|
||||
tester::apply("sl1", "MULTILINESTRING((0 20, 15 21, 25 19.9, 21 5, 15 5, 0 10)(25 20, 22 4, 0 0))", box_north,
|
||||
ps_distance("POINT(20 20)", "SEGMENT(15 21, 25 19.9)", strategy_ps),
|
||||
ps_distance<Point>("POINT(20 20)", "SEGMENT(15 21, 25 19.9)", strategy_ps),
|
||||
strategy_ps, true, false, false);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//===========================================================================
|
||||
//===========================================================================
|
||||
|
||||
//===========================================================================
|
||||
//===========================================================================
|
||||
//===========================================================================
|
||||
|
||||
template <typename Point, typename Strategy_pp, typename Strategy_ps>
|
||||
void test_all_l_ar(Strategy_pp pp_strategy, Strategy_ps ps_strategy)
|
||||
{
|
||||
test_distance_segment_polygon<Point>(pp_strategy, ps_strategy);
|
||||
test_distance_linestring_polygon<Point>(pp_strategy, ps_strategy);
|
||||
test_distance_multi_linestring_polygon<Point>(pp_strategy, ps_strategy);
|
||||
|
||||
test_distance_segment_multi_polygon<Point>(pp_strategy, ps_strategy);
|
||||
test_distance_linestring_multi_polygon<Point>(pp_strategy, ps_strategy);
|
||||
test_distance_multi_linestring_multi_polygon<Point>(pp_strategy, ps_strategy);
|
||||
|
||||
test_distance_segment_ring<Point>(pp_strategy, ps_strategy);
|
||||
test_distance_linestring_ring<Point>(pp_strategy, ps_strategy);
|
||||
test_distance_multi_linestring_ring<Point>(pp_strategy, ps_strategy);
|
||||
|
||||
test_distance_segment_box<Point>(pp_strategy, ps_strategy);
|
||||
test_distance_linestring_box<Point>(ps_strategy);
|
||||
test_distance_multi_linestring_box<Point>(ps_strategy);
|
||||
|
||||
test_more_empty_input_linear_areal<Point>(ps_strategy);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( test_all_linear_areal )
|
||||
{
|
||||
test_distance_segment_box(vincenty_pp(), vincenty_ps());
|
||||
test_distance_segment_box(thomas_pp(), thomas_ps());
|
||||
test_distance_segment_box(andoyer_pp(), andoyer_ps());
|
||||
typedef bg::model::point<double, 2, bg::cs::spherical_equatorial<bg::degree> >
|
||||
sph_point;
|
||||
test_all_l_ar<sph_point>(spherical_pp(), spherical_ps());
|
||||
|
||||
test_distance_linestring_box(vincenty_ps());
|
||||
test_distance_linestring_box(thomas_ps());
|
||||
test_distance_linestring_box(andoyer_ps());
|
||||
typedef bg::model::point<double, 2, bg::cs::geographic<bg::degree> > geo_point;
|
||||
|
||||
test_distance_multi_linestring_box(vincenty_ps());
|
||||
test_distance_multi_linestring_box(thomas_ps());
|
||||
test_distance_multi_linestring_box(andoyer_ps());
|
||||
test_all_l_ar<geo_point>(vincenty_pp(), vincenty_ps());
|
||||
test_all_l_ar<geo_point>(thomas_pp(), thomas_ps());
|
||||
test_all_l_ar<geo_point>(andoyer_pp(), andoyer_ps());
|
||||
}
|
||||
|
@ -227,6 +227,8 @@ void test_all_l_l(Strategy ps_strategy)
|
||||
test_distance_segment_multilinestring<Point>(ps_strategy);
|
||||
test_distance_linestring_multilinestring<Point>(ps_strategy);
|
||||
test_distance_multilinestring_multilinestring<Point>(ps_strategy);
|
||||
|
||||
test_more_empty_input_linear_linear<Point>(ps_strategy);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( test_all_linear_linear )
|
||||
@ -234,14 +236,9 @@ BOOST_AUTO_TEST_CASE( test_all_linear_linear )
|
||||
typedef bg::model::point<double, 2, bg::cs::spherical_equatorial<bg::degree> >
|
||||
sph_point;
|
||||
test_all_l_l<sph_point>(spherical_ps());
|
||||
test_more_empty_input_linear_linear<sph_point>(spherical_ps());
|
||||
|
||||
typedef bg::model::point<double, 2, bg::cs::geographic<bg::degree> > geo_point;
|
||||
test_all_l_l<geo_point>(vincenty_ps());
|
||||
test_all_l_l<geo_point>(thomas_ps());
|
||||
test_all_l_l<geo_point>(andoyer_ps());
|
||||
|
||||
test_more_empty_input_linear_linear<geo_point>(vincenty_ps());
|
||||
test_more_empty_input_linear_linear<geo_point>(thomas_ps());
|
||||
test_more_empty_input_linear_linear<geo_point>(andoyer_ps());
|
||||
}
|
||||
|
@ -26,27 +26,6 @@ typedef bg::model::segment<point_type> segment_type;
|
||||
typedef bg::model::linestring<point_type> linestring_type;
|
||||
typedef bg::model::multi_linestring<linestring_type> multi_linestring_type;
|
||||
|
||||
namespace services = bg::strategy::distance::services;
|
||||
typedef bg::default_distance_result<point_type>::type return_type;
|
||||
|
||||
typedef bg::srs::spheroid<double> stype;
|
||||
|
||||
// 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_strategy;
|
||||
|
||||
typedef bg::strategy::distance::geographic_cross_track<bg::strategy::thomas, stype, double>
|
||||
thomas_strategy;
|
||||
|
||||
typedef bg::strategy::distance::geographic_cross_track<bg::strategy::vincenty, stype, double>
|
||||
vincenty_strategy;
|
||||
|
||||
//===========================================================================
|
||||
|
||||
@ -449,25 +428,25 @@ void test_distance_point_linestring_strategies()
|
||||
{
|
||||
typedef test_distance_of_geometries<point_type, linestring_type> tester;
|
||||
|
||||
tester::apply("p-l-03",
|
||||
tester::apply("p-l-s-01",
|
||||
"POINT(2.5 3)",
|
||||
"LINESTRING(2 1,3 1)",
|
||||
221147.24332788656,
|
||||
vincenty_strategy(),
|
||||
vincenty_ps(),
|
||||
true, false, false);
|
||||
|
||||
tester::apply("p-l-03",
|
||||
tester::apply("p-l-s-02",
|
||||
"POINT(2.5 3)",
|
||||
"LINESTRING(2 1,3 1)",
|
||||
221147.36682199029,
|
||||
thomas_strategy(),
|
||||
thomas_ps(),
|
||||
true, false, false);
|
||||
|
||||
tester::apply("p-l-03",
|
||||
tester::apply("p-l-s-03",
|
||||
"POINT(2.5 3)",
|
||||
"LINESTRING(2 1,3 1)",
|
||||
221144.76527049288,
|
||||
andoyer_strategy(),
|
||||
andoyer_ps(),
|
||||
true, false, false);
|
||||
}
|
||||
|
||||
@ -644,39 +623,26 @@ void test_distance_multipoint_segment(Strategy_pp const& strategy_pp,
|
||||
//===========================================================================
|
||||
//===========================================================================
|
||||
|
||||
template <typename Strategy_pp, typename Strategy_ps>
|
||||
void test_all_pl_l(Strategy_pp pp_strategy, Strategy_ps ps_strategy)
|
||||
{
|
||||
test_distance_point_segment(pp_strategy, ps_strategy);
|
||||
test_distance_point_linestring(pp_strategy, ps_strategy);
|
||||
test_distance_point_multilinestring(pp_strategy, ps_strategy);
|
||||
test_distance_linestring_multipoint(pp_strategy, ps_strategy);
|
||||
test_distance_multipoint_multilinestring(pp_strategy, ps_strategy);
|
||||
test_distance_multipoint_segment(pp_strategy, ps_strategy);
|
||||
|
||||
test_more_empty_input_pointlike_linear<point_type>(ps_strategy);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( test_all_pointlike_linear )
|
||||
{
|
||||
test_distance_point_segment(vincenty_pp(), vincenty_strategy());
|
||||
test_distance_point_segment(thomas_pp(), thomas_strategy());
|
||||
test_distance_point_segment(andoyer_pp(), andoyer_strategy());
|
||||
|
||||
test_distance_point_segment_no_thomas(vincenty_pp(), vincenty_strategy());
|
||||
//test_distance_point_segment_no_thomas(thomas_pp(), thomas_strategy());
|
||||
test_distance_point_segment_no_thomas(andoyer_pp(), andoyer_strategy());
|
||||
|
||||
test_distance_point_linestring(vincenty_pp(), vincenty_strategy());
|
||||
test_distance_point_linestring(thomas_pp(), thomas_strategy());
|
||||
test_distance_point_linestring(andoyer_pp(), andoyer_strategy());
|
||||
test_distance_point_linestring_strategies();
|
||||
|
||||
test_distance_point_multilinestring(vincenty_pp(), vincenty_strategy());
|
||||
test_distance_point_multilinestring(thomas_pp(), thomas_strategy());
|
||||
test_distance_point_multilinestring(andoyer_pp(), andoyer_strategy());
|
||||
|
||||
test_distance_linestring_multipoint(vincenty_pp(), vincenty_strategy());
|
||||
test_distance_linestring_multipoint(thomas_pp(), thomas_strategy());
|
||||
test_distance_linestring_multipoint(andoyer_pp(), andoyer_strategy());
|
||||
|
||||
test_distance_multipoint_multilinestring(vincenty_pp(), vincenty_strategy());
|
||||
test_distance_multipoint_multilinestring(thomas_pp(), thomas_strategy());
|
||||
test_distance_multipoint_multilinestring(andoyer_pp(), andoyer_strategy());
|
||||
|
||||
test_distance_multipoint_segment(vincenty_pp(), vincenty_strategy());
|
||||
test_distance_multipoint_segment(thomas_pp(), thomas_strategy());
|
||||
test_distance_multipoint_segment(andoyer_pp(), andoyer_strategy());
|
||||
|
||||
test_more_empty_input_pointlike_linear<point_type>(vincenty_strategy());
|
||||
test_more_empty_input_pointlike_linear<point_type>(thomas_strategy());
|
||||
test_more_empty_input_pointlike_linear<point_type>(andoyer_strategy());
|
||||
test_all_pl_l(vincenty_pp(), vincenty_ps());
|
||||
test_all_pl_l(thomas_pp(), thomas_ps());
|
||||
test_all_pl_l(andoyer_pp(), andoyer_ps());
|
||||
|
||||
test_distance_point_segment_no_thomas(vincenty_pp(), vincenty_ps());
|
||||
//test_distance_point_segment_no_thomas(thomas_pp(), thomas_ps());
|
||||
test_distance_point_segment_no_thomas(andoyer_pp(), andoyer_ps());
|
||||
}
|
||||
|
@ -94,22 +94,18 @@ void test_all_pl_pl(Strategy pp_strategy)
|
||||
test_distance_point_point<Point>(pp_strategy);
|
||||
test_distance_multipoint_point<Point>(pp_strategy);
|
||||
test_distance_multipoint_multipoint<Point>(pp_strategy);
|
||||
|
||||
test_more_empty_input_pointlike_pointlike<Point>(pp_strategy);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( test_all_pointlike_pointlike )
|
||||
{
|
||||
typedef bg::model::point<double, 2, bg::cs::spherical_equatorial<bg::degree> >
|
||||
sph_point;
|
||||
test_all_pl_pl<sph_point>(haversine());
|
||||
|
||||
test_more_empty_input_pointlike_pointlike<sph_point>(haversine());
|
||||
test_all_pl_pl<sph_point>(spherical_pp());
|
||||
|
||||
typedef bg::model::point<double, 2, bg::cs::geographic<bg::degree> > geo_point;
|
||||
test_all_pl_pl<geo_point>(vincenty());
|
||||
test_all_pl_pl<geo_point>(thomas());
|
||||
test_all_pl_pl<geo_point>(andoyer());
|
||||
|
||||
test_more_empty_input_pointlike_pointlike<geo_point>(vincenty());
|
||||
test_more_empty_input_pointlike_pointlike<geo_point>(thomas());
|
||||
test_more_empty_input_pointlike_pointlike<geo_point>(andoyer());
|
||||
test_all_pl_pl<geo_point>(vincenty_pp());
|
||||
test_all_pl_pl<geo_point>(thomas_pp());
|
||||
test_all_pl_pl<geo_point>(andoyer_pp());
|
||||
}
|
||||
|
@ -48,13 +48,13 @@ typedef bg::srs::spheroid<double> stype;
|
||||
|
||||
// Spherical strategy for point-point distance
|
||||
|
||||
typedef bg::strategy::distance::haversine<double> haversine;
|
||||
typedef bg::strategy::distance::haversine<double> spherical_pp;
|
||||
|
||||
// Geo strategies for point-point distance
|
||||
|
||||
typedef bg::strategy::distance::andoyer<stype> andoyer;
|
||||
typedef bg::strategy::distance::thomas<stype> thomas;
|
||||
typedef bg::strategy::distance::vincenty<stype> vincenty;
|
||||
typedef bg::strategy::distance::andoyer<stype> andoyer_pp;
|
||||
typedef bg::strategy::distance::thomas<stype> thomas_pp;
|
||||
typedef bg::strategy::distance::vincenty<stype> vincenty_pp;
|
||||
|
||||
// Spherical strategy for point-segment distance
|
||||
|
||||
|
@ -49,12 +49,13 @@ void test_more_empty_input_pointlike_linear(Strategy const& strategy)
|
||||
|
||||
Point point = from_wkt<Point>("POINT(0 0)");
|
||||
bg::model::linestring<Point> line =
|
||||
from_wkt<bg::model::linestring<Point> >("LINESTRING(0 0,1 1)");
|
||||
from_wkt<bg::model::linestring<Point> >("LINESTRING(0 0,1 1,2 2)");
|
||||
|
||||
// 1st geometry is empty
|
||||
test_empty_input(multipoint_empty, line, strategy);
|
||||
|
||||
// 2nd geometry is empty
|
||||
test_empty_input(line, multipoint_empty, strategy);
|
||||
test_empty_input(point, line_empty, strategy);
|
||||
test_empty_input(point, multiline_empty, strategy);
|
||||
|
||||
@ -98,4 +99,45 @@ void test_more_empty_input_linear_linear(Strategy const& strategy)
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename Point, typename Strategy>
|
||||
void test_more_empty_input_linear_areal(Strategy const& strategy)
|
||||
{
|
||||
#ifdef BOOST_GEOMETRY_TEST_DEBUG
|
||||
std::cout << std::endl;
|
||||
std::cout << "testing on empty inputs... " << std::flush;
|
||||
#endif
|
||||
bg::model::linestring<Point> line_empty;
|
||||
bg::model::multi_linestring<bg::model::linestring<Point> > multiline_empty;
|
||||
|
||||
bg::model::polygon<Point> polygon_empty;
|
||||
bg::model::multi_polygon<bg::model::polygon<Point> > multipolygon_empty;
|
||||
|
||||
bg::model::linestring<Point> line =
|
||||
from_wkt<bg::model::linestring<Point> >("LINESTRING(0 0,1 1)");
|
||||
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(line_empty, polygon, strategy);
|
||||
test_empty_input(multiline_empty, polygon, strategy);
|
||||
test_empty_input(polygon_empty, line, strategy);
|
||||
test_empty_input(multipolygon_empty, line, strategy);
|
||||
|
||||
// 2nd geometry is empty
|
||||
test_empty_input(line, polygon_empty, strategy);
|
||||
test_empty_input(line, multipolygon_empty, strategy);
|
||||
test_empty_input(polygon, line_empty, strategy);
|
||||
test_empty_input(polygon, multiline_empty, strategy);
|
||||
|
||||
// both geometries are empty
|
||||
test_empty_input(line_empty, polygon_empty, strategy);
|
||||
test_empty_input(line_empty, multipolygon_empty, strategy);
|
||||
test_empty_input(multiline_empty, polygon_empty, strategy);
|
||||
test_empty_input(multiline_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