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

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.