Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:35:25

0001 // Boost.Geometry
0002 
0003 // Copyright (c) 2017-2018 Oracle and/or its affiliates.
0004 
0005 // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
0006 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0007 
0008 // Use, modification and distribution is subject to the Boost Software License,
0009 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0010 // http://www.boost.org/LICENSE_1_0.txt)
0011 
0012 #ifndef BOOST_GEOMETRY_FORMULAS_MERIDIAN_SEGMENT_HPP
0013 #define BOOST_GEOMETRY_FORMULAS_MERIDIAN_SEGMENT_HPP
0014 
0015 #include <boost/math/constants/constants.hpp>
0016 
0017 #include <boost/geometry/core/radius.hpp>
0018 
0019 #include <boost/geometry/util/condition.hpp>
0020 #include <boost/geometry/util/math.hpp>
0021 #include <boost/geometry/util/normalize_spheroidal_coordinates.hpp>
0022 
0023 namespace boost { namespace geometry { namespace formula
0024 {
0025 
0026 /*!
0027 \brief Test if a segment is meridian or not.
0028 */
0029 
0030 class meridian_segment
0031 {
0032 
0033 public :
0034 
0035     enum SegmentType {NonMeridian, MeridianCrossingPole, MeridianNotCrossingPole};
0036 
0037     template <typename T>
0038     static inline SegmentType is_meridian(T lon1, T lat1, T lon2, T lat2)
0039     {
0040         SegmentType res = NonMeridian;
0041         T diff = geometry::math::longitude_distance_signed<geometry::radian>(lon1, lon2);
0042 
0043         if ( meridian_not_crossing_pole(lat1, lat2, diff) )
0044         {
0045             res = MeridianNotCrossingPole;
0046         }
0047         else if ( meridian_crossing_pole(diff) )
0048         {
0049             res = MeridianCrossingPole;
0050         }
0051         return res;
0052     }
0053 
0054     template <typename T>
0055     static bool meridian_not_crossing_pole(T lat1, T lat2, T diff)
0056     {
0057         T half_pi = math::half_pi<T>();
0058         return math::equals(diff, T(0)) ||
0059                (math::equals(lat2, half_pi) && math::equals(lat1, -half_pi));
0060     }
0061 
0062     template <typename T>
0063     static bool meridian_crossing_pole(T diff)
0064     {
0065         return math::equals(math::abs(diff), math::pi<T>());
0066     }
0067 
0068 };
0069 
0070 }}} // namespace boost::geometry::formula
0071 
0072 #endif //BOOST_GEOMETRY_FORMULAS_MERIDIAN_SEGMENT_HPP