1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2017-2021, Oracle and/or its affiliates.
5 // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
6 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
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)
12 #ifndef BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_DISTANCE_CROSS_TRACK_BOX_BOX_HPP
13 #define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_DISTANCE_CROSS_TRACK_BOX_BOX_HPP
15 #include <boost/config.hpp>
16 #include <boost/concept_check.hpp>
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>
24 #include <boost/geometry/strategies/distance.hpp>
25 #include <boost/geometry/strategies/concepts/distance_concept.hpp>
26 #include <boost/geometry/strategies/geographic/distance.hpp>
27 #include <boost/geometry/strategies/geographic/distance_cross_track.hpp>
28 #include <boost/geometry/strategies/spherical/distance_cross_track.hpp>
29 #include <boost/geometry/strategies/spherical/distance_cross_track_box_box.hpp>
31 #include <boost/geometry/util/math.hpp>
32 #include <boost/geometry/algorithms/detail/assign_box_corners.hpp>
35 namespace boost { namespace geometry
38 namespace strategy { namespace distance
43 \brief Strategy functor for distance point to box calculation
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
52 [link geometry.reference.algorithms.distance.distance_3_with_strategy distance (with strategy)]
57 typename FormulaPolicy = strategy::andoyer,
58 typename Spheroid = srs::spheroid<double>,
59 typename CalculationType = void
61 class geographic_cross_track_box_box
65 // point-point strategy getters
66 struct distance_pp_strategy
68 typedef geographic<FormulaPolicy, Spheroid, CalculationType> type;
71 // point-segment strategy getters
72 struct distance_ps_strategy
74 typedef geographic_cross_track
82 template <typename Box1, typename Box2>
83 struct return_type : services::return_type
85 typename distance_ps_strategy::type,
86 typename point_type<Box1>::type,
87 typename point_type<Box2>::type
93 explicit geographic_cross_track_box_box(Spheroid const& spheroid = Spheroid())
94 : m_spheroid(spheroid)
97 template <typename Box1, typename Box2>
98 inline typename return_type<Box1, Box2>::type
99 apply(Box1 const& box1, Box2 const& box2) const
102 #if !defined(BOOST_MSVC)
105 (concepts::PointSegmentDistanceStrategy
108 typename point_type<Box1>::type,
109 typename point_type<Box2>::type
114 typedef typename return_type<Box1, Box2>::type return_type;
115 return details::cross_track_box_box_generic
116 <return_type>::apply(box1, box2,
117 typename distance_pp_strategy::type(m_spheroid),
118 typename distance_ps_strategy::type(m_spheroid));
121 Spheroid model() const
132 #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
136 template <typename Strategy, typename Spheroid, typename CalculationType>
137 struct tag<geographic_cross_track_box_box<Strategy, Spheroid, CalculationType> >
139 typedef strategy_tag_distance_box_box type;
143 template <typename Strategy, typename Spheroid, typename CalculationType, typename Box1, typename Box2>
144 struct return_type<geographic_cross_track_box_box<Strategy, Spheroid, CalculationType>, Box1, Box2>
145 : geographic_cross_track_box_box
147 Strategy, Spheroid, CalculationType
148 >::template return_type<Box1, Box2>
151 template <typename Strategy, typename Spheroid, typename Box1, typename Box2>
152 struct return_type<geographic_cross_track_box_box<Strategy, Spheroid>, Box1, Box2>
153 : geographic_cross_track_box_box
156 >::template return_type<Box1, Box2>
159 template <typename Strategy, typename Box1, typename Box2>
160 struct return_type<geographic_cross_track_box_box<Strategy>, Box1, Box2>
161 : geographic_cross_track_box_box
164 >::template return_type<Box1, Box2>
167 template <typename Strategy, typename Spheroid, typename CalculationType>
168 struct comparable_type<geographic_cross_track_box_box<Strategy, Spheroid, CalculationType> >
170 typedef geographic_cross_track_box_box
172 typename comparable_type<Strategy>::type, Spheroid, CalculationType
177 template <typename Strategy, typename Spheroid, typename CalculationType>
178 struct get_comparable<geographic_cross_track_box_box<Strategy, Spheroid, CalculationType> >
181 static inline geographic_cross_track_box_box<Strategy, Spheroid, CalculationType>
182 apply(geographic_cross_track_box_box<Strategy, Spheroid, CalculationType> const& str)
189 template <typename Strategy, typename Spheroid, typename CalculationType, typename Box1, typename Box2>
190 struct result_from_distance
192 geographic_cross_track_box_box<Strategy, Spheroid, CalculationType>, Box1, Box2
196 typedef geographic_cross_track_box_box<Strategy, Spheroid, CalculationType> this_strategy;
198 typedef typename this_strategy::template return_type
204 template <typename T>
205 static inline return_type apply(this_strategy const& strategy,
211 typename point_type<Box1>::type,
212 typename point_type<Box2>::type
213 >::apply(strategy, distance);
217 template <typename Box1, typename Box2>
218 struct default_strategy
220 box_tag, box_tag, Box1, Box2,
221 geographic_tag, geographic_tag
224 typedef geographic_cross_track_box_box<> type;
228 } // namespace services
229 #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
232 }} // namespace strategy::distance
235 }} // namespace boost::geometry
238 #endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_DISTANCE_CROSS_TRACK_BOX_BOX_HPP