1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
5 // This file was modified by Oracle on 2014.
6 // Modifications copyright (c) 2014, Oracle and/or its affiliates.
8 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
10 // Use, modification and distribution is subject to the Boost Software License,
11 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
12 // http://www.boost.org/LICENSE_1_0.txt)
14 #ifndef BOOST_GEOMETRY_STRATEGIES_SPHERICAL_SIDE_BY_CROSS_TRACK_HPP
15 #define BOOST_GEOMETRY_STRATEGIES_SPHERICAL_SIDE_BY_CROSS_TRACK_HPP
17 #include <boost/geometry/core/cs.hpp>
18 #include <boost/geometry/core/access.hpp>
19 #include <boost/geometry/core/radian_access.hpp>
21 #include <boost/geometry/algorithms/detail/course.hpp>
23 #include <boost/geometry/util/math.hpp>
24 #include <boost/geometry/util/promote_floating_point.hpp>
25 #include <boost/geometry/util/select_calculation_type.hpp>
27 #include <boost/geometry/strategies/side.hpp>
28 //#include <boost/geometry/strategies/concepts/side_concept.hpp>
31 namespace boost { namespace geometry
35 namespace strategy { namespace side
39 \brief Check at which side of a Great Circle segment a point lies
40 left of segment (> 0), right of segment (< 0), on segment (0)
42 \tparam CalculationType \tparam_calculation
44 template <typename CalculationType = void>
45 class side_by_cross_track
49 template <typename P1, typename P2, typename P>
50 static inline int apply(P1 const& p1, P2 const& p2, P const& p)
52 typedef typename promote_floating_point
54 typename select_calculation_type_alt
61 calc_t d1 = 0.001; // m_strategy.apply(sp1, p);
62 calc_t crs_AD = geometry::detail::course<calc_t>(p1, p);
63 calc_t crs_AB = geometry::detail::course<calc_t>(p1, p2);
64 calc_t XTD = asin(sin(d1) * sin(crs_AD - crs_AB));
66 return math::equals(XTD, 0) ? 0 : XTD < 0 ? 1 : -1;
70 }} // namespace strategy::side
73 }} // namespace boost::geometry
76 #endif // BOOST_GEOMETRY_STRATEGIES_SPHERICAL_SIDE_BY_CROSS_TRACK_HPP