]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/strategies/geographic/index.hpp
202f0620df27c3b2a25f819b6303cf97e5cb0a5d
[ceph.git] / ceph / src / boost / boost / geometry / strategies / geographic / index.hpp
1 // Boost.Geometry Index
2 //
3 // R-tree strategies
4 //
5 // Copyright (c) 2019, Oracle and/or its affiliates.
6 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
7 //
8 // Use, modification and distribution is subject to the Boost Software License,
9 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
10 // http://www.boost.org/LICENSE_1_0.txt)
11
12 #ifndef BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_INDEX_HPP
13 #define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_INDEX_HPP
14
15
16 #include <boost/geometry/strategies/geographic/distance.hpp>
17 #include <boost/geometry/strategies/geographic/distance_andoyer.hpp> // backward compatibility
18 #include <boost/geometry/strategies/geographic/distance_cross_track.hpp>
19 #include <boost/geometry/strategies/geographic/distance_cross_track_point_box.hpp>
20 #include <boost/geometry/strategies/geographic/distance_segment_box.hpp>
21 #include <boost/geometry/strategies/geographic/distance_thomas.hpp> // backward compatibility
22 #include <boost/geometry/strategies/geographic/distance_vincenty.hpp> // backward compatibility
23 #include <boost/geometry/strategies/geographic/envelope_segment.hpp>
24 #include <boost/geometry/strategies/geographic/expand_segment.hpp>
25 #include <boost/geometry/strategies/geographic/intersection.hpp>
26 #include <boost/geometry/strategies/geographic/point_in_poly_winding.hpp>
27
28 #include <boost/geometry/strategies/spherical/index.hpp>
29
30
31 namespace boost { namespace geometry { namespace strategy { namespace index
32 {
33
34 template
35 <
36 typename FormulaPolicy = strategy::andoyer,
37 typename Spheroid = geometry::srs::spheroid<double>,
38 typename CalculationType = void
39 >
40 struct geographic
41 : spherical<CalculationType>
42 {
43 typedef geographic_tag cs_tag;
44
45 typedef geometry::strategy::envelope::geographic_segment
46 <
47 FormulaPolicy, Spheroid, CalculationType
48 > envelope_segment_strategy_type;
49
50 inline envelope_segment_strategy_type get_envelope_segment_strategy() const
51 {
52 return envelope_segment_strategy_type(m_spheroid);
53 }
54
55 typedef geometry::strategy::expand::geographic_segment
56 <
57 FormulaPolicy, Spheroid, CalculationType
58 > expand_segment_strategy_type;
59
60 inline expand_segment_strategy_type get_expand_segment_strategy() const
61 {
62 return expand_segment_strategy_type(m_spheroid);
63 }
64
65 // used in equals(Seg, Seg) but only to get_point_in_point_strategy()
66 typedef geometry::strategy::intersection::geographic_segments
67 <
68 FormulaPolicy,
69 // If index::geographic formula is derived from intersection::geographic_segments
70 // formula with different Order this may cause an inconsistency
71 strategy::default_order<FormulaPolicy>::value,
72 Spheroid,
73 CalculationType
74 > relate_segment_segment_strategy_type;
75
76 inline relate_segment_segment_strategy_type get_relate_segment_segment_strategy() const
77 {
78 return relate_segment_segment_strategy_type(m_spheroid);
79 }
80
81 typedef geometry::strategy::distance::geographic
82 <
83 FormulaPolicy, Spheroid, CalculationType
84 > comparable_distance_point_point_strategy_type;
85
86 inline comparable_distance_point_point_strategy_type get_comparable_distance_point_point_strategy() const
87 {
88 return comparable_distance_point_point_strategy_type(m_spheroid);
89 }
90
91 typedef geometry::strategy::distance::geographic_cross_track_point_box
92 <
93 FormulaPolicy, Spheroid, CalculationType
94 > comparable_distance_point_box_strategy_type;
95
96 inline comparable_distance_point_box_strategy_type get_comparable_distance_point_box_strategy() const
97 {
98 return comparable_distance_point_box_strategy_type(m_spheroid);
99 }
100
101 typedef geometry::strategy::distance::geographic_cross_track
102 <
103 FormulaPolicy, Spheroid, CalculationType
104 > comparable_distance_point_segment_strategy_type;
105
106 inline comparable_distance_point_segment_strategy_type get_comparable_distance_point_segment_strategy() const
107 {
108 return comparable_distance_point_segment_strategy_type(m_spheroid);
109 }
110
111 typedef geometry::strategy::distance::geographic_segment_box
112 <
113 FormulaPolicy, Spheroid, CalculationType
114 > comparable_distance_segment_box_strategy_type;
115
116 inline comparable_distance_segment_box_strategy_type get_comparable_distance_segment_box_strategy() const
117 {
118 return comparable_distance_segment_box_strategy_type(m_spheroid);
119 }
120
121 geographic()
122 : m_spheroid()
123 {}
124
125 explicit geographic(Spheroid const& spheroid)
126 : m_spheroid(spheroid)
127 {}
128
129 public:
130 Spheroid m_spheroid;
131 };
132
133
134 namespace services
135 {
136
137 template <typename Geometry>
138 struct default_strategy<Geometry, geographic_tag>
139 {
140 typedef geographic<> type;
141 };
142
143
144 // within and relate (MPt, Mls/MPoly)
145 template <typename Point1, typename Point2, typename Formula, typename Spheroid, typename CalculationType>
146 struct from_strategy<within::geographic_winding<Point1, Point2, Formula, Spheroid, CalculationType> >
147 {
148 typedef strategy::index::geographic<Formula, Spheroid, CalculationType> type;
149
150 static inline type get(within::geographic_winding<Point1, Point2, Formula, Spheroid, CalculationType> const& strategy)
151 {
152 return type(strategy.model());
153 }
154 };
155
156 // distance (MPt, MPt)
157 template <typename Formula, typename Spheroid, typename CalculationType>
158 struct from_strategy<distance::geographic<Formula, Spheroid, CalculationType> >
159 {
160 typedef strategy::index::geographic<Formula, Spheroid, CalculationType> type;
161
162 static inline type get(distance::geographic<Formula, Spheroid, CalculationType> const& strategy)
163 {
164 return type(strategy.model());
165 }
166 };
167 template <typename Spheroid, typename CalculationType>
168 struct from_strategy<distance::andoyer<Spheroid, CalculationType> >
169 {
170 typedef strategy::index::geographic<strategy::andoyer, Spheroid, CalculationType> type;
171
172 static inline type get(distance::andoyer<Spheroid, CalculationType> const& strategy)
173 {
174 return type(strategy.model());
175 }
176 };
177 template <typename Spheroid, typename CalculationType>
178 struct from_strategy<distance::thomas<Spheroid, CalculationType> >
179 {
180 typedef strategy::index::geographic<strategy::thomas, Spheroid, CalculationType> type;
181
182 static inline type get(distance::thomas<Spheroid, CalculationType> const& strategy)
183 {
184 return type(strategy.model());
185 }
186 };
187 template <typename Spheroid, typename CalculationType>
188 struct from_strategy<distance::vincenty<Spheroid, CalculationType> >
189 {
190 typedef strategy::index::geographic<strategy::vincenty, Spheroid, CalculationType> type;
191
192 static inline type get(distance::vincenty<Spheroid, CalculationType> const& strategy)
193 {
194 return type(strategy.model());
195 }
196 };
197
198 // distance (MPt, Linear/Areal)
199 template <typename Formula, typename Spheroid, typename CalculationType>
200 struct from_strategy<distance::geographic_cross_track<Formula, Spheroid, CalculationType> >
201 {
202 typedef strategy::index::geographic<Formula, Spheroid, CalculationType> type;
203
204 static inline type get(distance::geographic_cross_track<Formula, Spheroid, CalculationType> const& strategy)
205 {
206 return type(strategy.model());
207 }
208 };
209
210
211 } // namespace services
212
213
214 }}}} // namespace boost::geometry::strategy::index
215
216 #endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_INDEX_HPP