]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/strategies/spherical/side_by_cross_track.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / geometry / strategies / spherical / side_by_cross_track.hpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2
3 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
4
5 // This file was modified by Oracle on 2014-2017.
6 // Modifications copyright (c) 2014-2017, Oracle and/or its affiliates.
7
8 // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
9 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
10
11 // Use, modification and distribution is subject to the Boost Software License,
12 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
13 // http://www.boost.org/LICENSE_1_0.txt)
14
15 #ifndef BOOST_GEOMETRY_STRATEGIES_SPHERICAL_SIDE_BY_CROSS_TRACK_HPP
16 #define BOOST_GEOMETRY_STRATEGIES_SPHERICAL_SIDE_BY_CROSS_TRACK_HPP
17
18 #include <boost/geometry/core/cs.hpp>
19 #include <boost/geometry/core/access.hpp>
20 #include <boost/geometry/core/radian_access.hpp>
21
22 #include <boost/geometry/formulas/spherical.hpp>
23
24 #include <boost/geometry/util/math.hpp>
25 #include <boost/geometry/util/promote_floating_point.hpp>
26 #include <boost/geometry/util/select_calculation_type.hpp>
27
28 #include <boost/geometry/strategies/side.hpp>
29 //#include <boost/geometry/strategies/concepts/side_concept.hpp>
30
31
32 namespace boost { namespace geometry
33 {
34
35
36 namespace strategy { namespace side
37 {
38
39 /*!
40 \brief Check at which side of a Great Circle segment a point lies
41 left of segment (> 0), right of segment (< 0), on segment (0)
42 \ingroup strategies
43 \tparam CalculationType \tparam_calculation
44 */
45 template <typename CalculationType = void>
46 class side_by_cross_track
47 {
48
49 public :
50 template <typename P1, typename P2, typename P>
51 static inline int apply(P1 const& p1, P2 const& p2, P const& p)
52 {
53 typedef typename promote_floating_point
54 <
55 typename select_calculation_type_alt
56 <
57 CalculationType,
58 P1, P2, P
59 >::type
60 >::type calc_t;
61
62 calc_t d1 = 0.001; // m_strategy.apply(sp1, p);
63
64 calc_t lon1 = geometry::get_as_radian<0>(p1);
65 calc_t lat1 = geometry::get_as_radian<1>(p1);
66 calc_t lon2 = geometry::get_as_radian<0>(p2);
67 calc_t lat2 = geometry::get_as_radian<1>(p2);
68 calc_t lon = geometry::get_as_radian<0>(p);
69 calc_t lat = geometry::get_as_radian<1>(p);
70
71 calc_t crs_AD = geometry::formula::spherical_azimuth<calc_t, false>
72 (lon1, lat1, lon, lat).azimuth;
73
74 calc_t crs_AB = geometry::formula::spherical_azimuth<calc_t, false>
75 (lon1, lat1, lon2, lat2).azimuth;
76
77 calc_t XTD = asin(sin(d1) * sin(crs_AD - crs_AB));
78
79 return math::equals(XTD, 0) ? 0 : XTD < 0 ? 1 : -1;
80 }
81 };
82
83 }} // namespace strategy::side
84
85
86 }} // namespace boost::geometry
87
88
89 #endif // BOOST_GEOMETRY_STRATEGIES_SPHERICAL_SIDE_BY_CROSS_TRACK_HPP