1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2017-2018, 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>
17 #include <boost/mpl/if.hpp>
18 #include <boost/type_traits/is_void.hpp>
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>
26 #include <boost/geometry/strategies/distance.hpp>
27 #include <boost/geometry/strategies/concepts/distance_concept.hpp>
28 #include <boost/geometry/strategies/geographic/distance.hpp>
29 #include <boost/geometry/strategies/geographic/distance_cross_track.hpp>
30 #include <boost/geometry/strategies/spherical/distance_cross_track.hpp>
31 #include <boost/geometry/strategies/spherical/distance_cross_track_box_box.hpp>
33 #include <boost/geometry/util/math.hpp>
34 #include <boost/geometry/algorithms/detail/assign_box_corners.hpp>
37 namespace boost { namespace geometry
40 namespace strategy { namespace distance
45 \brief Strategy functor for distance point to box calculation
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
54 [link geometry.reference.algorithms.distance.distance_3_with_strategy distance (with strategy)]
59 typename FormulaPolicy = strategy::andoyer,
60 typename Spheroid = srs::spheroid<double>,
61 typename CalculationType = void
63 class geographic_cross_track_box_box
67 // point-point strategy getters
68 struct distance_pp_strategy
70 typedef geographic<FormulaPolicy, Spheroid, CalculationType> type;
73 // point-segment strategy getters
74 struct distance_ps_strategy
76 typedef geographic_cross_track
84 template <typename Box1, typename Box2>
85 struct return_type : services::return_type
87 typename distance_ps_strategy::type,
88 typename point_type<Box1>::type,
89 typename point_type<Box2>::type
95 explicit geographic_cross_track_box_box(Spheroid const& spheroid = Spheroid())
96 : m_spheroid(spheroid)
99 template <typename Box1, typename Box2>
100 inline typename return_type<Box1, Box2>::type
101 apply(Box1 const& box1, Box2 const& box2) const
104 #if !defined(BOOST_MSVC)
107 (concepts::PointSegmentDistanceStrategy
110 typename point_type<Box1>::type,
111 typename point_type<Box2>::type
116 typedef typename return_type<Box1, Box2>::type return_type;
117 return details::cross_track_box_box_generic
118 <return_type>::apply(box1, box2,
119 typename distance_pp_strategy::type(m_spheroid),
120 typename distance_ps_strategy::type(m_spheroid));
128 #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
132 template <typename Strategy, typename Spheroid, typename CalculationType>
133 struct tag<geographic_cross_track_box_box<Strategy, Spheroid, CalculationType> >
135 typedef strategy_tag_distance_box_box type;
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
143 Strategy, Spheroid, CalculationType
144 >::template return_type<Box1, Box2>
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
152 >::template return_type<Box1, Box2>
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
160 >::template return_type<Box1, Box2>
163 template <typename Strategy, typename Spheroid, typename CalculationType>
164 struct comparable_type<geographic_cross_track_box_box<Strategy, Spheroid, CalculationType> >
166 typedef geographic_cross_track_box_box
168 typename comparable_type<Strategy>::type, Spheroid, CalculationType
173 template <typename Strategy, typename Spheroid, typename CalculationType>
174 struct get_comparable<geographic_cross_track_box_box<Strategy, Spheroid, CalculationType> >
177 static inline geographic_cross_track_box_box<Strategy, Spheroid, CalculationType>
178 apply(geographic_cross_track_box_box<Strategy, Spheroid, CalculationType> const& str)
185 template <typename Strategy, typename Spheroid, typename CalculationType, typename Box1, typename Box2>
186 struct result_from_distance
188 geographic_cross_track_box_box<Strategy, Spheroid, CalculationType>, Box1, Box2
192 typedef geographic_cross_track_box_box<Strategy, Spheroid, CalculationType> this_strategy;
194 typedef typename this_strategy::template return_type
200 template <typename T>
201 static inline return_type apply(this_strategy const& strategy,
207 typename point_type<Box1>::type,
208 typename point_type<Box2>::type
209 >::apply(strategy, distance);
213 template <typename Box1, typename Box2>
214 struct default_strategy
216 box_tag, box_tag, Box1, Box2,
217 geographic_tag, geographic_tag
220 typedef geographic_cross_track_box_box<> type;
224 } // namespace services
225 #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
228 }} // namespace strategy::distance
231 }} // namespace boost::geometry
234 #endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_DISTANCE_CROSS_TRACK_BOX_BOX_HPP