[closest_points] Support cartesian segment-linear/areal case and tests

This commit is contained in:
Vissarion Fisikopoulos
2021-11-02 16:35:07 +02:00
parent 12108b1620
commit e668c8ec27
4 changed files with 140 additions and 7 deletions

View File

@@ -349,7 +349,7 @@ public:
#ifndef DOXYGEN_NO_DISPATCH
namespace dispatch
{
/*
template <typename Linear, typename Segment>
struct closest_points
<
@@ -358,7 +358,7 @@ struct closest_points
false
> : detail::closest_points::geometry_to_segment_or_box<Linear, Segment>
{};
*/
/*
template <typename Areal, typename Segment, typename Strategy>
struct distance

View File

@@ -98,8 +98,8 @@ struct linear_to_areal
return;
}
// if there are no intersection points then the linear geometry (or part of it)
// is inside the areal; return any point of this part
// if there are no intersection points then check if the linear geometry
// (or part of it) is inside the areal and return any point of this part
geometry::model::multi_linestring<linestring_type> ln_out;
geometry::intersection(linear, areal, ln_out, strategies);
@@ -130,6 +130,37 @@ struct areal_to_linear
};
struct segment_to_areal
{
template <typename Segment, typename Areal, typename OutSegment, typename Strategies>
static inline void apply(Segment const& segment,
Areal const& areal,
OutSegment& shortest_seg,
Strategies const& strategies,
bool = false)
{
using linestring_type = geometry::model::linestring<typename point_type<Segment>::type>;
linestring_type linestring;
convert(segment, linestring);
return linear_to_areal::apply(linestring, areal, shortest_seg, strategies);
}
};
struct areal_to_segment
{
template <typename Areal, typename Segment, typename OutSegment, typename Strategies>
static inline void apply(Areal const& areal,
Segment const& segment,
OutSegment& shortest_seg,
Strategies const& strategies,
bool = false)
{
segment_to_areal::apply(segment, areal, shortest_seg, strategies);
detail::closest_points::swap_segment_points::apply(shortest_seg);
return;
}
};
struct areal_to_areal
{
template <typename Areal1, typename Areal2, typename Segment, typename Strategies>
@@ -210,7 +241,7 @@ template <typename Linear, typename Areal>
struct closest_points
<
Linear, Areal,
linear_tag, areal_tag,
linear_tag, areal_tag,
false
>
: detail::closest_points::linear_to_areal
@@ -226,6 +257,26 @@ struct closest_points
: detail::closest_points::areal_to_linear
{};
template <typename Segment, typename Areal>
struct closest_points
<
Segment, Areal,
segment_tag, areal_tag,
false
>
: detail::closest_points::segment_to_areal
{};
template <typename Areal, typename Segment>
struct closest_points
<
Areal, Segment,
areal_tag, segment_tag,
false
>
: detail::closest_points::areal_to_segment
{};
template <typename Areal1, typename Areal2>
struct closest_points
<

View File

@@ -84,6 +84,70 @@ struct linear_to_linear
}
};
struct segment_to_linear
{
template <typename Segment, typename Linear, typename OutSegment, typename Strategies>
static inline void apply(Segment const& segment,
Linear const& linear,
OutSegment& shortest_seg,
Strategies const& strategies,
bool = false)
{
using linestring_type = geometry::model::linestring<typename point_type<Segment>::type>;
linestring_type linestring;
convert(segment, linestring);
return linear_to_linear::apply(linestring, linear, shortest_seg, strategies);
/*
if (geometry::num_points(segment) == 1)
{
using segment_point_type = typename point_type<Segment>::type;
segment_point_type point;
detail::assign_point_from_index<0>(segment, point);
dispatch::closest_points
<
segment_point_type,
Segment
>::apply(point, linear, shortest_seg, strategies);
return;
}
if (geometry::num_points(linear) == 1)
{
dispatch::closest_points
<
typename point_type<Linear>::type,
Segment
>::apply(*points_begin(linear), segment, shortest_seg, strategies);
detail::closest_points::swap_segment_points::apply(shortest_seg);
return;
}
point_or_segment_range_to_geometry_rtree::apply(
geometry::segments_begin(linear),
geometry::segments_end(linear),
segment,
shortest_seg,
strategies);
detail::closest_points::swap_segment_points::apply(shortest_seg);
return;
*/
}
};
struct linear_to_segment
{
template <typename Linear, typename Segment, typename OutSegment, typename Strategies>
static inline void apply(Linear const& linear,
Segment const& segment,
OutSegment& shortest_seg,
Strategies const& strategies,
bool = false)
{
segment_to_linear::apply(segment, linear, shortest_seg, strategies);
detail::closest_points::swap_segment_points::apply(shortest_seg);
return;
}
};
}} // namespace detail::closest_points
#endif // DOXYGEN_NO_DETAIL
@@ -102,6 +166,24 @@ struct closest_points
> : detail::closest_points::linear_to_linear
{};
template <typename Segment, typename Linear>
struct closest_points
<
Segment, Linear,
segment_tag, linear_tag,
false
> : detail::closest_points::segment_to_linear
{};
template <typename Linear, typename Segment>
struct closest_points
<
Linear, Segment,
linear_tag, segment_tag,
false
> : detail::closest_points::linear_to_segment
{};
} // namespace dispatch
#endif // DOXYGEN_NO_DISPATCH