Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:36:45

0001 // Boost.Geometry (aka GGL, Generic Geometry Library)
0002 
0003 // Copyright (c) 2016-2021 Oracle and/or its affiliates.
0004 // Contributed and/or modified by Vissarion Fisikopoulos, on behalf of Oracle
0005 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0006 
0007 // Use, modification and distribution is subject to the Boost Software License,
0008 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0009 // http://www.boost.org/LICENSE_1_0.txt)
0010 
0011 #ifndef BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_AZIMUTH_HPP
0012 #define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_AZIMUTH_HPP
0013 
0014 
0015 #include <type_traits>
0016 
0017 #include <boost/geometry/srs/spheroid.hpp>
0018 
0019 #include <boost/geometry/strategies/azimuth.hpp>
0020 #include <boost/geometry/strategies/geographic/parameters.hpp>
0021 
0022 #include <boost/geometry/util/select_most_precise.hpp>
0023 
0024 
0025 namespace boost { namespace geometry
0026 {
0027 
0028 namespace strategy { namespace azimuth
0029 {
0030 
0031 template
0032 <
0033     typename FormulaPolicy = strategy::andoyer,
0034     typename Spheroid = srs::spheroid<double>,
0035     typename CalculationType = void
0036 >
0037 class geographic
0038 {
0039 public:
0040     template <typename T1, typename T2>
0041     struct result_type
0042         : geometry::select_most_precise
0043               <
0044                   T1, T2, CalculationType
0045               >
0046     {};
0047 
0048     typedef Spheroid model_type;
0049 
0050     inline geographic()
0051         : m_spheroid()
0052     {}
0053 
0054     explicit inline geographic(Spheroid const& spheroid)
0055         : m_spheroid(spheroid)
0056     {}
0057 
0058     inline model_type const& model() const
0059     {
0060         return m_spheroid;
0061     }
0062 
0063     template <typename T1, typename T2, typename Result>
0064     inline void apply(T1 const& lon1_rad, T1 const& lat1_rad,
0065                       T2 const& lon2_rad, T2 const& lat2_rad,
0066                       Result& a1, Result& a2) const
0067     {
0068         compute<true, true>(lon1_rad, lat1_rad,
0069                             lon2_rad, lat2_rad,
0070                             a1, a2);
0071     }
0072     template <typename T1, typename T2, typename Result>
0073     inline void apply(T1 const& lon1_rad, T1 const& lat1_rad,
0074                       T2 const& lon2_rad, T2 const& lat2_rad,
0075                       Result& a1) const
0076     {
0077         compute<true, false>(lon1_rad, lat1_rad,
0078                              lon2_rad, lat2_rad,
0079                              a1, a1);
0080     }
0081     template <typename T1, typename T2, typename Result>
0082     inline void apply_reverse(T1 const& lon1_rad, T1 const& lat1_rad,
0083                               T2 const& lon2_rad, T2 const& lat2_rad,
0084                               Result& a2) const
0085     {
0086         compute<false, true>(lon1_rad, lat1_rad,
0087                              lon2_rad, lat2_rad,
0088                              a2, a2);
0089     }
0090 
0091 private :
0092 
0093     template
0094     <
0095         bool EnableAzimuth,
0096         bool EnableReverseAzimuth,
0097         typename T1, typename T2, typename Result
0098     >
0099     inline void compute(T1 const& lon1_rad, T1 const& lat1_rad,
0100                         T2 const& lon2_rad, T2 const& lat2_rad,
0101                         Result& a1, Result& a2) const
0102     {
0103         typedef typename result_type<T1, T2>::type calc_t;
0104 
0105         typedef typename FormulaPolicy::template inverse
0106             <
0107                 calc_t,
0108                 false,
0109                 EnableAzimuth,
0110                 EnableReverseAzimuth,
0111                 false,
0112                 false
0113             > inverse_type;
0114         typedef typename inverse_type::result_type inverse_result;
0115         inverse_result i_res = inverse_type::apply(calc_t(lon1_rad), calc_t(lat1_rad),
0116                                                    calc_t(lon2_rad), calc_t(lat2_rad),
0117                                                    m_spheroid);
0118         if (EnableAzimuth)
0119         {
0120             a1 = i_res.azimuth;
0121         }
0122         if (EnableReverseAzimuth)
0123         {
0124             a2 = i_res.reverse_azimuth;
0125         }
0126     }
0127 
0128     Spheroid m_spheroid;
0129 };
0130 
0131 #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
0132 
0133 namespace services
0134 {
0135 
0136 template <>
0137 struct default_strategy<geographic_tag>
0138 {
0139     typedef strategy::azimuth::geographic
0140         <
0141             strategy::andoyer,
0142             srs::spheroid<double>
0143         > type;
0144 };
0145 
0146 }
0147 
0148 #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
0149 
0150 }} // namespace strategy::azimuth
0151 
0152 
0153 }} // namespace boost::geometry
0154 
0155 #endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_AZIMUTH_HPP