]> git.proxmox.com Git - ceph.git/blame - 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
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
1e59de90
TL
7// This file was modified by Oracle on 2013-2021.
8// Modifications copyright (c) 2013-2021 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 22#include <cstddef>
1e59de90 23#include <deque>
b32b8144 24
92f5a8d4 25#include <boost/core/ignore_unused.hpp>
b32b8144 26
1e59de90
TL
27#include <boost/geometry/algorithms/detail/overlay/get_turns.hpp>
28#include <boost/geometry/algorithms/detail/overlay/do_reverse.hpp>
b32b8144 29#include <boost/geometry/algorithms/detail/within/interface.hpp>
1e59de90
TL
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>
b32b8144
FG
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
1e59de90
TL
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
b32b8144
FG
48#include <boost/geometry/util/math.hpp>
49#include <boost/geometry/util/order_as_direction.hpp>
b32b8144 50
b32b8144
FG
51namespace boost { namespace geometry
52{
53
54#ifndef DOXYGEN_NO_DETAIL
55namespace detail { namespace within {
56
57struct 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 {
92f5a8d4 62 return detail::within::within_point_geometry(geometry1, geometry2, strategy);
b32b8144
FG
63 }
64};
65
66struct 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
83namespace dispatch
84{
85
86template <typename Point, typename Box>
87struct 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 {
1e59de90 92 return strategy.within(point, box).apply(point, box);
b32b8144
FG
93 }
94};
95
96template <typename Box1, typename Box2>
97struct 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>();
1e59de90 103 return strategy.within(box1, box2).apply(box1, box2);
b32b8144
FG
104 }
105};
106
107// P/P
108
109template <typename Point1, typename Point2>
110struct within<Point1, Point2, point_tag, point_tag>
111 : public detail::within::use_point_in_geometry
112{};
113
114template <typename Point, typename MultiPoint>
115struct within<Point, MultiPoint, point_tag, multi_point_tag>
116 : public detail::within::use_point_in_geometry
117{};
118
119template <typename MultiPoint, typename Point>
120struct within<MultiPoint, Point, multi_point_tag, point_tag>
121 : public detail::within::multi_point_point
122{};
123
124template <typename MultiPoint1, typename MultiPoint2>
125struct within<MultiPoint1, MultiPoint2, multi_point_tag, multi_point_tag>
126 : public detail::within::multi_point_multi_point
127{};
128
129// P/L
130
131template <typename Point, typename Segment>
132struct within<Point, Segment, point_tag, segment_tag>
133 : public detail::within::use_point_in_geometry
134{};
135
136template <typename Point, typename Linestring>
137struct within<Point, Linestring, point_tag, linestring_tag>
138 : public detail::within::use_point_in_geometry
139{};
140
141template <typename Point, typename MultiLinestring>
142struct within<Point, MultiLinestring, point_tag, multi_linestring_tag>
143 : public detail::within::use_point_in_geometry
144{};
145
146template <typename MultiPoint, typename Segment>
147struct within<MultiPoint, Segment, multi_point_tag, segment_tag>
148 : public detail::within::multi_point_single_geometry<true>
149{};
150
151template <typename MultiPoint, typename Linestring>
152struct within<MultiPoint, Linestring, multi_point_tag, linestring_tag>
153 : public detail::within::multi_point_single_geometry<true>
154{};
155
156template <typename MultiPoint, typename MultiLinestring>
157struct within<MultiPoint, MultiLinestring, multi_point_tag, multi_linestring_tag>
158 : public detail::within::multi_point_multi_geometry<true>
159{};
160
161// P/A
162
163template <typename Point, typename Ring>
164struct within<Point, Ring, point_tag, ring_tag>
165 : public detail::within::use_point_in_geometry
166{};
167
168template <typename Point, typename Polygon>
169struct within<Point, Polygon, point_tag, polygon_tag>
170 : public detail::within::use_point_in_geometry
171{};
172
173template <typename Point, typename MultiPolygon>
174struct within<Point, MultiPolygon, point_tag, multi_polygon_tag>
175 : public detail::within::use_point_in_geometry
176{};
177
178template <typename MultiPoint, typename Ring>
179struct within<MultiPoint, Ring, multi_point_tag, ring_tag>
180 : public detail::within::multi_point_single_geometry<true>
181{};
182
183template <typename MultiPoint, typename Polygon>
184struct within<MultiPoint, Polygon, multi_point_tag, polygon_tag>
185 : public detail::within::multi_point_single_geometry<true>
186{};
187
188template <typename MultiPoint, typename MultiPolygon>
189struct within<MultiPoint, MultiPolygon, multi_point_tag, multi_polygon_tag>
190 : public detail::within::multi_point_multi_geometry<true>
191{};
192
193// L/L
194
195template <typename Linestring1, typename Linestring2>
196struct within<Linestring1, Linestring2, linestring_tag, linestring_tag>
197 : public detail::within::use_relate
198{};
199
200template <typename Linestring, typename MultiLinestring>
201struct within<Linestring, MultiLinestring, linestring_tag, multi_linestring_tag>
202 : public detail::within::use_relate
203{};
204
205template <typename MultiLinestring, typename Linestring>
206struct within<MultiLinestring, Linestring, multi_linestring_tag, linestring_tag>
207 : public detail::within::use_relate
208{};
209
210template <typename MultiLinestring1, typename MultiLinestring2>
211struct within<MultiLinestring1, MultiLinestring2, multi_linestring_tag, multi_linestring_tag>
212 : public detail::within::use_relate
213{};
214
215// L/A
216
217template <typename Linestring, typename Ring>
218struct within<Linestring, Ring, linestring_tag, ring_tag>
219 : public detail::within::use_relate
220{};
221
222template <typename MultiLinestring, typename Ring>
223struct within<MultiLinestring, Ring, multi_linestring_tag, ring_tag>
224 : public detail::within::use_relate
225{};
226
227template <typename Linestring, typename Polygon>
228struct within<Linestring, Polygon, linestring_tag, polygon_tag>
229 : public detail::within::use_relate
230{};
231
232template <typename MultiLinestring, typename Polygon>
233struct within<MultiLinestring, Polygon, multi_linestring_tag, polygon_tag>
234 : public detail::within::use_relate
235{};
236
237template <typename Linestring, typename MultiPolygon>
238struct within<Linestring, MultiPolygon, linestring_tag, multi_polygon_tag>
239 : public detail::within::use_relate
240{};
241
242template <typename MultiLinestring, typename MultiPolygon>
243struct within<MultiLinestring, MultiPolygon, multi_linestring_tag, multi_polygon_tag>
244 : public detail::within::use_relate
245{};
246
247// A/A
248
249template <typename Ring1, typename Ring2>
250struct within<Ring1, Ring2, ring_tag, ring_tag>
251 : public detail::within::use_relate
252{};
253
254template <typename Ring, typename Polygon>
255struct within<Ring, Polygon, ring_tag, polygon_tag>
256 : public detail::within::use_relate
257{};
258
259template <typename Polygon, typename Ring>
260struct within<Polygon, Ring, polygon_tag, ring_tag>
261 : public detail::within::use_relate
262{};
263
264template <typename Polygon1, typename Polygon2>
265struct within<Polygon1, Polygon2, polygon_tag, polygon_tag>
266 : public detail::within::use_relate
267{};
268
269template <typename Ring, typename MultiPolygon>
270struct within<Ring, MultiPolygon, ring_tag, multi_polygon_tag>
271 : public detail::within::use_relate
272{};
273
274template <typename MultiPolygon, typename Ring>
275struct within<MultiPolygon, Ring, multi_polygon_tag, ring_tag>
276 : public detail::within::use_relate
277{};
278
279template <typename Polygon, typename MultiPolygon>
280struct within<Polygon, MultiPolygon, polygon_tag, multi_polygon_tag>
281 : public detail::within::use_relate
282{};
283
284template <typename MultiPolygon, typename Polygon>
285struct within<MultiPolygon, Polygon, multi_polygon_tag, polygon_tag>
286 : public detail::within::use_relate
287{};
288
289template <typename MultiPolygon1, typename MultiPolygon2>
290struct 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