File indexing completed on 2025-01-18 09:35:04
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_LINEAR_TO_LINEAR_HPP
0012 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_LINEAR_TO_LINEAR_HPP
0013
0014 #include <boost/geometry/algorithms/detail/distance/range_to_geometry_rtree.hpp>
0015 #include <boost/geometry/algorithms/detail/distance/strategy_utils.hpp>
0016 #include <boost/geometry/algorithms/dispatch/distance.hpp>
0017 #include <boost/geometry/algorithms/num_points.hpp>
0018 #include <boost/geometry/algorithms/num_segments.hpp>
0019
0020 #include <boost/geometry/core/point_type.hpp>
0021
0022 #include <boost/geometry/iterators/point_iterator.hpp>
0023 #include <boost/geometry/iterators/segment_iterator.hpp>
0024
0025 #include <boost/geometry/strategies/distance.hpp>
0026
0027
0028 namespace boost { namespace geometry
0029 {
0030
0031 #ifndef DOXYGEN_NO_DETAIL
0032 namespace detail { namespace distance
0033 {
0034
0035
0036 template <typename Linear1, typename Linear2, typename Strategies>
0037 struct linear_to_linear
0038 {
0039 typedef distance::return_t<Linear1, Linear2, Strategies> return_type;
0040
0041 static inline return_type apply(Linear1 const& linear1,
0042 Linear2 const& linear2,
0043 Strategies const& strategies,
0044 bool = false)
0045 {
0046 if (geometry::num_points(linear1) == 1)
0047 {
0048 return dispatch::distance
0049 <
0050 typename point_type<Linear1>::type,
0051 Linear2,
0052 Strategies
0053 >::apply(*points_begin(linear1), linear2, strategies);
0054 }
0055
0056 if (geometry::num_points(linear2) == 1)
0057 {
0058 return dispatch::distance
0059 <
0060 typename point_type<Linear2>::type,
0061 Linear1,
0062 Strategies
0063 >::apply(*points_begin(linear2), linear1, strategies);
0064 }
0065
0066 if (geometry::num_segments(linear2) < geometry::num_segments(linear1))
0067 {
0068 return point_or_segment_range_to_geometry_rtree
0069 <
0070 geometry::segment_iterator<Linear2 const>,
0071 Linear1,
0072 Strategies
0073 >::apply(geometry::segments_begin(linear2),
0074 geometry::segments_end(linear2),
0075 linear1,
0076 strategies);
0077
0078 }
0079
0080 return point_or_segment_range_to_geometry_rtree
0081 <
0082 geometry::segment_iterator<Linear1 const>,
0083 Linear2,
0084 Strategies
0085 >::apply(geometry::segments_begin(linear1),
0086 geometry::segments_end(linear1),
0087 linear2,
0088 strategies);
0089 }
0090 };
0091
0092
0093 }}
0094 #endif
0095
0096
0097 #ifndef DOXYGEN_NO_DISPATCH
0098 namespace dispatch
0099 {
0100
0101 template <typename Linear1, typename Linear2, typename Strategy, typename StrategyTag>
0102 struct distance
0103 <
0104 Linear1, Linear2, Strategy,
0105 linear_tag, linear_tag,
0106 StrategyTag, false
0107 > : detail::distance::linear_to_linear
0108 <
0109 Linear1, Linear2, Strategy
0110 >
0111 {};
0112
0113 }
0114 #endif
0115
0116 }}
0117
0118 #endif