File indexing completed on 2025-01-18 09:35:25
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
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
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 }}}
0071
0072 #endif