]>
Commit | Line | Data |
---|---|---|
b32b8144 FG |
1 | // Boost.Geometry (aka GGL, Generic Geometry Library) |
2 | ||
1e59de90 | 3 | // Copyright (c) 2016-2021 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_SPHERICAL_AZIMUTH_HPP | |
12 | #define BOOST_GEOMETRY_STRATEGIES_SPHERICAL_AZIMUTH_HPP | |
13 | ||
14 | ||
20effc67 TL |
15 | #include <type_traits> |
16 | ||
b32b8144 FG |
17 | #include <boost/geometry/formulas/spherical.hpp> |
18 | ||
1e59de90 TL |
19 | #include <boost/geometry/strategies/azimuth.hpp> |
20 | ||
21 | #include <boost/geometry/util/select_most_precise.hpp> | |
22 | ||
b32b8144 FG |
23 | |
24 | namespace boost { namespace geometry | |
25 | { | |
26 | ||
27 | namespace strategy { namespace azimuth | |
28 | { | |
29 | ||
1e59de90 | 30 | template <typename CalculationType = void> |
b32b8144 FG |
31 | class spherical |
32 | { | |
1e59de90 TL |
33 | public: |
34 | template <typename T1, typename T2> | |
35 | struct result_type | |
36 | : geometry::select_most_precise | |
37 | < | |
38 | T1, T2, CalculationType | |
39 | > | |
40 | {}; | |
41 | ||
42 | template <typename T1, typename T2, typename Result> | |
43 | static inline void apply(T1 const& lon1_rad, T1 const& lat1_rad, | |
44 | T2 const& lon2_rad, T2 const& lat2_rad, | |
45 | Result& a1, Result& a2) | |
b32b8144 | 46 | { |
92f5a8d4 TL |
47 | compute<true, true>(lon1_rad, lat1_rad, |
48 | lon2_rad, lat2_rad, | |
49 | a1, a2); | |
b32b8144 | 50 | } |
1e59de90 TL |
51 | template <typename T1, typename T2, typename Result> |
52 | static inline void apply(T1 const& lon1_rad, T1 const& lat1_rad, | |
53 | T2 const& lon2_rad, T2 const& lat2_rad, | |
54 | Result& a1) | |
b32b8144 | 55 | { |
92f5a8d4 TL |
56 | compute<true, false>(lon1_rad, lat1_rad, |
57 | lon2_rad, lat2_rad, | |
58 | a1, a1); | |
59 | } | |
1e59de90 TL |
60 | template <typename T1, typename T2, typename Result> |
61 | static inline void apply_reverse(T1 const& lon1_rad, T1 const& lat1_rad, | |
62 | T2 const& lon2_rad, T2 const& lat2_rad, | |
63 | Result& a2) | |
92f5a8d4 TL |
64 | { |
65 | compute<false, true>(lon1_rad, lat1_rad, | |
66 | lon2_rad, lat2_rad, | |
67 | a2, a2); | |
68 | } | |
69 | ||
1e59de90 | 70 | private: |
92f5a8d4 TL |
71 | template |
72 | < | |
73 | bool EnableAzimuth, | |
74 | bool EnableReverseAzimuth, | |
1e59de90 | 75 | typename T1, typename T2, typename Result |
92f5a8d4 | 76 | > |
1e59de90 TL |
77 | static inline void compute(T1 const& lon1_rad, T1 const& lat1_rad, |
78 | T2 const& lon2_rad, T2 const& lat2_rad, | |
79 | Result& a1, Result& a2) | |
92f5a8d4 | 80 | { |
1e59de90 | 81 | typedef typename result_type<T1, T2>::type calc_t; |
b32b8144 FG |
82 | |
83 | geometry::formula::result_spherical<calc_t> | |
92f5a8d4 TL |
84 | result = geometry::formula::spherical_azimuth |
85 | < | |
86 | calc_t, | |
87 | EnableReverseAzimuth | |
88 | >(calc_t(lon1_rad), calc_t(lat1_rad), | |
89 | calc_t(lon2_rad), calc_t(lat2_rad)); | |
90 | ||
91 | if (EnableAzimuth) | |
92 | { | |
93 | a1 = result.azimuth; | |
94 | } | |
95 | if (EnableReverseAzimuth) | |
96 | { | |
97 | a2 = result.reverse_azimuth; | |
98 | } | |
b32b8144 | 99 | } |
b32b8144 FG |
100 | }; |
101 | ||
102 | #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS | |
103 | ||
104 | namespace services | |
105 | { | |
106 | ||
1e59de90 TL |
107 | template <> |
108 | struct default_strategy<spherical_equatorial_tag> | |
b32b8144 | 109 | { |
1e59de90 | 110 | typedef strategy::azimuth::spherical<> type; |
b32b8144 FG |
111 | }; |
112 | ||
b32b8144 FG |
113 | } |
114 | ||
115 | #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS | |
116 | ||
117 | }} // namespace strategy::azimuth | |
118 | ||
119 | ||
120 | }} // namespace boost::geometry | |
121 | ||
122 | #endif // BOOST_GEOMETRY_STRATEGIES_SPHERICAL_AZIMUTH_HPP |