]>
Commit | Line | Data |
---|---|---|
b32b8144 FG |
1 | // Boost.Geometry (aka GGL, Generic Geometry Library) |
2 | ||
20effc67 | 3 | // Copyright (c) 2016-2020 Oracle and/or its affiliates. |
b32b8144 FG |
4 | // Contributed and/or modified by Vissarion Fisikopoulos, on behalf of Oracle |
5 | // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle | |
6 | ||
7 | // Use, modification and distribution is subject to the Boost Software License, | |
8 | // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | |
9 | // http://www.boost.org/LICENSE_1_0.txt) | |
10 | ||
11 | #ifndef BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_AZIMUTH_HPP | |
12 | #define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_AZIMUTH_HPP | |
13 | ||
14 | ||
20effc67 TL |
15 | #include <type_traits> |
16 | ||
11fdf7f2 | 17 | #include <boost/geometry/srs/spheroid.hpp> |
b32b8144 FG |
18 | |
19 | #include <boost/geometry/strategies/azimuth.hpp> | |
20 | #include <boost/geometry/strategies/geographic/parameters.hpp> | |
21 | ||
b32b8144 FG |
22 | |
23 | namespace boost { namespace geometry | |
24 | { | |
25 | ||
26 | namespace strategy { namespace azimuth | |
27 | { | |
28 | ||
29 | template | |
30 | < | |
31 | typename FormulaPolicy = strategy::andoyer, | |
32 | typename Spheroid = srs::spheroid<double>, | |
33 | typename CalculationType = void | |
34 | > | |
35 | class geographic | |
36 | { | |
37 | public : | |
38 | ||
39 | typedef Spheroid model_type; | |
40 | ||
41 | inline geographic() | |
42 | : m_spheroid() | |
43 | {} | |
44 | ||
45 | explicit inline geographic(Spheroid const& spheroid) | |
46 | : m_spheroid(spheroid) | |
47 | {} | |
48 | ||
49 | inline model_type const& model() const | |
50 | { | |
51 | return m_spheroid; | |
52 | } | |
53 | ||
54 | template <typename T> | |
55 | inline void apply(T const& lon1_rad, T const& lat1_rad, | |
56 | T const& lon2_rad, T const& lat2_rad, | |
57 | T& a1, T& a2) const | |
58 | { | |
92f5a8d4 TL |
59 | compute<true, true>(lon1_rad, lat1_rad, |
60 | lon2_rad, lat2_rad, | |
61 | a1, a2); | |
b32b8144 | 62 | } |
b32b8144 FG |
63 | template <typename T> |
64 | inline void apply(T const& lon1_rad, T const& lat1_rad, | |
65 | T const& lon2_rad, T const& lat2_rad, | |
66 | T& a1) const | |
92f5a8d4 TL |
67 | { |
68 | compute<true, false>(lon1_rad, lat1_rad, | |
69 | lon2_rad, lat2_rad, | |
70 | a1, a1); | |
71 | } | |
72 | template <typename T> | |
73 | inline void apply_reverse(T const& lon1_rad, T const& lat1_rad, | |
74 | T const& lon2_rad, T const& lat2_rad, | |
75 | T& a2) const | |
76 | { | |
77 | compute<false, true>(lon1_rad, lat1_rad, | |
78 | lon2_rad, lat2_rad, | |
79 | a2, a2); | |
80 | } | |
81 | ||
82 | private : | |
83 | ||
20effc67 TL |
84 | template |
85 | < | |
92f5a8d4 TL |
86 | bool EnableAzimuth, |
87 | bool EnableReverseAzimuth, | |
88 | typename T | |
89 | > | |
90 | inline void compute(T const& lon1_rad, T const& lat1_rad, | |
91 | T const& lon2_rad, T const& lat2_rad, | |
92 | T& a1, T& a2) const | |
b32b8144 | 93 | { |
20effc67 | 94 | typedef std::conditional_t |
92f5a8d4 | 95 | < |
20effc67 TL |
96 | std::is_void<CalculationType>::value, T, CalculationType |
97 | > calc_t; | |
b32b8144 | 98 | |
92f5a8d4 | 99 | typedef typename FormulaPolicy::template inverse |
20effc67 TL |
100 | < |
101 | calc_t, | |
102 | false, | |
103 | EnableAzimuth, | |
104 | EnableReverseAzimuth, | |
105 | false, | |
106 | false | |
107 | > inverse_type; | |
b32b8144 FG |
108 | typedef typename inverse_type::result_type inverse_result; |
109 | inverse_result i_res = inverse_type::apply(calc_t(lon1_rad), calc_t(lat1_rad), | |
110 | calc_t(lon2_rad), calc_t(lat2_rad), | |
111 | m_spheroid); | |
92f5a8d4 TL |
112 | if (EnableAzimuth) |
113 | { | |
114 | a1 = i_res.azimuth; | |
115 | } | |
116 | if (EnableReverseAzimuth) | |
117 | { | |
118 | a2 = i_res.reverse_azimuth; | |
119 | } | |
b32b8144 FG |
120 | } |
121 | ||
b32b8144 FG |
122 | Spheroid m_spheroid; |
123 | }; | |
124 | ||
125 | #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS | |
126 | ||
127 | namespace services | |
128 | { | |
129 | ||
130 | template <typename CalculationType> | |
131 | struct default_strategy<geographic_tag, CalculationType> | |
132 | { | |
133 | typedef strategy::azimuth::geographic | |
134 | < | |
135 | strategy::andoyer, | |
136 | srs::spheroid<double>, | |
137 | CalculationType | |
138 | > type; | |
139 | }; | |
140 | ||
141 | } | |
142 | ||
143 | #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS | |
144 | ||
145 | }} // namespace strategy::azimuth | |
146 | ||
147 | ||
148 | }} // namespace boost::geometry | |
149 | ||
150 | #endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_AZIMUTH_HPP |