]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/strategies/geographic/point_order.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / boost / geometry / strategies / geographic / point_order.hpp
1 // Boost.Geometry
2
3 // Copyright (c) 2019, Oracle and/or its affiliates.
4
5 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
6
7 // Licensed under the Boost Software License version 1.0.
8 // http://www.boost.org/users/license.html
9
10 #ifndef BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_POINT_ORDER_HPP
11 #define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_POINT_ORDER_HPP
12
13
14 #include <boost/geometry/core/tags.hpp>
15
16 #include <boost/geometry/srs/spheroid.hpp>
17
18 #include <boost/geometry/strategies/geographic/parameters.hpp>
19 #include <boost/geometry/strategies/point_order.hpp>
20 #include <boost/geometry/strategies/spherical/point_in_point.hpp>
21
22 #include <boost/geometry/util/math.hpp>
23 #include <boost/geometry/util/select_calculation_type.hpp>
24
25
26 namespace boost { namespace geometry
27 {
28
29 namespace strategy { namespace point_order
30 {
31
32 template
33 <
34 typename FormulaPolicy = strategy::andoyer,
35 typename Spheroid = srs::spheroid<double>,
36 typename CalculationType = void
37 >
38 struct geographic
39 {
40 typedef azimuth_tag version_tag;
41
42 template <typename Geometry>
43 struct result_type
44 {
45 typedef typename geometry::select_calculation_type_alt
46 <
47 CalculationType, Geometry
48 >::type type;
49 };
50
51 geographic()
52 {}
53
54 explicit geographic(Spheroid const& spheroid)
55 : m_spheroid(spheroid)
56 {}
57
58 template <typename Point>
59 inline bool apply(Point const& p1, Point const& p2,
60 typename result_type<Point>::type & azi,
61 typename result_type<Point>::type & razi) const
62 {
63 typedef typename result_type<Point>::type calc_t;
64
65 if (equals_point_point(p1, p2))
66 {
67 return false;
68 }
69
70 formula::result_inverse<calc_t> res = FormulaPolicy::template inverse
71 <
72 calc_t, false, true, true, false, false
73 >::apply(geometry::get_as_radian<0>(p1),
74 geometry::get_as_radian<1>(p1),
75 geometry::get_as_radian<0>(p2),
76 geometry::get_as_radian<1>(p2),
77 m_spheroid);
78
79 azi = res.azimuth;
80 razi = res.reverse_azimuth;
81
82 return true;
83 }
84
85 template <typename Point>
86 inline typename result_type<Point>::type
87 apply(Point const& /*p0*/, Point const& /*p1*/, Point const& /*p2*/,
88 typename result_type<Point>::type const& azi1,
89 typename result_type<Point>::type const& azi2) const
90 {
91 // TODO: support poles
92 return math::longitude_distance_signed<radian>(azi1, azi2);
93 }
94
95 private:
96 template <typename Point>
97 static bool equals_point_point(Point const& p0, Point const& p1)
98 {
99 return strategy::within::spherical_point_point::apply(p0, p1);
100 }
101
102 Spheroid m_spheroid;
103 };
104
105 namespace services
106 {
107
108 template <>
109 struct default_strategy<geographic_tag>
110 {
111 typedef geographic<> type;
112 };
113
114 } // namespace services
115
116 }} // namespace strategy::point_order
117
118 }} // namespace boost::geometry
119
120 #endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_POINT_ORDER_HPP