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, 2016.
6 // Modifications copyright (c) 2014-2016 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)
14 #ifndef BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_ANDOYER_HPP
15 #define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_ANDOYER_HPP
18 #include <boost/geometry/core/coordinate_type.hpp>
19 #include <boost/geometry/core/radian_access.hpp>
20 #include <boost/geometry/core/radius.hpp>
21 #include <boost/geometry/core/srs.hpp>
23 #include <boost/geometry/algorithms/detail/andoyer_inverse.hpp>
24 #include <boost/geometry/algorithms/detail/flattening.hpp>
26 #include <boost/geometry/strategies/distance.hpp>
28 #include <boost/geometry/util/math.hpp>
29 #include <boost/geometry/util/promote_floating_point.hpp>
30 #include <boost/geometry/util/select_calculation_type.hpp>
33 namespace boost { namespace geometry
36 namespace strategy { namespace distance
41 \brief Point-point distance approximation taking flattening into account
43 \tparam Spheroid The reference spheroid model
44 \tparam CalculationType \tparam_calculation
45 \author After Andoyer, 19xx, republished 1950, republished by Meeus, 1999
46 \note Although not so well-known, the approximation is very good: in all cases the results
47 are about the same as Vincenty. In my (Barend's) testcases the results didn't differ more than 6 m
48 \see http://nacc.upc.es/tierra/node16.html
49 \see http://sci.tech-archive.net/Archive/sci.geo.satellite-nav/2004-12/2724.html
50 \see http://home.att.net/~srschmitt/great_circle_route.html (implementation)
51 \see http://www.codeguru.com/Cpp/Cpp/algorithms/article.php/c5115 (implementation)
52 \see http://futureboy.homeip.net/frinksamp/navigation.frink (implementation)
53 \see http://www.voidware.com/earthdist.htm (implementation)
54 \see http://www.dtic.mil/docs/citations/AD0627893
55 \see http://www.dtic.mil/docs/citations/AD703541
60 typename CalculationType = void
65 template <typename Point1, typename Point2>
66 struct calculation_type
67 : promote_floating_point
69 typename select_calculation_type
78 typedef Spheroid model_type;
84 explicit inline andoyer(Spheroid const& spheroid)
85 : m_spheroid(spheroid)
88 template <typename Point1, typename Point2>
89 inline typename calculation_type<Point1, Point2>::type
90 apply(Point1 const& point1, Point2 const& point2) const
92 return geometry::detail::andoyer_inverse
94 typename calculation_type<Point1, Point2>::type,
96 >::apply(get_as_radian<0>(point1), get_as_radian<1>(point1),
97 get_as_radian<0>(point2), get_as_radian<1>(point2),
101 inline Spheroid const& model() const
111 #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
115 template <typename Spheroid, typename CalculationType>
116 struct tag<andoyer<Spheroid, CalculationType> >
118 typedef strategy_tag_distance_point_point type;
122 template <typename Spheroid, typename CalculationType, typename P1, typename P2>
123 struct return_type<andoyer<Spheroid, CalculationType>, P1, P2>
124 : andoyer<Spheroid, CalculationType>::template calculation_type<P1, P2>
128 template <typename Spheroid, typename CalculationType>
129 struct comparable_type<andoyer<Spheroid, CalculationType> >
131 typedef andoyer<Spheroid, CalculationType> type;
135 template <typename Spheroid, typename CalculationType>
136 struct get_comparable<andoyer<Spheroid, CalculationType> >
138 static inline andoyer<Spheroid, CalculationType> apply(andoyer<Spheroid, CalculationType> const& input)
144 template <typename Spheroid, typename CalculationType, typename P1, typename P2>
145 struct result_from_distance<andoyer<Spheroid, CalculationType>, P1, P2>
147 template <typename T>
148 static inline typename return_type<andoyer<Spheroid, CalculationType>, P1, P2>::type
149 apply(andoyer<Spheroid, CalculationType> const& , T const& value)
156 template <typename Point1, typename Point2>
157 struct default_strategy<point_tag, point_tag, Point1, Point2, geographic_tag, geographic_tag>
159 typedef strategy::distance::andoyer
163 typename select_coordinate_type<Point1, Point2>::type
169 } // namespace services
170 #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
173 }} // namespace strategy::distance
176 }} // namespace boost::geometry
179 #endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_ANDOYER_HPP