File indexing completed on 2025-01-18 09:36:49
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef BOOST_GEOMETRY_STRATEGIES_SPHERICAL_SIDE_BY_CROSS_TRACK_HPP
0016 #define BOOST_GEOMETRY_STRATEGIES_SPHERICAL_SIDE_BY_CROSS_TRACK_HPP
0017
0018 #include <boost/geometry/core/access.hpp>
0019 #include <boost/geometry/core/coordinate_promotion.hpp>
0020 #include <boost/geometry/core/cs.hpp>
0021 #include <boost/geometry/core/radian_access.hpp>
0022
0023 #include <boost/geometry/formulas/spherical.hpp>
0024
0025
0026 #include <boost/geometry/strategies/side.hpp>
0027 #include <boost/geometry/strategies/spherical/point_in_point.hpp>
0028
0029 #include <boost/geometry/util/math.hpp>
0030 #include <boost/geometry/util/select_calculation_type.hpp>
0031
0032 namespace boost { namespace geometry
0033 {
0034
0035
0036 namespace strategy { namespace side
0037 {
0038
0039
0040
0041
0042
0043
0044
0045 template <typename CalculationType = void>
0046 class side_by_cross_track
0047 {
0048
0049 public :
0050 template <typename P1, typename P2, typename P>
0051 static inline int apply(P1 const& p1, P2 const& p2, P const& p)
0052 {
0053 typedef strategy::within::spherical_point_point
0054 equals_point_point_strategy_type;
0055 if (equals_point_point_strategy_type::apply(p, p1)
0056 || equals_point_point_strategy_type::apply(p, p2)
0057 || equals_point_point_strategy_type::apply(p1, p2))
0058 {
0059 return 0;
0060 }
0061
0062 typedef typename promote_floating_point
0063 <
0064 typename select_calculation_type_alt
0065 <
0066 CalculationType,
0067 P1, P2, P
0068 >::type
0069 >::type calc_t;
0070
0071 calc_t d1 = 0.001;
0072
0073 calc_t lon1 = geometry::get_as_radian<0>(p1);
0074 calc_t lat1 = geometry::get_as_radian<1>(p1);
0075 calc_t lon2 = geometry::get_as_radian<0>(p2);
0076 calc_t lat2 = geometry::get_as_radian<1>(p2);
0077 calc_t lon = geometry::get_as_radian<0>(p);
0078 calc_t lat = geometry::get_as_radian<1>(p);
0079
0080 calc_t crs_AD = geometry::formula::spherical_azimuth<calc_t, false>
0081 (lon1, lat1, lon, lat).azimuth;
0082
0083 calc_t crs_AB = geometry::formula::spherical_azimuth<calc_t, false>
0084 (lon1, lat1, lon2, lat2).azimuth;
0085
0086 calc_t XTD = asin(sin(d1) * sin(crs_AD - crs_AB));
0087
0088 return math::equals(XTD, 0) ? 0 : XTD < 0 ? 1 : -1;
0089 }
0090 };
0091
0092 }}
0093
0094
0095 }}
0096
0097
0098 #endif