]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/geometry/algorithms/detail/closest_points/linear_to_linear.hpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / boost / geometry / algorithms / detail / closest_points / linear_to_linear.hpp
CommitLineData
1e59de90
TL
1// Boost.Geometry
2
3// Copyright (c) 2021, Oracle and/or its affiliates.
4
5// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
6
7// Licensed under the Boost Software License version 1.0.
8// http://www.boost.org/users/license.html
9
10#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_CLOSEST_POINTS_LINEAR_TO_LINEAR_HPP
11#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_CLOSEST_POINTS_LINEAR_TO_LINEAR_HPP
12
13#include <boost/geometry/algorithms/detail/closest_points/range_to_geometry_rtree.hpp>
14#include <boost/geometry/algorithms/detail/closest_points/utilities.hpp>
15
16#include <boost/geometry/algorithms/num_points.hpp>
17#include <boost/geometry/algorithms/num_segments.hpp>
18
19#include <boost/geometry/core/point_type.hpp>
20
21#include <boost/geometry/iterators/point_iterator.hpp>
22#include <boost/geometry/iterators/segment_iterator.hpp>
23
24
25namespace boost { namespace geometry
26{
27
28#ifndef DOXYGEN_NO_DETAIL
29namespace detail { namespace closest_points
30{
31
32
33struct linear_to_linear
34{
35 template <typename Linear1, typename Linear2, typename Segment, typename Strategies>
36 static inline void apply(Linear1 const& linear1,
37 Linear2 const& linear2,
38 Segment& shortest_seg,
39 Strategies const& strategies,
40 bool = false)
41 {
42 if (geometry::num_points(linear1) == 1)
43 {
44 dispatch::closest_points
45 <
46 typename point_type<Linear1>::type,
47 Linear2
48 >::apply(*points_begin(linear1), linear2, shortest_seg, strategies);
49 return;
50 }
51
52 if (geometry::num_points(linear2) == 1)
53 {
54 dispatch::closest_points
55 <
56 typename point_type<Linear2>::type,
57 Linear1
58 >::apply(*points_begin(linear2), linear1, shortest_seg, strategies);
59 detail::closest_points::swap_segment_points::apply(shortest_seg);
60 return;
61 }
62
63 if (geometry::num_segments(linear1) < geometry::num_segments(linear2))
64 {
65 point_or_segment_range_to_geometry_rtree::apply(
66 geometry::segments_begin(linear2),
67 geometry::segments_end(linear2),
68 linear1,
69 shortest_seg,
70 strategies);
71 detail::closest_points::swap_segment_points::apply(shortest_seg);
72 return;
73 }
74
75 point_or_segment_range_to_geometry_rtree::apply(
76 geometry::segments_begin(linear1),
77 geometry::segments_end(linear1),
78 linear2,
79 shortest_seg,
80 strategies);
81 }
82};
83
84struct segment_to_linear
85{
86 template <typename Segment, typename Linear, typename OutSegment, typename Strategies>
87 static inline void apply(Segment const& segment,
88 Linear const& linear,
89 OutSegment& shortest_seg,
90 Strategies const& strategies,
91 bool = false)
92 {
93 using linestring_type = geometry::model::linestring
94 <typename point_type<Segment>::type>;
95 linestring_type linestring;
96 convert(segment, linestring);
97 linear_to_linear::apply(linestring, linear, shortest_seg, strategies);
98 }
99};
100
101struct linear_to_segment
102{
103 template <typename Linear, typename Segment, typename OutSegment, typename Strategies>
104 static inline void apply(Linear const& linear,
105 Segment const& segment,
106 OutSegment& shortest_seg,
107 Strategies const& strategies,
108 bool = false)
109 {
110 segment_to_linear::apply(segment, linear, shortest_seg, strategies);
111 detail::closest_points::swap_segment_points::apply(shortest_seg);
112 }
113};
114
115}} // namespace detail::closest_points
116#endif // DOXYGEN_NO_DETAIL
117
118
119#ifndef DOXYGEN_NO_DISPATCH
120namespace dispatch
121{
122
123template <typename Linear1, typename Linear2>
124struct closest_points
125 <
126 Linear1, Linear2,
127 linear_tag, linear_tag,
128 false
129 > : detail::closest_points::linear_to_linear
130{};
131
132template <typename Segment, typename Linear>
133struct closest_points
134 <
135 Segment, Linear,
136 segment_tag, linear_tag,
137 false
138 > : detail::closest_points::segment_to_linear
139{};
140
141template <typename Linear, typename Segment>
142struct closest_points
143 <
144 Linear, Segment,
145 linear_tag, segment_tag,
146 false
147 > : detail::closest_points::linear_to_segment
148{};
149
150} // namespace dispatch
151#endif // DOXYGEN_NO_DISPATCH
152
153}} // namespace boost::geometry
154
155#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_CLOSEST_POINTS_LINEAR_TO_LINEAR_HPP