MySQL 8.4.2
Source Code Documentation
within_functor.h
Go to the documentation of this file.
1#ifndef SQL_GIS_WITHIN_FUNCTOR_H_INCLUDED
2#define SQL_GIS_WITHIN_FUNCTOR_H_INCLUDED
3
4// Copyright (c) 2017, 2024, Oracle and/or its affiliates.
5//
6// This program is free software; you can redistribute it and/or modify
7// it under the terms of the GNU General Public License, version 2.0,
8// as published by the Free Software Foundation.
9//
10// This program is designed to work with certain software (including
11// but not limited to OpenSSL) that is licensed under separate terms,
12// as designated in a particular file or component or in included license
13// documentation. The authors of MySQL hereby grant you an additional
14// permission to link the program and your derivative works with the
15// separately licensed software that they have either included with
16// the program or referenced in the documentation.
17//
18// This program is distributed in the hope that it will be useful,
19// but WITHOUT ANY WARRANTY; without even the implied warranty of
20// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21// GNU General Public License, version 2.0, for more details.
22//
23// You should have received a copy of the GNU General Public License
24// along with this program; if not, write to the Free Software
25// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
26
27/// @file
28///
29/// This file declares the within functor interface.
30///
31/// The functor is not intended for use directly by MySQL code. It should be
32/// used indirectly through the gis::within() function.
33///
34/// @see gis::within
35
36#include <boost/geometry.hpp>
37
38#include "sql/gis/box.h"
39#include "sql/gis/functor.h"
40#include "sql/gis/geometries.h"
42
43namespace gis {
44
45/// Within functor that calls Boost.Geometry with the correct parameter types.
46///
47/// The functor throws exceptions and is therefore only intended used to
48/// implement within or other geographic functions. It should not be used
49/// directly by other MySQL code.
50class Within : public Functor<bool> {
51 private:
52 /// Semi-major axis of ellipsoid.
54 /// Semi-minor axis of ellipsoid.
56 /// Strategy used for P/L and P/A.
57 boost::geometry::strategy::within::geographic_winding<Geographic_point>
59 /// Strategy used for L/L, L/A and A/A.
60 boost::geometry::strategy::intersection::geographic_segments<>
62
63 public:
64 /// Creates a new Within functor.
65 ///
66 /// @param semi_major Semi-major axis of ellipsoid.
67 /// @param semi_minor Semi-minor axis of ellipsoid.
68 Within(double semi_major, double semi_minor);
69 bool operator()(const Geometry *g1, const Geometry *g2) const override;
70 bool operator()(const Box *b1, const Box *b2) const;
71 bool eval(const Geometry *g1, const Geometry *g2) const;
72
73 //////////////////////////////////////////////////////////////////////////////
74
75 // within(Cartesian_point, *)
76
77 bool eval(const Cartesian_point *g1, const Cartesian_point *g2) const;
78 bool eval(const Cartesian_point *g1, const Cartesian_linestring *g2) const;
79 bool eval(const Cartesian_point *g1, const Cartesian_polygon *g2) const;
80 bool eval(const Cartesian_point *g1,
81 const Cartesian_geometrycollection *g2) const;
82 bool eval(const Cartesian_point *g1, const Cartesian_multipoint *g2) const;
83 bool eval(const Cartesian_point *g1,
84 const Cartesian_multilinestring *g2) const;
85 bool eval(const Cartesian_point *g1, const Cartesian_multipolygon *g2) const;
86
87 //////////////////////////////////////////////////////////////////////////////
88
89 // within(Cartesian_linestring, *)
90
91 bool eval(const Cartesian_linestring *g1, const Cartesian_point *g2) const;
92 bool eval(const Cartesian_linestring *g1,
93 const Cartesian_linestring *g2) const;
94 bool eval(const Cartesian_linestring *g1, const Cartesian_polygon *g2) const;
95 bool eval(const Cartesian_linestring *g1,
96 const Cartesian_geometrycollection *g2) const;
97 bool eval(const Cartesian_linestring *g1,
98 const Cartesian_multipoint *g2) const;
99 bool eval(const Cartesian_linestring *g1,
100 const Cartesian_multilinestring *g2) const;
101 bool eval(const Cartesian_linestring *g1,
102 const Cartesian_multipolygon *g2) const;
103
104 //////////////////////////////////////////////////////////////////////////////
105
106 // within(Cartesian_polygon, *)
107
108 bool eval(const Cartesian_polygon *g1, const Cartesian_point *g2) const;
109 bool eval(const Cartesian_polygon *g1, const Cartesian_linestring *g2) const;
110 bool eval(const Cartesian_polygon *g1, const Cartesian_polygon *g2) const;
111 bool eval(const Cartesian_polygon *g1,
112 const Cartesian_geometrycollection *g2) const;
113 bool eval(const Cartesian_polygon *g1, const Cartesian_multipoint *g2) const;
114 bool eval(const Cartesian_polygon *g1,
115 const Cartesian_multilinestring *g2) const;
116 bool eval(const Cartesian_polygon *g1,
117 const Cartesian_multipolygon *g2) const;
118
119 //////////////////////////////////////////////////////////////////////////////
120
121 // within(Cartesian_geometrycollection, *)
122
123 bool eval(const Cartesian_geometrycollection *g1,
124 const Cartesian_point *g2) const;
125 bool eval(const Cartesian_geometrycollection *g1,
126 const Cartesian_linestring *g2) const;
127 bool eval(const Cartesian_geometrycollection *g1,
128 const Cartesian_polygon *g2) const;
129 bool eval(const Cartesian_geometrycollection *g1,
130 const Cartesian_geometrycollection *g2) const;
131 bool eval(const Cartesian_geometrycollection *g1,
132 const Cartesian_multipoint *g2) const;
133 bool eval(const Cartesian_geometrycollection *g1,
134 const Cartesian_multilinestring *g2) const;
135 bool eval(const Cartesian_geometrycollection *g1,
136 const Cartesian_multipolygon *g2) const;
137
138 //////////////////////////////////////////////////////////////////////////////
139
140 // within(Cartesian_multipoint, *)
141
142 bool eval(const Cartesian_multipoint *g1, const Cartesian_point *g2) const;
143 bool eval(const Cartesian_multipoint *g1,
144 const Cartesian_linestring *g2) const;
145 bool eval(const Cartesian_multipoint *g1, const Cartesian_polygon *g2) const;
146 bool eval(const Cartesian_multipoint *g1,
147 const Cartesian_geometrycollection *g2) const;
148 bool eval(const Cartesian_multipoint *g1,
149 const Cartesian_multipoint *g2) const;
150 bool eval(const Cartesian_multipoint *g1,
151 const Cartesian_multilinestring *g2) const;
152 bool eval(const Cartesian_multipoint *g1,
153 const Cartesian_multipolygon *g2) const;
154
155 //////////////////////////////////////////////////////////////////////////////
156
157 // within(Cartesian_multilinestring, *)
158
159 bool eval(const Cartesian_multilinestring *g1,
160 const Cartesian_point *g2) const;
161 bool eval(const Cartesian_multilinestring *g1,
162 const Cartesian_linestring *g2) const;
163 bool eval(const Cartesian_multilinestring *g1,
164 const Cartesian_polygon *g2) const;
165 bool eval(const Cartesian_multilinestring *g1,
166 const Cartesian_geometrycollection *g2) const;
167 bool eval(const Cartesian_multilinestring *g1,
168 const Cartesian_multipoint *g2) const;
169 bool eval(const Cartesian_multilinestring *g1,
170 const Cartesian_multilinestring *g2) const;
171 bool eval(const Cartesian_multilinestring *g1,
172 const Cartesian_multipolygon *g2) const;
173
174 //////////////////////////////////////////////////////////////////////////////
175
176 // within(Cartesian_multipolygon, *)
177
178 bool eval(const Cartesian_multipolygon *g1, const Cartesian_point *g2) const;
179 bool eval(const Cartesian_multipolygon *g1,
180 const Cartesian_linestring *g2) const;
181 bool eval(const Cartesian_multipolygon *g1,
182 const Cartesian_polygon *g2) const;
183 bool eval(const Cartesian_multipolygon *g1,
184 const Cartesian_geometrycollection *g2) const;
185 bool eval(const Cartesian_multipolygon *g1,
186 const Cartesian_multipoint *g2) const;
187 bool eval(const Cartesian_multipolygon *g1,
188 const Cartesian_multilinestring *g2) const;
189 bool eval(const Cartesian_multipolygon *g1,
190 const Cartesian_multipolygon *g2) const;
191
192 //////////////////////////////////////////////////////////////////////////////
193
194 // within(Geographic_point, *)
195
196 bool eval(const Geographic_point *g1, const Geographic_point *g2) const;
197 bool eval(const Geographic_point *g1, const Geographic_linestring *g2) const;
198 bool eval(const Geographic_point *g1, const Geographic_polygon *g2) const;
199 bool eval(const Geographic_point *g1,
200 const Geographic_geometrycollection *g2) const;
201 bool eval(const Geographic_point *g1, const Geographic_multipoint *g2) const;
202 bool eval(const Geographic_point *g1,
203 const Geographic_multilinestring *g2) const;
204 bool eval(const Geographic_point *g1,
205 const Geographic_multipolygon *g2) const;
206
207 //////////////////////////////////////////////////////////////////////////////
208
209 // within(Geographic_linestring, *)
210
211 bool eval(const Geographic_linestring *g1, const Geographic_point *g2) const;
212 bool eval(const Geographic_linestring *g1,
213 const Geographic_linestring *g2) const;
214 bool eval(const Geographic_linestring *g1,
215 const Geographic_polygon *g2) const;
216 bool eval(const Geographic_linestring *g1,
217 const Geographic_geometrycollection *g2) const;
218 bool eval(const Geographic_linestring *g1,
219 const Geographic_multipoint *g2) const;
220 bool eval(const Geographic_linestring *g1,
221 const Geographic_multilinestring *g2) const;
222 bool eval(const Geographic_linestring *g1,
223 const Geographic_multipolygon *g2) const;
224
225 //////////////////////////////////////////////////////////////////////////////
226
227 // within(Geographic_polygon, *)
228
229 bool eval(const Geographic_polygon *g1, const Geographic_point *g2) const;
230 bool eval(const Geographic_polygon *g1,
231 const Geographic_linestring *g2) const;
232 bool eval(const Geographic_polygon *g1, const Geographic_polygon *g2) const;
233 bool eval(const Geographic_polygon *g1,
234 const Geographic_geometrycollection *g2) const;
235 bool eval(const Geographic_polygon *g1,
236 const Geographic_multipoint *g2) const;
237 bool eval(const Geographic_polygon *g1,
238 const Geographic_multilinestring *g2) const;
239 bool eval(const Geographic_polygon *g1,
240 const Geographic_multipolygon *g2) const;
241
242 //////////////////////////////////////////////////////////////////////////////
243
244 // within(Geographic_geometrycollection, *)
245
246 bool eval(const Geographic_geometrycollection *g1,
247 const Geographic_point *g2) const;
248 bool eval(const Geographic_geometrycollection *g1,
249 const Geographic_linestring *g2) const;
250 bool eval(const Geographic_geometrycollection *g1,
251 const Geographic_polygon *g2) const;
252 bool eval(const Geographic_geometrycollection *g1,
253 const Geographic_geometrycollection *g2) const;
254 bool eval(const Geographic_geometrycollection *g1,
255 const Geographic_multipoint *g2) const;
256 bool eval(const Geographic_geometrycollection *g1,
257 const Geographic_multilinestring *g2) const;
258 bool eval(const Geographic_geometrycollection *g1,
259 const Geographic_multipolygon *g2) const;
260
261 //////////////////////////////////////////////////////////////////////////////
262
263 // within(Geographic_multipoint, *)
264
265 bool eval(const Geographic_multipoint *g1, const Geographic_point *g2) const;
266 bool eval(const Geographic_multipoint *g1,
267 const Geographic_linestring *g2) const;
268 bool eval(const Geographic_multipoint *g1,
269 const Geographic_polygon *g2) const;
270 bool eval(const Geographic_multipoint *g1,
271 const Geographic_geometrycollection *g2) const;
272 bool eval(const Geographic_multipoint *g1,
273 const Geographic_multipoint *g2) const;
274 bool eval(const Geographic_multipoint *g1,
275 const Geographic_multilinestring *g2) const;
276 bool eval(const Geographic_multipoint *g1,
277 const Geographic_multipolygon *g2) const;
278
279 //////////////////////////////////////////////////////////////////////////////
280
281 // within(Geographic_multilinestring, *)
282
283 bool eval(const Geographic_multilinestring *g1,
284 const Geographic_point *g2) const;
285 bool eval(const Geographic_multilinestring *g1,
286 const Geographic_linestring *g2) const;
287 bool eval(const Geographic_multilinestring *g1,
288 const Geographic_polygon *g2) const;
289 bool eval(const Geographic_multilinestring *g1,
290 const Geographic_geometrycollection *g2) const;
291 bool eval(const Geographic_multilinestring *g1,
292 const Geographic_multipoint *g2) const;
293 bool eval(const Geographic_multilinestring *g1,
294 const Geographic_multilinestring *g2) const;
295 bool eval(const Geographic_multilinestring *g1,
296 const Geographic_multipolygon *g2) const;
297
298 //////////////////////////////////////////////////////////////////////////////
299
300 // within(Geographic_multipolygon, *)
301
302 bool eval(const Geographic_multipolygon *g1,
303 const Geographic_point *g2) const;
304 bool eval(const Geographic_multipolygon *g1,
305 const Geographic_linestring *g2) const;
306 bool eval(const Geographic_multipolygon *g1,
307 const Geographic_polygon *g2) const;
308 bool eval(const Geographic_multipolygon *g1,
309 const Geographic_geometrycollection *g2) const;
310 bool eval(const Geographic_multipolygon *g1,
311 const Geographic_multipoint *g2) const;
312 bool eval(const Geographic_multipolygon *g1,
313 const Geographic_multilinestring *g2) const;
314 bool eval(const Geographic_multipolygon *g1,
315 const Geographic_multipolygon *g2) const;
316
317 //////////////////////////////////////////////////////////////////////////////
318
319 // within(Box, Box)
320
321 bool eval(const Cartesian_box *b1, const Cartesian_box *b2) const;
322 bool eval(const Geographic_box *b1, const Geographic_box *b2) const;
323};
324
325} // namespace gis
326
327#endif // SQL_GIS_WITHIN_FUNCTOR_H_INCLUDED
This file declares the Box class.
A 2d box with sides parallel to the coordinate system grid.
Definition: box.h:41
A Cartesian 2d box.
Definition: box.h:70
A Cartesian 2d geometry collection.
Definition: geometries_cs.h:375
A Cartesian 2d linestring.
Definition: geometries_cs.h:71
A Cartesian 2d multilinestring.
Definition: geometries_cs.h:602
A Cartesian 2d multipoint.
Definition: geometries_cs.h:501
A Cartesian 2d multipolygon.
Definition: geometries_cs.h:720
A Cartesian 2d point.
Definition: geometries_cs.h:47
A Cartesian 2d polygon.
Definition: geometries_cs.h:269
The base class of all functors that takes two geometry arguments.
Definition: functor.h:165
A Geographic 2d box.
Definition: box.h:103
A geographic (ellipsoidal) 2d geometry collection.
Definition: geometries_cs.h:438
A geographic (ellipsoidal) 2d linestring.
Definition: geometries_cs.h:125
A geographic (ellipsoidal) 2d multilinestring.
Definition: geometries_cs.h:661
A geographic (ellipsoidal) 2d multipoint.
Definition: geometries_cs.h:552
A geographic (ellipsoidal) 2d multipolygon.
Definition: geometries_cs.h:774
A geographic (ellipsoidal) 2d point.
Definition: geometries_cs.h:58
A geographic (ellipsoidal) 2d polygon.
Definition: geometries_cs.h:322
Abstract superclass for all geometric objects.
Definition: geometries.h:100
Within functor that calls Boost.Geometry with the correct parameter types.
Definition: within_functor.h:50
double m_semi_major
Semi-major axis of ellipsoid.
Definition: within_functor.h:53
double m_semi_minor
Semi-minor axis of ellipsoid.
Definition: within_functor.h:55
Within(double semi_major, double semi_minor)
Creates a new Within functor.
Definition: within.cc:53
bool eval(const Geometry *g1, const Geometry *g2) const
Definition: within.cc:80
boost::geometry::strategy::intersection::geographic_segments m_geographic_ll_la_aa_strategy
Strategy used for L/L, L/A and A/A.
Definition: within_functor.h:61
bool operator()(const Geometry *g1, const Geometry *g2) const override
Definition: within.cc:61
boost::geometry::strategy::within::geographic_winding< Geographic_point > m_geographic_pl_pa_strategy
Strategy used for P/L and P/A.
Definition: within_functor.h:58
This file contains the superclasses for GIS functors.
This file declares the geometry class hierarchy used by the server as the internal representation of ...
This file contains Boost.Geometry type traits declarations for Cartesian and geographic geometries.
Definition: area.cc:47