1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- #ifndef BOOST_GEOMETRY_STRATEGIES_SPHERICAL_SIDE_BY_CROSS_TRACK_HPP
- #define BOOST_GEOMETRY_STRATEGIES_SPHERICAL_SIDE_BY_CROSS_TRACK_HPP
- #include <boost/geometry/core/access.hpp>
- #include <boost/geometry/core/coordinate_promotion.hpp>
- #include <boost/geometry/core/cs.hpp>
- #include <boost/geometry/core/radian_access.hpp>
- #include <boost/geometry/formulas/spherical.hpp>
- #include <boost/geometry/strategies/side.hpp>
- #include <boost/geometry/strategies/spherical/point_in_point.hpp>
- #include <boost/geometry/util/math.hpp>
- #include <boost/geometry/util/select_calculation_type.hpp>
- namespace boost { namespace geometry
- {
- namespace strategy { namespace side
- {
- template <typename CalculationType = void>
- class side_by_cross_track
- {
- public :
- template <typename P1, typename P2, typename P>
- static inline int apply(P1 const& p1, P2 const& p2, P const& p)
- {
- typedef strategy::within::spherical_point_point
- equals_point_point_strategy_type;
- if (equals_point_point_strategy_type::apply(p, p1)
- || equals_point_point_strategy_type::apply(p, p2)
- || equals_point_point_strategy_type::apply(p1, p2))
- {
- return 0;
- }
- typedef typename promote_floating_point
- <
- typename select_calculation_type_alt
- <
- CalculationType,
- P1, P2, P
- >::type
- >::type calc_t;
- calc_t d1 = 0.001;
- calc_t lon1 = geometry::get_as_radian<0>(p1);
- calc_t lat1 = geometry::get_as_radian<1>(p1);
- calc_t lon2 = geometry::get_as_radian<0>(p2);
- calc_t lat2 = geometry::get_as_radian<1>(p2);
- calc_t lon = geometry::get_as_radian<0>(p);
- calc_t lat = geometry::get_as_radian<1>(p);
- calc_t crs_AD = geometry::formula::spherical_azimuth<calc_t, false>
- (lon1, lat1, lon, lat).azimuth;
- calc_t crs_AB = geometry::formula::spherical_azimuth<calc_t, false>
- (lon1, lat1, lon2, lat2).azimuth;
- calc_t XTD = asin(sin(d1) * sin(crs_AD - crs_AB));
- return math::equals(XTD, 0) ? 0 : XTD < 0 ? 1 : -1;
- }
- };
- }}
- }}
- #endif
|