]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // Boost.Geometry (aka GGL, Generic Geometry Library) |
2 | ||
1e59de90 | 3 | // Copyright (c) 2014-2021, Oracle and/or its affiliates. |
7c673cae FG |
4 | |
5 | // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle | |
1e59de90 | 6 | // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle |
7c673cae FG |
7 | |
8 | // Licensed under the Boost Software License version 1.0. | |
9 | // http://www.boost.org/users/license.html | |
10 | ||
11 | #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_LINEAR_TO_LINEAR_HPP | |
12 | #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_LINEAR_TO_LINEAR_HPP | |
13 | ||
1e59de90 TL |
14 | #include <boost/geometry/algorithms/detail/distance/range_to_geometry_rtree.hpp> |
15 | #include <boost/geometry/algorithms/detail/distance/strategy_utils.hpp> | |
16 | #include <boost/geometry/algorithms/dispatch/distance.hpp> | |
17 | #include <boost/geometry/algorithms/num_points.hpp> | |
18 | #include <boost/geometry/algorithms/num_segments.hpp> | |
7c673cae | 19 | |
1e59de90 | 20 | #include <boost/geometry/core/point_type.hpp> |
7c673cae FG |
21 | |
22 | #include <boost/geometry/iterators/point_iterator.hpp> | |
23 | #include <boost/geometry/iterators/segment_iterator.hpp> | |
24 | ||
1e59de90 | 25 | #include <boost/geometry/strategies/distance.hpp> |
7c673cae FG |
26 | |
27 | ||
28 | namespace boost { namespace geometry | |
29 | { | |
30 | ||
31 | #ifndef DOXYGEN_NO_DETAIL | |
32 | namespace detail { namespace distance | |
33 | { | |
34 | ||
35 | ||
1e59de90 | 36 | template <typename Linear1, typename Linear2, typename Strategies> |
7c673cae FG |
37 | struct linear_to_linear |
38 | { | |
1e59de90 | 39 | typedef distance::return_t<Linear1, Linear2, Strategies> return_type; |
7c673cae FG |
40 | |
41 | static inline return_type apply(Linear1 const& linear1, | |
42 | Linear2 const& linear2, | |
1e59de90 | 43 | Strategies const& strategies, |
7c673cae FG |
44 | bool = false) |
45 | { | |
46 | if (geometry::num_points(linear1) == 1) | |
47 | { | |
48 | return dispatch::distance | |
49 | < | |
50 | typename point_type<Linear1>::type, | |
51 | Linear2, | |
1e59de90 TL |
52 | Strategies |
53 | >::apply(*points_begin(linear1), linear2, strategies); | |
7c673cae FG |
54 | } |
55 | ||
56 | if (geometry::num_points(linear2) == 1) | |
57 | { | |
58 | return dispatch::distance | |
59 | < | |
60 | typename point_type<Linear2>::type, | |
61 | Linear1, | |
1e59de90 TL |
62 | Strategies |
63 | >::apply(*points_begin(linear2), linear1, strategies); | |
7c673cae FG |
64 | } |
65 | ||
66 | if (geometry::num_segments(linear2) < geometry::num_segments(linear1)) | |
67 | { | |
68 | return point_or_segment_range_to_geometry_rtree | |
69 | < | |
70 | geometry::segment_iterator<Linear2 const>, | |
71 | Linear1, | |
1e59de90 | 72 | Strategies |
7c673cae FG |
73 | >::apply(geometry::segments_begin(linear2), |
74 | geometry::segments_end(linear2), | |
75 | linear1, | |
1e59de90 | 76 | strategies); |
7c673cae FG |
77 | |
78 | } | |
79 | ||
80 | return point_or_segment_range_to_geometry_rtree | |
81 | < | |
82 | geometry::segment_iterator<Linear1 const>, | |
83 | Linear2, | |
1e59de90 | 84 | Strategies |
7c673cae FG |
85 | >::apply(geometry::segments_begin(linear1), |
86 | geometry::segments_end(linear1), | |
87 | linear2, | |
1e59de90 | 88 | strategies); |
7c673cae FG |
89 | } |
90 | }; | |
91 | ||
92 | ||
93 | }} // namespace detail::distance | |
94 | #endif // DOXYGEN_NO_DETAIL | |
95 | ||
96 | ||
97 | #ifndef DOXYGEN_NO_DISPATCH | |
98 | namespace dispatch | |
99 | { | |
100 | ||
1e59de90 | 101 | template <typename Linear1, typename Linear2, typename Strategy, typename StrategyTag> |
7c673cae FG |
102 | struct distance |
103 | < | |
104 | Linear1, Linear2, Strategy, | |
105 | linear_tag, linear_tag, | |
1e59de90 | 106 | StrategyTag, false |
7c673cae FG |
107 | > : detail::distance::linear_to_linear |
108 | < | |
109 | Linear1, Linear2, Strategy | |
110 | > | |
111 | {}; | |
112 | ||
113 | } // namespace dispatch | |
114 | #endif // DOXYGEN_NO_DISPATCH | |
115 | ||
116 | }} // namespace boost::geometry | |
117 | ||
118 | #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_LINEAR_TO_LINEAR_HPP |