]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/strategies/geographic/distance_cross_track_point_box.hpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / boost / geometry / strategies / geographic / distance_cross_track_point_box.hpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2
3 // Copyright (c) 2017-2020, 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_POINT_BOX_HPP
13 #define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_DISTANCE_CROSS_TRACK_POINT_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/spherical/distance_cross_track.hpp>
27 #include <boost/geometry/strategies/geographic/distance_cross_track.hpp>
28 #include <boost/geometry/strategies/spherical/distance_cross_track_point_box.hpp>
29
30 #include <boost/geometry/util/math.hpp>
31 #include <boost/geometry/algorithms/detail/assign_box_corners.hpp>
32
33
34 namespace boost { namespace geometry
35 {
36
37 namespace strategy { namespace distance
38 {
39
40
41 /*!
42 \brief Strategy functor for distance point to box calculation
43 \ingroup strategies
44 \details Class which calculates the distance of a point to a box, for
45 points and boxes on a sphere or globe
46 \tparam CalculationType \tparam_calculation
47 \tparam Strategy underlying point-segment distance strategy, defaults
48 to cross track
49 \qbk{
50 [heading See also]
51 [link geometry.reference.algorithms.distance.distance_3_with_strategy distance (with strategy)]
52 }
53 */
54 template
55 <
56 typename FormulaPolicy = strategy::andoyer,
57 typename Spheroid = srs::spheroid<double>,
58 typename CalculationType = void
59 >
60 class geographic_cross_track_point_box
61 {
62 public:
63 // point-point strategy getters
64 struct distance_ps_strategy
65 {
66 typedef geographic_cross_track<FormulaPolicy, Spheroid, CalculationType> type;
67 };
68
69 template <typename Point, typename Box>
70 struct return_type
71 : services::return_type<typename distance_ps_strategy::type,
72 Point, typename point_type<Box>::type>
73 {};
74
75 //constructor
76
77 explicit geographic_cross_track_point_box(Spheroid const& spheroid = Spheroid())
78 : m_spheroid(spheroid)
79 {}
80
81 template <typename Point, typename Box>
82 inline typename return_type<Point, Box>::type
83 apply(Point const& point, Box const& box) const
84 {
85 /*
86 #if !defined(BOOST_MSVC)
87 BOOST_CONCEPT_ASSERT
88 (
89 (concepts::PointSegmentDistanceStrategy
90 <
91 Strategy, Point, typename point_type<Box>::type
92 >)
93 );
94 #endif
95 */
96
97 typedef typename return_type<Point, Box>::type return_type;
98
99 return details::cross_track_point_box_generic
100 <return_type>::apply(point, box,
101 typename distance_ps_strategy::type(m_spheroid));
102 }
103
104 private :
105 Spheroid m_spheroid;
106 };
107
108
109
110 #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
111 namespace services
112 {
113
114 template <typename Strategy, typename Spheroid, typename CalculationType>
115 struct tag<geographic_cross_track_point_box<Strategy, Spheroid, CalculationType> >
116 {
117 typedef strategy_tag_distance_point_box type;
118 };
119
120
121 template <typename Strategy, typename Spheroid, typename CalculationType, typename P, typename Box>
122 struct return_type<geographic_cross_track_point_box<Strategy, Spheroid, CalculationType>, P, Box>
123 : geographic_cross_track_point_box
124 <
125 Strategy, Spheroid, CalculationType
126 >::template return_type<P, Box>
127 {};
128
129 template <typename Strategy, typename Spheroid, typename P, typename Box>
130 struct return_type<geographic_cross_track_point_box<Strategy, Spheroid>, P, Box>
131 : geographic_cross_track_point_box
132 <
133 Strategy, Spheroid
134 >::template return_type<P, Box>
135 {};
136
137 template <typename Strategy, typename P, typename Box>
138 struct return_type<geographic_cross_track_point_box<Strategy>, P, Box>
139 : geographic_cross_track_point_box
140 <
141 Strategy
142 >::template return_type<P, Box>
143 {};
144
145 template <typename Strategy, typename Spheroid, typename CalculationType>
146 struct comparable_type<geographic_cross_track_point_box<Strategy, Spheroid, CalculationType> >
147 {
148 typedef geographic_cross_track_point_box
149 <
150 Strategy, Spheroid, CalculationType
151 > type;
152 };
153
154
155 template <typename Strategy, typename Spheroid, typename CalculationType>
156 struct get_comparable<geographic_cross_track_point_box<Strategy, Spheroid, CalculationType> >
157 {
158 public:
159 static inline geographic_cross_track_point_box<Strategy, Spheroid, CalculationType>
160 apply(geographic_cross_track_point_box<Strategy, Spheroid, CalculationType> const& str)
161 {
162 return str;
163 }
164 };
165
166
167 template <typename Strategy, typename Spheroid, typename CalculationType, typename P, typename Box>
168 struct result_from_distance
169 <
170 geographic_cross_track_point_box<Strategy, Spheroid, CalculationType>, P, Box
171 >
172 {
173 private:
174 typedef geographic_cross_track_point_box<Strategy, Spheroid, CalculationType> this_strategy;
175
176 typedef typename this_strategy::template return_type
177 <
178 P, Box
179 >::type return_type;
180
181 public:
182 template <typename T>
183 static inline return_type apply(this_strategy const& strategy,
184 T const& distance)
185 {
186 result_from_distance
187 <
188 Strategy, P, typename point_type<Box>::type
189 >::apply(strategy, distance);
190 }
191 };
192
193 template <typename Point, typename Box>
194 struct default_strategy
195 <
196 point_tag, box_tag, Point, Box,
197 geographic_tag, geographic_tag
198 >
199 {
200 typedef geographic_cross_track_point_box<> type;
201 };
202
203 template <typename Box, typename Point>
204 struct default_strategy
205 <
206 box_tag, point_tag, Box, Point,
207 geographic_tag, geographic_tag
208 >
209 {
210 typedef typename default_strategy
211 <
212 point_tag, box_tag, Point, Box,
213 geographic_tag, geographic_tag
214 >::type type;
215 };
216
217 } // namespace services
218 #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
219
220
221 }} // namespace strategy::distance
222
223
224 }} // namespace boost::geometry
225
226 #endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_DISTANCE_CROSS_TRACK_POINT_BOX_HPP