]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/geometry/algorithms/detail/within/implementation.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / boost / geometry / algorithms / detail / within / implementation.hpp
CommitLineData
b32b8144
FG
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
92f5a8d4
TL
7// This file was modified by Oracle on 2013, 2014, 2017, 2019.
8// Modifications copyright (c) 2013-2019 Oracle and/or its affiliates.
b32b8144
FG
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
b32b8144
FG
22#include <cstddef>
23
92f5a8d4 24#include <boost/core/ignore_unused.hpp>
b32b8144
FG
25#include <boost/range.hpp>
26
27#include <boost/geometry/algorithms/detail/within/interface.hpp>
28
29#include <boost/geometry/core/access.hpp>
30#include <boost/geometry/core/closure.hpp>
31#include <boost/geometry/core/cs.hpp>
32#include <boost/geometry/core/exterior_ring.hpp>
33#include <boost/geometry/core/interior_rings.hpp>
34#include <boost/geometry/core/point_order.hpp>
35#include <boost/geometry/core/ring_type.hpp>
36#include <boost/geometry/core/interior_rings.hpp>
37#include <boost/geometry/core/tags.hpp>
38
39#include <boost/geometry/util/math.hpp>
40#include <boost/geometry/util/order_as_direction.hpp>
41#include <boost/geometry/views/closeable_view.hpp>
42#include <boost/geometry/views/reversible_view.hpp>
43
44#include <boost/geometry/algorithms/detail/within/multi_point.hpp>
45#include <boost/geometry/algorithms/detail/within/point_in_geometry.hpp>
46#include <boost/geometry/algorithms/relate.hpp>
47
48#include <boost/geometry/algorithms/detail/overlay/get_turns.hpp>
49#include <boost/geometry/algorithms/detail/overlay/do_reverse.hpp>
50#include <deque>
51
52
53namespace boost { namespace geometry
54{
55
56#ifndef DOXYGEN_NO_DETAIL
57namespace detail { namespace within {
58
59struct use_point_in_geometry
60{
61 template <typename Geometry1, typename Geometry2, typename Strategy>
62 static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2, Strategy const& strategy)
63 {
92f5a8d4 64 return detail::within::within_point_geometry(geometry1, geometry2, strategy);
b32b8144
FG
65 }
66};
67
68struct use_relate
69{
70 template <typename Geometry1, typename Geometry2, typename Strategy>
71 static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2, Strategy const& strategy)
72 {
73 typedef typename detail::de9im::static_mask_within_type
74 <
75 Geometry1, Geometry2
76 >::type within_mask;
77 return geometry::relate(geometry1, geometry2, within_mask(), strategy);
78 }
79};
80
81}} // namespace detail::within
82#endif // DOXYGEN_NO_DETAIL
83
84#ifndef DOXYGEN_NO_DISPATCH
85namespace dispatch
86{
87
88template <typename Point, typename Box>
89struct within<Point, Box, point_tag, box_tag>
90{
91 template <typename Strategy>
92 static inline bool apply(Point const& point, Box const& box, Strategy const& strategy)
93 {
92f5a8d4 94 boost::ignore_unused(strategy);
b32b8144
FG
95 return strategy.apply(point, box);
96 }
97};
98
99template <typename Box1, typename Box2>
100struct within<Box1, Box2, box_tag, box_tag>
101{
102 template <typename Strategy>
103 static inline bool apply(Box1 const& box1, Box2 const& box2, Strategy const& strategy)
104 {
105 assert_dimension_equal<Box1, Box2>();
92f5a8d4 106 boost::ignore_unused(strategy);
b32b8144
FG
107 return strategy.apply(box1, box2);
108 }
109};
110
111// P/P
112
113template <typename Point1, typename Point2>
114struct within<Point1, Point2, point_tag, point_tag>
115 : public detail::within::use_point_in_geometry
116{};
117
118template <typename Point, typename MultiPoint>
119struct within<Point, MultiPoint, point_tag, multi_point_tag>
120 : public detail::within::use_point_in_geometry
121{};
122
123template <typename MultiPoint, typename Point>
124struct within<MultiPoint, Point, multi_point_tag, point_tag>
125 : public detail::within::multi_point_point
126{};
127
128template <typename MultiPoint1, typename MultiPoint2>
129struct within<MultiPoint1, MultiPoint2, multi_point_tag, multi_point_tag>
130 : public detail::within::multi_point_multi_point
131{};
132
133// P/L
134
135template <typename Point, typename Segment>
136struct within<Point, Segment, point_tag, segment_tag>
137 : public detail::within::use_point_in_geometry
138{};
139
140template <typename Point, typename Linestring>
141struct within<Point, Linestring, point_tag, linestring_tag>
142 : public detail::within::use_point_in_geometry
143{};
144
145template <typename Point, typename MultiLinestring>
146struct within<Point, MultiLinestring, point_tag, multi_linestring_tag>
147 : public detail::within::use_point_in_geometry
148{};
149
150template <typename MultiPoint, typename Segment>
151struct within<MultiPoint, Segment, multi_point_tag, segment_tag>
152 : public detail::within::multi_point_single_geometry<true>
153{};
154
155template <typename MultiPoint, typename Linestring>
156struct within<MultiPoint, Linestring, multi_point_tag, linestring_tag>
157 : public detail::within::multi_point_single_geometry<true>
158{};
159
160template <typename MultiPoint, typename MultiLinestring>
161struct within<MultiPoint, MultiLinestring, multi_point_tag, multi_linestring_tag>
162 : public detail::within::multi_point_multi_geometry<true>
163{};
164
165// P/A
166
167template <typename Point, typename Ring>
168struct within<Point, Ring, point_tag, ring_tag>
169 : public detail::within::use_point_in_geometry
170{};
171
172template <typename Point, typename Polygon>
173struct within<Point, Polygon, point_tag, polygon_tag>
174 : public detail::within::use_point_in_geometry
175{};
176
177template <typename Point, typename MultiPolygon>
178struct within<Point, MultiPolygon, point_tag, multi_polygon_tag>
179 : public detail::within::use_point_in_geometry
180{};
181
182template <typename MultiPoint, typename Ring>
183struct within<MultiPoint, Ring, multi_point_tag, ring_tag>
184 : public detail::within::multi_point_single_geometry<true>
185{};
186
187template <typename MultiPoint, typename Polygon>
188struct within<MultiPoint, Polygon, multi_point_tag, polygon_tag>
189 : public detail::within::multi_point_single_geometry<true>
190{};
191
192template <typename MultiPoint, typename MultiPolygon>
193struct within<MultiPoint, MultiPolygon, multi_point_tag, multi_polygon_tag>
194 : public detail::within::multi_point_multi_geometry<true>
195{};
196
197// L/L
198
199template <typename Linestring1, typename Linestring2>
200struct within<Linestring1, Linestring2, linestring_tag, linestring_tag>
201 : public detail::within::use_relate
202{};
203
204template <typename Linestring, typename MultiLinestring>
205struct within<Linestring, MultiLinestring, linestring_tag, multi_linestring_tag>
206 : public detail::within::use_relate
207{};
208
209template <typename MultiLinestring, typename Linestring>
210struct within<MultiLinestring, Linestring, multi_linestring_tag, linestring_tag>
211 : public detail::within::use_relate
212{};
213
214template <typename MultiLinestring1, typename MultiLinestring2>
215struct within<MultiLinestring1, MultiLinestring2, multi_linestring_tag, multi_linestring_tag>
216 : public detail::within::use_relate
217{};
218
219// L/A
220
221template <typename Linestring, typename Ring>
222struct within<Linestring, Ring, linestring_tag, ring_tag>
223 : public detail::within::use_relate
224{};
225
226template <typename MultiLinestring, typename Ring>
227struct within<MultiLinestring, Ring, multi_linestring_tag, ring_tag>
228 : public detail::within::use_relate
229{};
230
231template <typename Linestring, typename Polygon>
232struct within<Linestring, Polygon, linestring_tag, polygon_tag>
233 : public detail::within::use_relate
234{};
235
236template <typename MultiLinestring, typename Polygon>
237struct within<MultiLinestring, Polygon, multi_linestring_tag, polygon_tag>
238 : public detail::within::use_relate
239{};
240
241template <typename Linestring, typename MultiPolygon>
242struct within<Linestring, MultiPolygon, linestring_tag, multi_polygon_tag>
243 : public detail::within::use_relate
244{};
245
246template <typename MultiLinestring, typename MultiPolygon>
247struct within<MultiLinestring, MultiPolygon, multi_linestring_tag, multi_polygon_tag>
248 : public detail::within::use_relate
249{};
250
251// A/A
252
253template <typename Ring1, typename Ring2>
254struct within<Ring1, Ring2, ring_tag, ring_tag>
255 : public detail::within::use_relate
256{};
257
258template <typename Ring, typename Polygon>
259struct within<Ring, Polygon, ring_tag, polygon_tag>
260 : public detail::within::use_relate
261{};
262
263template <typename Polygon, typename Ring>
264struct within<Polygon, Ring, polygon_tag, ring_tag>
265 : public detail::within::use_relate
266{};
267
268template <typename Polygon1, typename Polygon2>
269struct within<Polygon1, Polygon2, polygon_tag, polygon_tag>
270 : public detail::within::use_relate
271{};
272
273template <typename Ring, typename MultiPolygon>
274struct within<Ring, MultiPolygon, ring_tag, multi_polygon_tag>
275 : public detail::within::use_relate
276{};
277
278template <typename MultiPolygon, typename Ring>
279struct within<MultiPolygon, Ring, multi_polygon_tag, ring_tag>
280 : public detail::within::use_relate
281{};
282
283template <typename Polygon, typename MultiPolygon>
284struct within<Polygon, MultiPolygon, polygon_tag, multi_polygon_tag>
285 : public detail::within::use_relate
286{};
287
288template <typename MultiPolygon, typename Polygon>
289struct within<MultiPolygon, Polygon, multi_polygon_tag, polygon_tag>
290 : public detail::within::use_relate
291{};
292
293template <typename MultiPolygon1, typename MultiPolygon2>
294struct within<MultiPolygon1, MultiPolygon2, multi_polygon_tag, multi_polygon_tag>
295 : public detail::within::use_relate
296{};
297
298} // namespace dispatch
299#endif // DOXYGEN_NO_DISPATCH
300
301
302}} // namespace boost::geometry
303
304#include <boost/geometry/index/rtree.hpp>
305
306#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_WITHIN_IMPLEMENTATION_HPP