]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/algorithms/detail/within/implementation.hpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / boost / geometry / algorithms / detail / within / implementation.hpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2
3 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
4 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
5 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
6
7 // This file was modified by Oracle on 2013-2021.
8 // Modifications copyright (c) 2013-2021 Oracle and/or its affiliates.
9
10 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
11
12 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
13 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
14
15 // Use, modification and distribution is subject to the Boost Software License,
16 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
17 // http://www.boost.org/LICENSE_1_0.txt)
18
19 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_WITHIN_IMPLEMENTATION_HPP
20 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_WITHIN_IMPLEMENTATION_HPP
21
22 #include <cstddef>
23 #include <deque>
24
25 #include <boost/core/ignore_unused.hpp>
26
27 #include <boost/geometry/algorithms/detail/overlay/get_turns.hpp>
28 #include <boost/geometry/algorithms/detail/overlay/do_reverse.hpp>
29 #include <boost/geometry/algorithms/detail/within/interface.hpp>
30 #include <boost/geometry/algorithms/detail/within/multi_point.hpp>
31 #include <boost/geometry/algorithms/detail/within/point_in_geometry.hpp>
32 #include <boost/geometry/algorithms/relate.hpp>
33
34 #include <boost/geometry/core/access.hpp>
35 #include <boost/geometry/core/closure.hpp>
36 #include <boost/geometry/core/cs.hpp>
37 #include <boost/geometry/core/exterior_ring.hpp>
38 #include <boost/geometry/core/interior_rings.hpp>
39 #include <boost/geometry/core/point_order.hpp>
40 #include <boost/geometry/core/ring_type.hpp>
41 #include <boost/geometry/core/interior_rings.hpp>
42 #include <boost/geometry/core/tags.hpp>
43
44 #include <boost/geometry/strategies/relate/cartesian.hpp>
45 #include <boost/geometry/strategies/relate/geographic.hpp>
46 #include <boost/geometry/strategies/relate/spherical.hpp>
47
48 #include <boost/geometry/util/math.hpp>
49 #include <boost/geometry/util/order_as_direction.hpp>
50
51 namespace boost { namespace geometry
52 {
53
54 #ifndef DOXYGEN_NO_DETAIL
55 namespace detail { namespace within {
56
57 struct use_point_in_geometry
58 {
59 template <typename Geometry1, typename Geometry2, typename Strategy>
60 static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2, Strategy const& strategy)
61 {
62 return detail::within::within_point_geometry(geometry1, geometry2, strategy);
63 }
64 };
65
66 struct use_relate
67 {
68 template <typename Geometry1, typename Geometry2, typename Strategy>
69 static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2, Strategy const& strategy)
70 {
71 typedef typename detail::de9im::static_mask_within_type
72 <
73 Geometry1, Geometry2
74 >::type within_mask;
75 return geometry::relate(geometry1, geometry2, within_mask(), strategy);
76 }
77 };
78
79 }} // namespace detail::within
80 #endif // DOXYGEN_NO_DETAIL
81
82 #ifndef DOXYGEN_NO_DISPATCH
83 namespace dispatch
84 {
85
86 template <typename Point, typename Box>
87 struct within<Point, Box, point_tag, box_tag>
88 {
89 template <typename Strategy>
90 static inline bool apply(Point const& point, Box const& box, Strategy const& strategy)
91 {
92 return strategy.within(point, box).apply(point, box);
93 }
94 };
95
96 template <typename Box1, typename Box2>
97 struct within<Box1, Box2, box_tag, box_tag>
98 {
99 template <typename Strategy>
100 static inline bool apply(Box1 const& box1, Box2 const& box2, Strategy const& strategy)
101 {
102 assert_dimension_equal<Box1, Box2>();
103 return strategy.within(box1, box2).apply(box1, box2);
104 }
105 };
106
107 // P/P
108
109 template <typename Point1, typename Point2>
110 struct within<Point1, Point2, point_tag, point_tag>
111 : public detail::within::use_point_in_geometry
112 {};
113
114 template <typename Point, typename MultiPoint>
115 struct within<Point, MultiPoint, point_tag, multi_point_tag>
116 : public detail::within::use_point_in_geometry
117 {};
118
119 template <typename MultiPoint, typename Point>
120 struct within<MultiPoint, Point, multi_point_tag, point_tag>
121 : public detail::within::multi_point_point
122 {};
123
124 template <typename MultiPoint1, typename MultiPoint2>
125 struct within<MultiPoint1, MultiPoint2, multi_point_tag, multi_point_tag>
126 : public detail::within::multi_point_multi_point
127 {};
128
129 // P/L
130
131 template <typename Point, typename Segment>
132 struct within<Point, Segment, point_tag, segment_tag>
133 : public detail::within::use_point_in_geometry
134 {};
135
136 template <typename Point, typename Linestring>
137 struct within<Point, Linestring, point_tag, linestring_tag>
138 : public detail::within::use_point_in_geometry
139 {};
140
141 template <typename Point, typename MultiLinestring>
142 struct within<Point, MultiLinestring, point_tag, multi_linestring_tag>
143 : public detail::within::use_point_in_geometry
144 {};
145
146 template <typename MultiPoint, typename Segment>
147 struct within<MultiPoint, Segment, multi_point_tag, segment_tag>
148 : public detail::within::multi_point_single_geometry<true>
149 {};
150
151 template <typename MultiPoint, typename Linestring>
152 struct within<MultiPoint, Linestring, multi_point_tag, linestring_tag>
153 : public detail::within::multi_point_single_geometry<true>
154 {};
155
156 template <typename MultiPoint, typename MultiLinestring>
157 struct within<MultiPoint, MultiLinestring, multi_point_tag, multi_linestring_tag>
158 : public detail::within::multi_point_multi_geometry<true>
159 {};
160
161 // P/A
162
163 template <typename Point, typename Ring>
164 struct within<Point, Ring, point_tag, ring_tag>
165 : public detail::within::use_point_in_geometry
166 {};
167
168 template <typename Point, typename Polygon>
169 struct within<Point, Polygon, point_tag, polygon_tag>
170 : public detail::within::use_point_in_geometry
171 {};
172
173 template <typename Point, typename MultiPolygon>
174 struct within<Point, MultiPolygon, point_tag, multi_polygon_tag>
175 : public detail::within::use_point_in_geometry
176 {};
177
178 template <typename MultiPoint, typename Ring>
179 struct within<MultiPoint, Ring, multi_point_tag, ring_tag>
180 : public detail::within::multi_point_single_geometry<true>
181 {};
182
183 template <typename MultiPoint, typename Polygon>
184 struct within<MultiPoint, Polygon, multi_point_tag, polygon_tag>
185 : public detail::within::multi_point_single_geometry<true>
186 {};
187
188 template <typename MultiPoint, typename MultiPolygon>
189 struct within<MultiPoint, MultiPolygon, multi_point_tag, multi_polygon_tag>
190 : public detail::within::multi_point_multi_geometry<true>
191 {};
192
193 // L/L
194
195 template <typename Linestring1, typename Linestring2>
196 struct within<Linestring1, Linestring2, linestring_tag, linestring_tag>
197 : public detail::within::use_relate
198 {};
199
200 template <typename Linestring, typename MultiLinestring>
201 struct within<Linestring, MultiLinestring, linestring_tag, multi_linestring_tag>
202 : public detail::within::use_relate
203 {};
204
205 template <typename MultiLinestring, typename Linestring>
206 struct within<MultiLinestring, Linestring, multi_linestring_tag, linestring_tag>
207 : public detail::within::use_relate
208 {};
209
210 template <typename MultiLinestring1, typename MultiLinestring2>
211 struct within<MultiLinestring1, MultiLinestring2, multi_linestring_tag, multi_linestring_tag>
212 : public detail::within::use_relate
213 {};
214
215 // L/A
216
217 template <typename Linestring, typename Ring>
218 struct within<Linestring, Ring, linestring_tag, ring_tag>
219 : public detail::within::use_relate
220 {};
221
222 template <typename MultiLinestring, typename Ring>
223 struct within<MultiLinestring, Ring, multi_linestring_tag, ring_tag>
224 : public detail::within::use_relate
225 {};
226
227 template <typename Linestring, typename Polygon>
228 struct within<Linestring, Polygon, linestring_tag, polygon_tag>
229 : public detail::within::use_relate
230 {};
231
232 template <typename MultiLinestring, typename Polygon>
233 struct within<MultiLinestring, Polygon, multi_linestring_tag, polygon_tag>
234 : public detail::within::use_relate
235 {};
236
237 template <typename Linestring, typename MultiPolygon>
238 struct within<Linestring, MultiPolygon, linestring_tag, multi_polygon_tag>
239 : public detail::within::use_relate
240 {};
241
242 template <typename MultiLinestring, typename MultiPolygon>
243 struct within<MultiLinestring, MultiPolygon, multi_linestring_tag, multi_polygon_tag>
244 : public detail::within::use_relate
245 {};
246
247 // A/A
248
249 template <typename Ring1, typename Ring2>
250 struct within<Ring1, Ring2, ring_tag, ring_tag>
251 : public detail::within::use_relate
252 {};
253
254 template <typename Ring, typename Polygon>
255 struct within<Ring, Polygon, ring_tag, polygon_tag>
256 : public detail::within::use_relate
257 {};
258
259 template <typename Polygon, typename Ring>
260 struct within<Polygon, Ring, polygon_tag, ring_tag>
261 : public detail::within::use_relate
262 {};
263
264 template <typename Polygon1, typename Polygon2>
265 struct within<Polygon1, Polygon2, polygon_tag, polygon_tag>
266 : public detail::within::use_relate
267 {};
268
269 template <typename Ring, typename MultiPolygon>
270 struct within<Ring, MultiPolygon, ring_tag, multi_polygon_tag>
271 : public detail::within::use_relate
272 {};
273
274 template <typename MultiPolygon, typename Ring>
275 struct within<MultiPolygon, Ring, multi_polygon_tag, ring_tag>
276 : public detail::within::use_relate
277 {};
278
279 template <typename Polygon, typename MultiPolygon>
280 struct within<Polygon, MultiPolygon, polygon_tag, multi_polygon_tag>
281 : public detail::within::use_relate
282 {};
283
284 template <typename MultiPolygon, typename Polygon>
285 struct within<MultiPolygon, Polygon, multi_polygon_tag, polygon_tag>
286 : public detail::within::use_relate
287 {};
288
289 template <typename MultiPolygon1, typename MultiPolygon2>
290 struct within<MultiPolygon1, MultiPolygon2, multi_polygon_tag, multi_polygon_tag>
291 : public detail::within::use_relate
292 {};
293
294 } // namespace dispatch
295 #endif // DOXYGEN_NO_DISPATCH
296
297
298 }} // namespace boost::geometry
299
300 #include <boost/geometry/index/rtree.hpp>
301
302 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_WITHIN_IMPLEMENTATION_HPP