]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/include/boost/geometry/strategies/geographic/distance_andoyer.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / geometry / include / boost / geometry / strategies / geographic / distance_andoyer.hpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2
3 // Copyright (c) 2007-2016 Barend Gehrels, Amsterdam, the Netherlands.
4
5 // This file was modified by Oracle on 2014, 2016.
6 // Modifications copyright (c) 2014-2016 Oracle and/or its affiliates.
7
8 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
9
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)
13
14 #ifndef BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_ANDOYER_HPP
15 #define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_ANDOYER_HPP
16
17
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>
22
23 #include <boost/geometry/algorithms/detail/andoyer_inverse.hpp>
24 #include <boost/geometry/algorithms/detail/flattening.hpp>
25
26 #include <boost/geometry/strategies/distance.hpp>
27
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>
31
32
33 namespace boost { namespace geometry
34 {
35
36 namespace strategy { namespace distance
37 {
38
39
40 /*!
41 \brief Point-point distance approximation taking flattening into account
42 \ingroup distance
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
56 */
57 template
58 <
59 typename Spheroid,
60 typename CalculationType = void
61 >
62 class andoyer
63 {
64 public :
65 template <typename Point1, typename Point2>
66 struct calculation_type
67 : promote_floating_point
68 <
69 typename select_calculation_type
70 <
71 Point1,
72 Point2,
73 CalculationType
74 >::type
75 >
76 {};
77
78 typedef Spheroid model_type;
79
80 inline andoyer()
81 : m_spheroid()
82 {}
83
84 explicit inline andoyer(Spheroid const& spheroid)
85 : m_spheroid(spheroid)
86 {}
87
88 template <typename Point1, typename Point2>
89 inline typename calculation_type<Point1, Point2>::type
90 apply(Point1 const& point1, Point2 const& point2) const
91 {
92 return geometry::detail::andoyer_inverse
93 <
94 typename calculation_type<Point1, Point2>::type,
95 true, false
96 >::apply(get_as_radian<0>(point1), get_as_radian<1>(point1),
97 get_as_radian<0>(point2), get_as_radian<1>(point2),
98 m_spheroid).distance;
99 }
100
101 inline Spheroid const& model() const
102 {
103 return m_spheroid;
104 }
105
106 private :
107 Spheroid m_spheroid;
108 };
109
110
111 #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
112 namespace services
113 {
114
115 template <typename Spheroid, typename CalculationType>
116 struct tag<andoyer<Spheroid, CalculationType> >
117 {
118 typedef strategy_tag_distance_point_point type;
119 };
120
121
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>
125 {};
126
127
128 template <typename Spheroid, typename CalculationType>
129 struct comparable_type<andoyer<Spheroid, CalculationType> >
130 {
131 typedef andoyer<Spheroid, CalculationType> type;
132 };
133
134
135 template <typename Spheroid, typename CalculationType>
136 struct get_comparable<andoyer<Spheroid, CalculationType> >
137 {
138 static inline andoyer<Spheroid, CalculationType> apply(andoyer<Spheroid, CalculationType> const& input)
139 {
140 return input;
141 }
142 };
143
144 template <typename Spheroid, typename CalculationType, typename P1, typename P2>
145 struct result_from_distance<andoyer<Spheroid, CalculationType>, P1, P2>
146 {
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)
150 {
151 return value;
152 }
153 };
154
155
156 template <typename Point1, typename Point2>
157 struct default_strategy<point_tag, point_tag, Point1, Point2, geographic_tag, geographic_tag>
158 {
159 typedef strategy::distance::andoyer
160 <
161 srs::spheroid
162 <
163 typename select_coordinate_type<Point1, Point2>::type
164 >
165 > type;
166 };
167
168
169 } // namespace services
170 #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
171
172
173 }} // namespace strategy::distance
174
175
176 }} // namespace boost::geometry
177
178
179 #endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_ANDOYER_HPP