Back to home page

EIC code displayed by LXR

 
 

    


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

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_SPHERICAL_AZIMUTH_HPP
0012 #define BOOST_GEOMETRY_STRATEGIES_SPHERICAL_AZIMUTH_HPP
0013 
0014 
0015 #include <type_traits>
0016 
0017 #include <boost/geometry/formulas/spherical.hpp>
0018 
0019 #include <boost/geometry/strategies/azimuth.hpp>
0020 
0021 #include <boost/geometry/util/select_most_precise.hpp>
0022 
0023 
0024 namespace boost { namespace geometry
0025 {
0026 
0027 namespace strategy { namespace azimuth
0028 {
0029 
0030 template <typename CalculationType = void>
0031 class spherical
0032 {
0033 public:
0034     template <typename T1, typename T2>
0035     struct result_type
0036         : geometry::select_most_precise
0037               <
0038                   T1, T2, CalculationType
0039               >
0040     {};
0041 
0042     template <typename T1, typename T2, typename Result>
0043     static inline void apply(T1 const& lon1_rad, T1 const& lat1_rad,
0044                              T2 const& lon2_rad, T2 const& lat2_rad,
0045                              Result& a1, Result& a2)
0046     {
0047         compute<true, true>(lon1_rad, lat1_rad,
0048                             lon2_rad, lat2_rad,
0049                             a1, a2);
0050     }
0051     template <typename T1, typename T2, typename Result>
0052     static inline void apply(T1 const& lon1_rad, T1 const& lat1_rad,
0053                              T2 const& lon2_rad, T2 const& lat2_rad,
0054                              Result& a1)
0055     {
0056         compute<true, false>(lon1_rad, lat1_rad,
0057                              lon2_rad, lat2_rad,
0058                              a1, a1);
0059     }
0060     template <typename T1, typename T2, typename Result>
0061     static inline void apply_reverse(T1 const& lon1_rad, T1 const& lat1_rad,
0062                                      T2 const& lon2_rad, T2 const& lat2_rad,
0063                                      Result& a2)
0064     {
0065         compute<false, true>(lon1_rad, lat1_rad,
0066                              lon2_rad, lat2_rad,
0067                              a2, a2);
0068     }
0069 
0070 private:
0071     template
0072     <
0073         bool EnableAzimuth,
0074         bool EnableReverseAzimuth,
0075         typename T1, typename T2, typename Result
0076     >
0077     static inline void compute(T1 const& lon1_rad, T1 const& lat1_rad,
0078                                T2 const& lon2_rad, T2 const& lat2_rad,
0079                                Result& a1, Result& a2)
0080     {
0081         typedef typename result_type<T1, T2>::type calc_t;
0082 
0083         geometry::formula::result_spherical<calc_t>
0084             result = geometry::formula::spherical_azimuth
0085                      <
0086                         calc_t,
0087                         EnableReverseAzimuth
0088                      >(calc_t(lon1_rad), calc_t(lat1_rad),
0089                        calc_t(lon2_rad), calc_t(lat2_rad));
0090 
0091         if (EnableAzimuth)
0092         {
0093             a1 = result.azimuth;
0094         }
0095         if (EnableReverseAzimuth)
0096         {
0097             a2 = result.reverse_azimuth;
0098         }
0099     }
0100 };
0101 
0102 #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
0103 
0104 namespace services
0105 {
0106 
0107 template <>
0108 struct default_strategy<spherical_equatorial_tag>
0109 {
0110     typedef strategy::azimuth::spherical<> type;
0111 };
0112 
0113 }
0114 
0115 #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
0116 
0117 }} // namespace strategy::azimuth
0118 
0119 
0120 }} // namespace boost::geometry
0121 
0122 #endif // BOOST_GEOMETRY_STRATEGIES_SPHERICAL_AZIMUTH_HPP