]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/strategies/geographic/side.hpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / boost / geometry / strategies / geographic / side.hpp
1 // Boost.Geometry
2
3 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
4
5 // This file was modified by Oracle on 2014-2020.
6 // Modifications copyright (c) 2014-2020 Oracle and/or its affiliates.
7
8 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
9
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)
13
14 #ifndef BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_SIDE_HPP
15 #define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_SIDE_HPP
16
17 #include <boost/geometry/core/cs.hpp>
18 #include <boost/geometry/core/access.hpp>
19 #include <boost/geometry/core/radian_access.hpp>
20 #include <boost/geometry/core/radius.hpp>
21
22 #include <boost/geometry/formulas/spherical.hpp>
23
24 #include <boost/geometry/srs/spheroid.hpp>
25
26 #include <boost/geometry/util/math.hpp>
27 #include <boost/geometry/util/promote_floating_point.hpp>
28 #include <boost/geometry/util/select_calculation_type.hpp>
29
30 #include <boost/geometry/strategy/geographic/envelope.hpp>
31
32 #include <boost/geometry/strategies/geographic/disjoint_segment_box.hpp>
33 #include <boost/geometry/strategies/geographic/parameters.hpp>
34 #include <boost/geometry/strategies/side.hpp>
35 #include <boost/geometry/strategies/spherical/point_in_point.hpp>
36 //#include <boost/geometry/strategies/concepts/side_concept.hpp>
37
38
39 namespace boost { namespace geometry
40 {
41
42
43 namespace strategy { namespace side
44 {
45
46
47 /*!
48 \brief Check at which side of a segment a point lies
49 left of segment (> 0), right of segment (< 0), on segment (0)
50 \ingroup strategies
51 \tparam FormulaPolicy Geodesic solution formula policy.
52 \tparam Spheroid Reference model of coordinate system.
53 \tparam CalculationType \tparam_calculation
54
55 \qbk{
56 [heading See also]
57 [link geometry.reference.srs.srs_spheroid srs::spheroid]
58 }
59 */
60 template
61 <
62 typename FormulaPolicy = strategy::andoyer,
63 typename Spheroid = srs::spheroid<double>,
64 typename CalculationType = void
65 >
66 class geographic
67 {
68 public:
69 typedef geographic_tag cs_tag;
70
71 typedef strategy::envelope::geographic
72 <
73 FormulaPolicy,
74 Spheroid,
75 CalculationType
76 > envelope_strategy_type;
77
78 inline envelope_strategy_type get_envelope_strategy() const
79 {
80 return envelope_strategy_type(m_model);
81 }
82
83 typedef strategy::disjoint::segment_box_geographic
84 <
85 FormulaPolicy,
86 Spheroid,
87 CalculationType
88 > disjoint_strategy_type;
89
90 inline disjoint_strategy_type get_disjoint_strategy() const
91 {
92 return disjoint_strategy_type(m_model);
93 }
94
95 typedef strategy::within::spherical_point_point equals_point_point_strategy_type;
96 static inline equals_point_point_strategy_type get_equals_point_point_strategy()
97 {
98 return equals_point_point_strategy_type();
99 }
100
101 geographic()
102 {}
103
104 explicit geographic(Spheroid const& model)
105 : m_model(model)
106 {}
107
108 template <typename P1, typename P2, typename P>
109 inline int apply(P1 const& p1, P2 const& p2, P const& p) const
110 {
111 typedef typename promote_floating_point
112 <
113 typename select_calculation_type_alt
114 <
115 CalculationType,
116 P1, P2, P
117 >::type
118 >::type calc_t;
119
120 typedef typename FormulaPolicy::template inverse
121 <calc_t, false, true, false, false, false> inverse_formula;
122
123 calc_t a1p = azimuth<calc_t, inverse_formula>(p1, p, m_model);
124 calc_t a12 = azimuth<calc_t, inverse_formula>(p1, p2, m_model);
125
126 return formula::azimuth_side_value(a1p, a12);
127 }
128
129 Spheroid const& model() const
130 {
131 return m_model;
132 }
133
134 private:
135 template <typename ResultType,
136 typename InverseFormulaType,
137 typename Point1,
138 typename Point2,
139 typename ModelT>
140 static inline ResultType azimuth(Point1 const& point1, Point2 const& point2,
141 ModelT const& model)
142 {
143 return InverseFormulaType::apply(get_as_radian<0>(point1),
144 get_as_radian<1>(point1),
145 get_as_radian<0>(point2),
146 get_as_radian<1>(point2),
147 model).azimuth;
148 }
149
150 Spheroid m_model;
151 };
152
153
154 }} // namespace strategy::side
155
156
157 }} // namespace boost::geometry
158
159
160 #endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_SIDE_HPP