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 typedef geographic_cross_track<FormulaPolicy, Spheroid, CalculationType> Strategy;
67 template <typename Point, typename Box>
69 : services::return_type<Strategy, Point, typename point_type<Box>::type>
72 inline geographic_cross_track_point_box()
75 template <typename Point, typename Box>
76 inline typename return_type<Point, Box>::type
77 apply(Point const& point, Box const& box) const
80 #if !defined(BOOST_MSVC)
83 (concepts::PointSegmentDistanceStrategy
85 Strategy, Point, typename point_type<Box>::type
91 typedef typename return_type<Point, Box>::type return_type;
93 return details::cross_track_point_box_generic
94 <return_type>::apply(point, box, Strategy());
100 #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
104 template <typename Strategy, typename Spheroid, typename CalculationType>
105 struct tag<geographic_cross_track_point_box<Strategy, Spheroid, CalculationType> >
107 typedef strategy_tag_distance_point_box type;
111 template <typename Strategy, typename Spheroid, typename CalculationType, typename P, typename Box>
112 struct return_type<geographic_cross_track_point_box<Strategy, Spheroid, CalculationType>, P, Box>
113 : geographic_cross_track_point_box
115 Strategy, Spheroid, CalculationType
116 >::template return_type<P, Box>
119 template <typename Strategy, typename Spheroid, typename P, typename Box>
120 struct return_type<geographic_cross_track_point_box<Strategy, Spheroid>, P, Box>
121 : geographic_cross_track_point_box
124 >::template return_type<P, Box>
127 template <typename Strategy, typename P, typename Box>
128 struct return_type<geographic_cross_track_point_box<Strategy>, P, Box>
129 : geographic_cross_track_point_box
132 >::template return_type<P, Box>
135 template <typename Strategy, typename Spheroid, typename CalculationType>
136 struct comparable_type<geographic_cross_track_point_box<Strategy, Spheroid, CalculationType> >
138 typedef geographic_cross_track_point_box
140 Strategy, Spheroid, CalculationType
145 template <typename Strategy, typename Spheroid, typename CalculationType>
146 struct get_comparable<geographic_cross_track_point_box<Strategy, Spheroid, CalculationType> >
148 typedef geographic_cross_track_point_box<Strategy, Spheroid, CalculationType> this_strategy;
149 typedef typename comparable_type<this_strategy>::type comparable_type;
152 static inline comparable_type apply(this_strategy const&)
154 return comparable_type();
159 template <typename Strategy, typename Spheroid, typename CalculationType, typename P, typename Box>
160 struct result_from_distance
162 geographic_cross_track_point_box<Strategy, Spheroid, CalculationType>, P, Box
166 typedef geographic_cross_track_point_box<Strategy, Spheroid, CalculationType> this_strategy;
168 typedef typename this_strategy::template return_type
174 template <typename T>
175 static inline return_type apply(this_strategy const& strategy,
180 Strategy, P, typename point_type<Box>::type
181 >::apply(strategy, distance);
185 template <typename Point, typename Box>
186 struct default_strategy
188 point_tag, box_tag, Point, Box,
189 geographic_tag, geographic_tag
192 typedef geographic_cross_track_point_box<> type;
195 template <typename Box, typename Point>
196 struct default_strategy
198 box_tag, point_tag, Box, Point,
199 geographic_tag, geographic_tag
202 typedef typename default_strategy
204 point_tag, box_tag, Point, Box,
205 geographic_tag, geographic_tag
209 } // namespace services
210 #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
213 }} // namespace strategy::distance
216 }} // namespace boost::geometry
218 #endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_DISTANCE_CROSS_TRACK_POINT_BOX_HPP