1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2017-2020, 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_POINT_BOX_HPP
13 #define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_DISTANCE_CROSS_TRACK_POINT_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/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>
30 #include <boost/geometry/util/math.hpp>
31 #include <boost/geometry/algorithms/detail/assign_box_corners.hpp>
34 namespace boost { namespace geometry
37 namespace strategy { namespace distance
42 \brief Strategy functor for distance point to box calculation
44 \details Class which calculates the distance of a point to a box, for
45 points and boxes on a sphere or globe
46 \tparam CalculationType \tparam_calculation
47 \tparam Strategy underlying point-segment distance strategy, defaults
51 [link geometry.reference.algorithms.distance.distance_3_with_strategy distance (with strategy)]
56 typename FormulaPolicy = strategy::andoyer,
57 typename Spheroid = srs::spheroid<double>,
58 typename CalculationType = void
60 class geographic_cross_track_point_box
63 // point-point strategy getters
64 struct distance_ps_strategy
66 typedef geographic_cross_track<FormulaPolicy, Spheroid, CalculationType> type;
69 template <typename Point, typename Box>
71 : services::return_type<typename distance_ps_strategy::type,
72 Point, typename point_type<Box>::type>
77 explicit geographic_cross_track_point_box(Spheroid const& spheroid = Spheroid())
78 : m_spheroid(spheroid)
81 template <typename Point, typename Box>
82 inline typename return_type<Point, Box>::type
83 apply(Point const& point, Box const& box) const
86 #if !defined(BOOST_MSVC)
89 (concepts::PointSegmentDistanceStrategy
91 Strategy, Point, typename point_type<Box>::type
97 typedef typename return_type<Point, Box>::type return_type;
99 return details::cross_track_point_box_generic
100 <return_type>::apply(point, box,
101 typename distance_ps_strategy::type(m_spheroid));
110 #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
114 template <typename Strategy, typename Spheroid, typename CalculationType>
115 struct tag<geographic_cross_track_point_box<Strategy, Spheroid, CalculationType> >
117 typedef strategy_tag_distance_point_box type;
121 template <typename Strategy, typename Spheroid, typename CalculationType, typename P, typename Box>
122 struct return_type<geographic_cross_track_point_box<Strategy, Spheroid, CalculationType>, P, Box>
123 : geographic_cross_track_point_box
125 Strategy, Spheroid, CalculationType
126 >::template return_type<P, Box>
129 template <typename Strategy, typename Spheroid, typename P, typename Box>
130 struct return_type<geographic_cross_track_point_box<Strategy, Spheroid>, P, Box>
131 : geographic_cross_track_point_box
134 >::template return_type<P, Box>
137 template <typename Strategy, typename P, typename Box>
138 struct return_type<geographic_cross_track_point_box<Strategy>, P, Box>
139 : geographic_cross_track_point_box
142 >::template return_type<P, Box>
145 template <typename Strategy, typename Spheroid, typename CalculationType>
146 struct comparable_type<geographic_cross_track_point_box<Strategy, Spheroid, CalculationType> >
148 typedef geographic_cross_track_point_box
150 Strategy, Spheroid, CalculationType
155 template <typename Strategy, typename Spheroid, typename CalculationType>
156 struct get_comparable<geographic_cross_track_point_box<Strategy, Spheroid, CalculationType> >
159 static inline geographic_cross_track_point_box<Strategy, Spheroid, CalculationType>
160 apply(geographic_cross_track_point_box<Strategy, Spheroid, CalculationType> const& str)
167 template <typename Strategy, typename Spheroid, typename CalculationType, typename P, typename Box>
168 struct result_from_distance
170 geographic_cross_track_point_box<Strategy, Spheroid, CalculationType>, P, Box
174 typedef geographic_cross_track_point_box<Strategy, Spheroid, CalculationType> this_strategy;
176 typedef typename this_strategy::template return_type
182 template <typename T>
183 static inline return_type apply(this_strategy const& strategy,
188 Strategy, P, typename point_type<Box>::type
189 >::apply(strategy, distance);
193 template <typename Point, typename Box>
194 struct default_strategy
196 point_tag, box_tag, Point, Box,
197 geographic_tag, geographic_tag
200 typedef geographic_cross_track_point_box<> type;
203 template <typename Box, typename Point>
204 struct default_strategy
206 box_tag, point_tag, Box, Point,
207 geographic_tag, geographic_tag
210 typedef typename default_strategy
212 point_tag, box_tag, Point, Box,
213 geographic_tag, geographic_tag
217 } // namespace services
218 #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
221 }} // namespace strategy::distance
224 }} // namespace boost::geometry
226 #endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_DISTANCE_CROSS_TRACK_POINT_BOX_HPP