Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Boost.Geometry (aka GGL, Generic Geometry Library)
0002 
0003 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
0004 
0005 // This file was modified by Oracle on 2014-2021.
0006 // Modifications copyright (c) 2014-2021, Oracle and/or its affiliates.
0007 
0008 // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
0009 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0010 
0011 // Use, modification and distribution is subject to the Boost Software License,
0012 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0013 // http://www.boost.org/LICENSE_1_0.txt)
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 //#include <boost/geometry/strategies/concepts/side_concept.hpp>
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 \brief Check at which side of a Great Circle segment a point lies
0041          left of segment (> 0), right of segment (< 0), on segment (0)
0042 \ingroup strategies
0043 \tparam CalculationType \tparam_calculation
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; // m_strategy.apply(sp1, p);
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 }} // namespace strategy::side
0093 
0094 
0095 }} // namespace boost::geometry
0096 
0097 
0098 #endif // BOOST_GEOMETRY_STRATEGIES_SPHERICAL_SIDE_BY_CROSS_TRACK_HPP