• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 
3 // Copyright (c) 2016-2017 Oracle and/or its affiliates.
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 
15 #include <boost/geometry/strategies/azimuth.hpp>
16 #include <boost/geometry/formulas/spherical.hpp>
17 
18 #include <boost/mpl/if.hpp>
19 #include <boost/type_traits/is_void.hpp>
20 
21 
22 namespace boost { namespace geometry
23 {
24 
25 namespace strategy { namespace azimuth
26 {
27 
28 template
29 <
30     typename CalculationType = void
31 >
32 class spherical
33 {
34 public :
35 
spherical()36     inline spherical()
37     {}
38 
39     template <typename T>
apply(T const & lon1_rad,T const & lat1_rad,T const & lon2_rad,T const & lat2_rad,T & a1,T & a2) const40     inline void apply(T const& lon1_rad, T const& lat1_rad,
41                       T const& lon2_rad, T const& lat2_rad,
42                       T& a1, T& a2) const
43     {
44         compute<true, true>(lon1_rad, lat1_rad,
45                             lon2_rad, lat2_rad,
46                             a1, a2);
47     }
48     template <typename T>
apply(T const & lon1_rad,T const & lat1_rad,T const & lon2_rad,T const & lat2_rad,T & a1) const49     inline void apply(T const& lon1_rad, T const& lat1_rad,
50                       T const& lon2_rad, T const& lat2_rad,
51                       T& a1) const
52     {
53         compute<true, false>(lon1_rad, lat1_rad,
54                              lon2_rad, lat2_rad,
55                              a1, a1);
56     }
57     template <typename T>
apply_reverse(T const & lon1_rad,T const & lat1_rad,T const & lon2_rad,T const & lat2_rad,T & a2) const58     inline void apply_reverse(T const& lon1_rad, T const& lat1_rad,
59                               T const& lon2_rad, T const& lat2_rad,
60                               T& a2) const
61     {
62         compute<false, true>(lon1_rad, lat1_rad,
63                              lon2_rad, lat2_rad,
64                              a2, a2);
65     }
66 
67 private :
68 
69     template
70     <
71         bool EnableAzimuth,
72         bool EnableReverseAzimuth,
73         typename T
74     >
compute(T const & lon1_rad,T const & lat1_rad,T const & lon2_rad,T const & lat2_rad,T & a1,T & a2) const75     inline void compute(T const& lon1_rad, T const& lat1_rad,
76                         T const& lon2_rad, T const& lat2_rad,
77                         T& a1, T& a2) const
78     {
79         typedef typename boost::mpl::if_
80             <
81                 boost::is_void<CalculationType>, T, CalculationType
82             >::type calc_t;
83 
84         geometry::formula::result_spherical<calc_t>
85             result = geometry::formula::spherical_azimuth
86                      <
87                         calc_t,
88                         EnableReverseAzimuth
89                      >(calc_t(lon1_rad), calc_t(lat1_rad),
90                        calc_t(lon2_rad), calc_t(lat2_rad));
91 
92         if (EnableAzimuth)
93         {
94             a1 = result.azimuth;
95         }
96         if (EnableReverseAzimuth)
97         {
98             a2 = result.reverse_azimuth;
99         }
100     }
101 };
102 
103 #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
104 
105 namespace services
106 {
107 
108 template <typename CalculationType>
109 struct default_strategy<spherical_equatorial_tag, CalculationType>
110 {
111     typedef strategy::azimuth::spherical<CalculationType> type;
112 };
113 
114 /*
115 template <typename CalculationType>
116 struct default_strategy<spherical_polar_tag, CalculationType>
117 {
118     typedef strategy::azimuth::spherical<CalculationType> type;
119 };
120 */
121 }
122 
123 #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
124 
125 }} // namespace strategy::azimuth
126 
127 
128 }} // namespace boost::geometry
129 
130 #endif // BOOST_GEOMETRY_STRATEGIES_SPHERICAL_AZIMUTH_HPP
131