1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2014, Oracle and/or its affiliates.
5 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
7 // Licensed under the Boost Software License version 1.0.
8 // http://www.boost.org/users/license.html
10 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_LINEAR_TO_LINEAR_HPP
11 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_LINEAR_TO_LINEAR_HPP
13 #include <boost/geometry/core/point_type.hpp>
15 #include <boost/geometry/strategies/distance.hpp>
17 #include <boost/geometry/iterators/point_iterator.hpp>
18 #include <boost/geometry/iterators/segment_iterator.hpp>
20 #include <boost/geometry/algorithms/num_points.hpp>
21 #include <boost/geometry/algorithms/num_segments.hpp>
23 #include <boost/geometry/algorithms/dispatch/distance.hpp>
25 #include <boost/geometry/algorithms/detail/distance/range_to_geometry_rtree.hpp>
28 namespace boost { namespace geometry
31 #ifndef DOXYGEN_NO_DETAIL
32 namespace detail { namespace distance
36 template <typename Linear1, typename Linear2, typename Strategy>
37 struct linear_to_linear
39 typedef typename strategy::distance::services::return_type
42 typename point_type<Linear1>::type,
43 typename point_type<Linear2>::type
46 static inline return_type apply(Linear1 const& linear1,
47 Linear2 const& linear2,
48 Strategy const& strategy,
51 if (geometry::num_points(linear1) == 1)
53 return dispatch::distance
55 typename point_type<Linear1>::type,
58 >::apply(*points_begin(linear1), linear2, strategy);
61 if (geometry::num_points(linear2) == 1)
63 return dispatch::distance
65 typename point_type<Linear2>::type,
68 >::apply(*points_begin(linear2), linear1, strategy);
71 if (geometry::num_segments(linear2) < geometry::num_segments(linear1))
73 return point_or_segment_range_to_geometry_rtree
75 geometry::segment_iterator<Linear2 const>,
78 >::apply(geometry::segments_begin(linear2),
79 geometry::segments_end(linear2),
85 return point_or_segment_range_to_geometry_rtree
87 geometry::segment_iterator<Linear1 const>,
90 >::apply(geometry::segments_begin(linear1),
91 geometry::segments_end(linear1),
98 }} // namespace detail::distance
99 #endif // DOXYGEN_NO_DETAIL
102 #ifndef DOXYGEN_NO_DISPATCH
106 template <typename Linear1, typename Linear2, typename Strategy>
109 Linear1, Linear2, Strategy,
110 linear_tag, linear_tag,
111 strategy_tag_distance_point_segment, false
112 > : detail::distance::linear_to_linear
114 Linear1, Linear2, Strategy
118 } // namespace dispatch
119 #endif // DOXYGEN_NO_DISPATCH
121 }} // namespace boost::geometry
123 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_LINEAR_TO_LINEAR_HPP