]>
Commit | Line | Data |
---|---|---|
11fdf7f2 TL |
1 | // Boost.Geometry (aka GGL, Generic Geometry Library) |
2 | ||
20effc67 | 3 | // Copyright (c) 2017-2020, Oracle and/or its affiliates. |
11fdf7f2 TL |
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> | |
11fdf7f2 TL |
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> | |
92f5a8d4 TL |
26 | #include <boost/geometry/strategies/geographic/distance.hpp> |
27 | #include <boost/geometry/strategies/geographic/distance_cross_track.hpp> | |
11fdf7f2 TL |
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: | |
92f5a8d4 TL |
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 | }; | |
11fdf7f2 TL |
81 | |
82 | template <typename Box1, typename Box2> | |
92f5a8d4 TL |
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 | > | |
11fdf7f2 TL |
89 | {}; |
90 | ||
92f5a8d4 TL |
91 | //constructor |
92 | ||
93 | explicit geographic_cross_track_box_box(Spheroid const& spheroid = Spheroid()) | |
94 | : m_spheroid(spheroid) | |
11fdf7f2 TL |
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 | |
92f5a8d4 TL |
116 | <return_type>::apply(box1, box2, |
117 | typename distance_pp_strategy::type(m_spheroid), | |
118 | typename distance_ps_strategy::type(m_spheroid)); | |
11fdf7f2 | 119 | } |
92f5a8d4 TL |
120 | private : |
121 | Spheroid m_spheroid; | |
11fdf7f2 TL |
122 | }; |
123 | ||
124 | ||
125 | ||
126 | #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS | |
127 | namespace services | |
128 | { | |
129 | ||
130 | template <typename Strategy, typename Spheroid, typename CalculationType> | |
131 | struct tag<geographic_cross_track_box_box<Strategy, Spheroid, CalculationType> > | |
132 | { | |
133 | typedef strategy_tag_distance_box_box type; | |
134 | }; | |
135 | ||
136 | ||
137 | template <typename Strategy, typename Spheroid, typename CalculationType, typename Box1, typename Box2> | |
138 | struct return_type<geographic_cross_track_box_box<Strategy, Spheroid, CalculationType>, Box1, Box2> | |
139 | : geographic_cross_track_box_box | |
140 | < | |
141 | Strategy, Spheroid, CalculationType | |
142 | >::template return_type<Box1, Box2> | |
143 | {}; | |
144 | ||
145 | template <typename Strategy, typename Spheroid, typename Box1, typename Box2> | |
146 | struct return_type<geographic_cross_track_box_box<Strategy, Spheroid>, Box1, Box2> | |
147 | : geographic_cross_track_box_box | |
148 | < | |
149 | Strategy, Spheroid | |
150 | >::template return_type<Box1, Box2> | |
151 | {}; | |
152 | ||
153 | template <typename Strategy, typename Box1, typename Box2> | |
154 | struct return_type<geographic_cross_track_box_box<Strategy>, Box1, Box2> | |
155 | : geographic_cross_track_box_box | |
156 | < | |
157 | Strategy | |
158 | >::template return_type<Box1, Box2> | |
159 | {}; | |
160 | ||
161 | template <typename Strategy, typename Spheroid, typename CalculationType> | |
162 | struct comparable_type<geographic_cross_track_box_box<Strategy, Spheroid, CalculationType> > | |
163 | { | |
164 | typedef geographic_cross_track_box_box | |
165 | < | |
166 | typename comparable_type<Strategy>::type, Spheroid, CalculationType | |
167 | > type; | |
168 | }; | |
169 | ||
170 | ||
171 | template <typename Strategy, typename Spheroid, typename CalculationType> | |
172 | struct get_comparable<geographic_cross_track_box_box<Strategy, Spheroid, CalculationType> > | |
173 | { | |
11fdf7f2 | 174 | public: |
92f5a8d4 TL |
175 | static inline geographic_cross_track_box_box<Strategy, Spheroid, CalculationType> |
176 | apply(geographic_cross_track_box_box<Strategy, Spheroid, CalculationType> const& str) | |
11fdf7f2 | 177 | { |
92f5a8d4 | 178 | return str; |
11fdf7f2 TL |
179 | } |
180 | }; | |
181 | ||
182 | ||
183 | template <typename Strategy, typename Spheroid, typename CalculationType, typename Box1, typename Box2> | |
184 | struct result_from_distance | |
185 | < | |
186 | geographic_cross_track_box_box<Strategy, Spheroid, CalculationType>, Box1, Box2 | |
187 | > | |
188 | { | |
189 | private: | |
190 | typedef geographic_cross_track_box_box<Strategy, Spheroid, CalculationType> this_strategy; | |
191 | ||
192 | typedef typename this_strategy::template return_type | |
193 | < | |
194 | Box1, Box2 | |
195 | >::type return_type; | |
196 | ||
197 | public: | |
198 | template <typename T> | |
199 | static inline return_type apply(this_strategy const& strategy, | |
200 | T const& distance) | |
201 | { | |
202 | result_from_distance | |
203 | < | |
204 | Strategy, | |
205 | typename point_type<Box1>::type, | |
206 | typename point_type<Box2>::type | |
207 | >::apply(strategy, distance); | |
208 | } | |
209 | }; | |
210 | ||
211 | template <typename Box1, typename Box2> | |
212 | struct default_strategy | |
213 | < | |
214 | box_tag, box_tag, Box1, Box2, | |
215 | geographic_tag, geographic_tag | |
216 | > | |
217 | { | |
218 | typedef geographic_cross_track_box_box<> type; | |
219 | }; | |
220 | ||
221 | ||
222 | } // namespace services | |
223 | #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS | |
224 | ||
225 | ||
226 | }} // namespace strategy::distance | |
227 | ||
228 | ||
229 | }} // namespace boost::geometry | |
230 | ||
231 | ||
232 | #endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_DISTANCE_CROSS_TRACK_BOX_BOX_HPP |