Imported Upstream version 1.64.0
[platform/upstream/boost.git] / boost / geometry / strategies / geographic / azimuth.hpp
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_GEOGRAPHIC_AZIMUTH_HPP
12 #define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_AZIMUTH_HPP
13
14
15 #include <boost/geometry/core/srs.hpp>
16
17 #include <boost/geometry/strategies/azimuth.hpp>
18 #include <boost/geometry/strategies/geographic/parameters.hpp>
19
20 #include <boost/mpl/if.hpp>
21 #include <boost/type_traits/is_void.hpp>
22
23
24 namespace boost { namespace geometry
25 {
26
27 namespace strategy { namespace azimuth
28 {
29
30 template
31 <
32     typename FormulaPolicy = strategy::andoyer,
33     typename Spheroid = srs::spheroid<double>,
34     typename CalculationType = void
35 >
36 class geographic
37 {
38 public :
39
40     typedef Spheroid model_type;
41
42     inline geographic()
43         : m_spheroid()
44     {}
45
46     explicit inline geographic(Spheroid const& spheroid)
47         : m_spheroid(spheroid)
48     {}
49
50     inline model_type const& model() const
51     {
52         return m_spheroid;
53     }
54
55     template <typename T>
56     inline void apply(T const& lon1_rad, T const& lat1_rad,
57                       T const& lon2_rad, T const& lat2_rad,
58                       T& a1, T& a2) const
59     {
60         typedef typename boost::mpl::if_
61             <
62                 boost::is_void<CalculationType>, T, CalculationType
63             >::type calc_t;            
64
65         typedef typename FormulaPolicy::template inverse<calc_t, false, true, true, false, false> inverse_type;
66         typedef typename inverse_type::result_type inverse_result;
67         inverse_result i_res = inverse_type::apply(calc_t(lon1_rad), calc_t(lat1_rad),
68                                                    calc_t(lon2_rad), calc_t(lat2_rad),
69                                                    m_spheroid);
70         a1 = i_res.azimuth;
71         a2 = i_res.reverse_azimuth;
72     }
73
74 private :
75     Spheroid m_spheroid;
76 };
77
78 #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
79
80 namespace services
81 {
82
83 template <typename CalculationType>
84 struct default_strategy<geographic_tag, CalculationType>
85 {
86     typedef strategy::azimuth::geographic
87         <
88             strategy::andoyer,
89             srs::spheroid<double>,
90             CalculationType
91         > type;
92 };
93
94 }
95
96 #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
97
98 }} // namespace strategy::azimuth
99
100
101 }} // namespace boost::geometry
102
103 #endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_AZIMUTH_HPP