]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/strategies/geographic/distance_cross_track_box_box.hpp
bump version to 18.2.4-pve3
[ceph.git] / ceph / src / boost / boost / geometry / strategies / geographic / distance_cross_track_box_box.hpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2
3 // Copyright (c) 2017-2021, Oracle and/or its affiliates.
4
5 // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
6 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
7
8 // Use, modification and distribution is subject to the Boost Software License,
9 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
10 // http://www.boost.org/LICENSE_1_0.txt)
11
12 #ifndef BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_DISTANCE_CROSS_TRACK_BOX_BOX_HPP
13 #define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_DISTANCE_CROSS_TRACK_BOX_BOX_HPP
14
15 #include <boost/config.hpp>
16 #include <boost/concept_check.hpp>
17
18 #include <boost/geometry/core/access.hpp>
19 #include <boost/geometry/core/assert.hpp>
20 #include <boost/geometry/core/point_type.hpp>
21 #include <boost/geometry/core/radian_access.hpp>
22 #include <boost/geometry/core/tags.hpp>
23
24 #include <boost/geometry/strategies/distance.hpp>
25 #include <boost/geometry/strategies/concepts/distance_concept.hpp>
26 #include <boost/geometry/strategies/geographic/distance.hpp>
27 #include <boost/geometry/strategies/geographic/distance_cross_track.hpp>
28 #include <boost/geometry/strategies/spherical/distance_cross_track.hpp>
29 #include <boost/geometry/strategies/spherical/distance_cross_track_box_box.hpp>
30
31 #include <boost/geometry/util/math.hpp>
32 #include <boost/geometry/algorithms/detail/assign_box_corners.hpp>
33
34
35 namespace boost { namespace geometry
36 {
37
38 namespace strategy { namespace distance
39 {
40
41
42 /*!
43 \brief Strategy functor for distance point to box calculation
44 \ingroup strategies
45 \details Class which calculates the distance of a point to a box, for
46 points and boxes on a sphere or globe
47 \tparam CalculationType \tparam_calculation
48 \tparam Strategy underlying point-segment distance strategy, defaults
49 to cross track
50 \qbk{
51 [heading See also]
52 [link geometry.reference.algorithms.distance.distance_3_with_strategy distance (with strategy)]
53 }
54 */
55 template
56 <
57 typename FormulaPolicy = strategy::andoyer,
58 typename Spheroid = srs::spheroid<double>,
59 typename CalculationType = void
60 >
61 class geographic_cross_track_box_box
62 {
63 public:
64
65 // point-point strategy getters
66 struct distance_pp_strategy
67 {
68 typedef geographic<FormulaPolicy, Spheroid, CalculationType> type;
69 };
70
71 // point-segment strategy getters
72 struct distance_ps_strategy
73 {
74 typedef geographic_cross_track
75 <
76 FormulaPolicy,
77 Spheroid,
78 CalculationType
79 > type;
80 };
81
82 template <typename Box1, typename Box2>
83 struct return_type : services::return_type
84 <
85 typename distance_ps_strategy::type,
86 typename point_type<Box1>::type,
87 typename point_type<Box2>::type
88 >
89 {};
90
91 //constructor
92
93 explicit geographic_cross_track_box_box(Spheroid const& spheroid = Spheroid())
94 : m_spheroid(spheroid)
95 {}
96
97 template <typename Box1, typename Box2>
98 inline typename return_type<Box1, Box2>::type
99 apply(Box1 const& box1, Box2 const& box2) const
100 {
101 /*
102 #if !defined(BOOST_MSVC)
103 BOOST_CONCEPT_ASSERT
104 (
105 (concepts::PointSegmentDistanceStrategy
106 <
107 Strategy,
108 typename point_type<Box1>::type,
109 typename point_type<Box2>::type
110 >)
111 );
112 #endif
113 */
114 typedef typename return_type<Box1, Box2>::type return_type;
115 return details::cross_track_box_box_generic
116 <return_type>::apply(box1, box2,
117 typename distance_pp_strategy::type(m_spheroid),
118 typename distance_ps_strategy::type(m_spheroid));
119 }
120
121 Spheroid model() const
122 {
123 return m_spheroid;
124 }
125
126 private :
127 Spheroid m_spheroid;
128 };
129
130
131
132 #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
133 namespace services
134 {
135
136 template <typename Strategy, typename Spheroid, typename CalculationType>
137 struct tag<geographic_cross_track_box_box<Strategy, Spheroid, CalculationType> >
138 {
139 typedef strategy_tag_distance_box_box type;
140 };
141
142
143 template <typename Strategy, typename Spheroid, typename CalculationType, typename Box1, typename Box2>
144 struct return_type<geographic_cross_track_box_box<Strategy, Spheroid, CalculationType>, Box1, Box2>
145 : geographic_cross_track_box_box
146 <
147 Strategy, Spheroid, CalculationType
148 >::template return_type<Box1, Box2>
149 {};
150
151 template <typename Strategy, typename Spheroid, typename Box1, typename Box2>
152 struct return_type<geographic_cross_track_box_box<Strategy, Spheroid>, Box1, Box2>
153 : geographic_cross_track_box_box
154 <
155 Strategy, Spheroid
156 >::template return_type<Box1, Box2>
157 {};
158
159 template <typename Strategy, typename Box1, typename Box2>
160 struct return_type<geographic_cross_track_box_box<Strategy>, Box1, Box2>
161 : geographic_cross_track_box_box
162 <
163 Strategy
164 >::template return_type<Box1, Box2>
165 {};
166
167 template <typename Strategy, typename Spheroid, typename CalculationType>
168 struct comparable_type<geographic_cross_track_box_box<Strategy, Spheroid, CalculationType> >
169 {
170 typedef geographic_cross_track_box_box
171 <
172 typename comparable_type<Strategy>::type, Spheroid, CalculationType
173 > type;
174 };
175
176
177 template <typename Strategy, typename Spheroid, typename CalculationType>
178 struct get_comparable<geographic_cross_track_box_box<Strategy, Spheroid, CalculationType> >
179 {
180 public:
181 static inline geographic_cross_track_box_box<Strategy, Spheroid, CalculationType>
182 apply(geographic_cross_track_box_box<Strategy, Spheroid, CalculationType> const& str)
183 {
184 return str;
185 }
186 };
187
188
189 template <typename Strategy, typename Spheroid, typename CalculationType, typename Box1, typename Box2>
190 struct result_from_distance
191 <
192 geographic_cross_track_box_box<Strategy, Spheroid, CalculationType>, Box1, Box2
193 >
194 {
195 private:
196 typedef geographic_cross_track_box_box<Strategy, Spheroid, CalculationType> this_strategy;
197
198 typedef typename this_strategy::template return_type
199 <
200 Box1, Box2
201 >::type return_type;
202
203 public:
204 template <typename T>
205 static inline return_type apply(this_strategy const& strategy,
206 T const& distance)
207 {
208 result_from_distance
209 <
210 Strategy,
211 typename point_type<Box1>::type,
212 typename point_type<Box2>::type
213 >::apply(strategy, distance);
214 }
215 };
216
217 template <typename Box1, typename Box2>
218 struct default_strategy
219 <
220 box_tag, box_tag, Box1, Box2,
221 geographic_tag, geographic_tag
222 >
223 {
224 typedef geographic_cross_track_box_box<> type;
225 };
226
227
228 } // namespace services
229 #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
230
231
232 }} // namespace strategy::distance
233
234
235 }} // namespace boost::geometry
236
237
238 #endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_DISTANCE_CROSS_TRACK_BOX_BOX_HPP