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_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>
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/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>
32 #include <boost/geometry/util/math.hpp>
33 #include <boost/geometry/algorithms/detail/assign_box_corners.hpp>
36 namespace boost { namespace geometry
39 namespace strategy { namespace distance
44 \brief Strategy functor for distance point to box calculation
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
53 [link geometry.reference.algorithms.distance.distance_3_with_strategy distance (with strategy)]
58 typename FormulaPolicy = strategy::andoyer,
59 typename Spheroid = srs::spheroid<double>,
60 typename CalculationType = void
62 class geographic_cross_track_point_box
65 // point-point strategy getters
66 struct distance_ps_strategy
68 typedef geographic_cross_track<FormulaPolicy, Spheroid, CalculationType> type;
71 template <typename Point, typename Box>
73 : services::return_type<typename distance_ps_strategy::type,
74 Point, typename point_type<Box>::type>
79 explicit geographic_cross_track_point_box(Spheroid const& spheroid = Spheroid())
80 : m_spheroid(spheroid)
83 template <typename Point, typename Box>
84 inline typename return_type<Point, Box>::type
85 apply(Point const& point, Box const& box) const
88 #if !defined(BOOST_MSVC)
91 (concepts::PointSegmentDistanceStrategy
93 Strategy, Point, typename point_type<Box>::type
99 typedef typename return_type<Point, Box>::type return_type;
101 return details::cross_track_point_box_generic
102 <return_type>::apply(point, box,
103 typename distance_ps_strategy::type(m_spheroid));
112 #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
116 template <typename Strategy, typename Spheroid, typename CalculationType>
117 struct tag<geographic_cross_track_point_box<Strategy, Spheroid, CalculationType> >
119 typedef strategy_tag_distance_point_box type;
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
127 Strategy, Spheroid, CalculationType
128 >::template return_type<P, Box>
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
136 >::template return_type<P, Box>
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
144 >::template return_type<P, Box>
147 template <typename Strategy, typename Spheroid, typename CalculationType>
148 struct comparable_type<geographic_cross_track_point_box<Strategy, Spheroid, CalculationType> >
150 typedef geographic_cross_track_point_box
152 Strategy, Spheroid, CalculationType
157 template <typename Strategy, typename Spheroid, typename CalculationType>
158 struct get_comparable<geographic_cross_track_point_box<Strategy, Spheroid, CalculationType> >
161 static inline geographic_cross_track_point_box<Strategy, Spheroid, CalculationType>
162 apply(geographic_cross_track_point_box<Strategy, Spheroid, CalculationType> const& str)
169 template <typename Strategy, typename Spheroid, typename CalculationType, typename P, typename Box>
170 struct result_from_distance
172 geographic_cross_track_point_box<Strategy, Spheroid, CalculationType>, P, Box
176 typedef geographic_cross_track_point_box<Strategy, Spheroid, CalculationType> this_strategy;
178 typedef typename this_strategy::template return_type
184 template <typename T>
185 static inline return_type apply(this_strategy const& strategy,
190 Strategy, P, typename point_type<Box>::type
191 >::apply(strategy, distance);
195 template <typename Point, typename Box>
196 struct default_strategy
198 point_tag, box_tag, Point, Box,
199 geographic_tag, geographic_tag
202 typedef geographic_cross_track_point_box<> type;
205 template <typename Box, typename Point>
206 struct default_strategy
208 box_tag, point_tag, Box, Point,
209 geographic_tag, geographic_tag
212 typedef typename default_strategy
214 point_tag, box_tag, Point, Box,
215 geographic_tag, geographic_tag
219 } // namespace services
220 #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
223 }} // namespace strategy::distance
226 }} // namespace boost::geometry
228 #endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_DISTANCE_CROSS_TRACK_POINT_BOX_HPP