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