]> git.proxmox.com Git - ceph.git/blame - 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
CommitLineData
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_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>
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>
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
34namespace boost { namespace geometry
35{
36
37namespace 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
45points and boxes on a sphere or globe
46\tparam CalculationType \tparam_calculation
47\tparam Strategy underlying point-segment distance strategy, defaults
48to cross track
49\qbk{
50[heading See also]
51[link geometry.reference.algorithms.distance.distance_3_with_strategy distance (with strategy)]
52}
53*/
54template
55<
56 typename FormulaPolicy = strategy::andoyer,
57 typename Spheroid = srs::spheroid<double>,
58 typename CalculationType = void
59>
60class geographic_cross_track_point_box
61{
62public:
92f5a8d4
TL
63 // point-point strategy getters
64 struct distance_ps_strategy
65 {
66 typedef geographic_cross_track<FormulaPolicy, Spheroid, CalculationType> type;
67 };
11fdf7f2
TL
68
69 template <typename Point, typename Box>
70 struct return_type
92f5a8d4
TL
71 : services::return_type<typename distance_ps_strategy::type,
72 Point, typename point_type<Box>::type>
11fdf7f2
TL
73 {};
74
92f5a8d4
TL
75 //constructor
76
77 explicit geographic_cross_track_point_box(Spheroid const& spheroid = Spheroid())
78 : m_spheroid(spheroid)
11fdf7f2
TL
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
92f5a8d4
TL
100 <return_type>::apply(point, box,
101 typename distance_ps_strategy::type(m_spheroid));
11fdf7f2 102 }
92f5a8d4
TL
103
104private :
105 Spheroid m_spheroid;
11fdf7f2
TL
106};
107
108
109
110#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
111namespace services
112{
113
114template <typename Strategy, typename Spheroid, typename CalculationType>
115struct tag<geographic_cross_track_point_box<Strategy, Spheroid, CalculationType> >
116{
117 typedef strategy_tag_distance_point_box type;
118};
119
120
121template <typename Strategy, typename Spheroid, typename CalculationType, typename P, typename Box>
122struct 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
129template <typename Strategy, typename Spheroid, typename P, typename Box>
130struct 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
137template <typename Strategy, typename P, typename Box>
138struct 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
145template <typename Strategy, typename Spheroid, typename CalculationType>
146struct 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
155template <typename Strategy, typename Spheroid, typename CalculationType>
156struct get_comparable<geographic_cross_track_point_box<Strategy, Spheroid, CalculationType> >
157{
11fdf7f2 158public:
92f5a8d4
TL
159 static inline geographic_cross_track_point_box<Strategy, Spheroid, CalculationType>
160 apply(geographic_cross_track_point_box<Strategy, Spheroid, CalculationType> const& str)
11fdf7f2 161 {
92f5a8d4 162 return str;
11fdf7f2
TL
163 }
164};
165
166
167template <typename Strategy, typename Spheroid, typename CalculationType, typename P, typename Box>
168struct result_from_distance
169 <
170 geographic_cross_track_point_box<Strategy, Spheroid, CalculationType>, P, Box
171 >
172{
173private:
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
181public:
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
193template <typename Point, typename Box>
194struct 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
203template <typename Box, typename Point>
204struct 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