1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2007-2016 Barend Gehrels, Amsterdam, the Netherlands.
5 // This file was modified by Oracle on 2014-2017.
6 // Modifications copyright (c) 2014-2017 Oracle and/or its affiliates.
8 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
10 // Use, modification and distribution is subject to the Boost Software License,
11 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
12 // http://www.boost.org/LICENSE_1_0.txt)
15 #ifndef BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_DISTANCE_HPP
16 #define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_DISTANCE_HPP
19 #include <boost/geometry/core/coordinate_type.hpp>
20 #include <boost/geometry/core/radian_access.hpp>
21 #include <boost/geometry/core/radius.hpp>
22 #include <boost/geometry/core/srs.hpp>
24 #include <boost/geometry/formulas/andoyer_inverse.hpp>
25 #include <boost/geometry/formulas/flattening.hpp>
27 #include <boost/geometry/strategies/distance.hpp>
28 #include <boost/geometry/strategies/geographic/parameters.hpp>
30 #include <boost/geometry/util/math.hpp>
31 #include <boost/geometry/util/promote_floating_point.hpp>
32 #include <boost/geometry/util/select_calculation_type.hpp>
35 namespace boost { namespace geometry
38 namespace strategy { namespace distance
43 typename FormulaPolicy = strategy::andoyer,
44 typename Spheroid = srs::spheroid<double>,
45 typename CalculationType = void
50 template <typename Point1, typename Point2>
51 struct calculation_type
52 : promote_floating_point
54 typename select_calculation_type
63 typedef Spheroid model_type;
69 explicit inline geographic(Spheroid const& spheroid)
70 : m_spheroid(spheroid)
73 template <typename Point1, typename Point2>
74 inline typename calculation_type<Point1, Point2>::type
75 apply(Point1 const& point1, Point2 const& point2) const
77 return FormulaPolicy::template inverse
79 typename calculation_type<Point1, Point2>::type,
80 true, false, false, false, false
81 >::apply(get_as_radian<0>(point1), get_as_radian<1>(point1),
82 get_as_radian<0>(point2), get_as_radian<1>(point2),
86 inline Spheroid const& model() const
96 #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
102 typename FormulaPolicy,
104 typename CalculationType
106 struct tag<geographic<FormulaPolicy, Spheroid, CalculationType> >
108 typedef strategy_tag_distance_point_point type;
114 typename FormulaPolicy,
116 typename CalculationType,
120 struct return_type<geographic<FormulaPolicy, Spheroid, CalculationType>, P1, P2>
121 : geographic<FormulaPolicy, Spheroid, CalculationType>::template calculation_type<P1, P2>
127 typename FormulaPolicy,
129 typename CalculationType
131 struct comparable_type<geographic<FormulaPolicy, Spheroid, CalculationType> >
133 typedef geographic<FormulaPolicy, Spheroid, CalculationType> type;
139 typename FormulaPolicy,
141 typename CalculationType
143 struct get_comparable<geographic<FormulaPolicy, Spheroid, CalculationType> >
145 static inline geographic<FormulaPolicy, Spheroid, CalculationType>
146 apply(geographic<FormulaPolicy, Spheroid, CalculationType> const& input)
154 typename FormulaPolicy,
156 typename CalculationType,
160 struct result_from_distance<geographic<FormulaPolicy, Spheroid, CalculationType>, P1, P2>
162 template <typename T>
163 static inline typename return_type<geographic<FormulaPolicy, Spheroid, CalculationType>, P1, P2>::type
164 apply(geographic<FormulaPolicy, Spheroid, CalculationType> const& , T const& value)
171 template <typename Point1, typename Point2>
172 struct default_strategy<point_tag, point_tag, Point1, Point2, geographic_tag, geographic_tag>
174 typedef strategy::distance::geographic
179 typename select_coordinate_type<Point1, Point2>::type
185 } // namespace services
186 #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
189 }} // namespace strategy::distance
192 }} // namespace boost::geometry
195 #endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_DISTANCE_HPP