MySQL 8.0.39
Source Code Documentation
intersects_functor.h
Go to the documentation of this file.
1#ifndef SQL_GIS_INTERSECTS_FUNCTOR_H_INCLUDED
2#define SQL_GIS_INTERSECTS_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 intersects functor interface.
30///
31/// The functor is not intended for use directly by MySQL code. It should be
32/// used indirectly through the gis::intersects() function.
33///
34/// @see gis::intersects
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/// Intersects functor that calls Boost.Geometry with the correct parameter
46/// types.
47///
48/// The functor throws exceptions and is therefore only intended used to
49/// implement intersects or other geographic functions. It should not be used
50/// directly by other MySQL code.
51class Intersects : public Functor<bool> {
52 private:
53 /// Semi-major axis of ellipsoid.
55 /// Semi-minor axis of ellipsoid.
57 /// Strategy used for P/L and P/A.
58 boost::geometry::strategy::within::geographic_winding<Geographic_point>
60 /// Strategy used for L/L, L/A and A/A.
61 boost::geometry::strategy::intersection::geographic_segments<>
63
64 public:
65 /// Creates a new Intersects functor.
66 ///
67 /// @param semi_major Semi-major axis of ellipsoid.
68 /// @param semi_minor Semi-minor axis of ellipsoid.
69 Intersects(double semi_major, double semi_minor);
70 bool operator()(const Geometry *g1, const Geometry *g2) const override;
71 bool operator()(const Box *b1, const Box *b2) const;
72 bool eval(const Geometry *g1, const Geometry *g2) const;
73
74 //////////////////////////////////////////////////////////////////////////////
75
76 // intersects(Cartesian_point, *)
77
78 bool eval(const Cartesian_point *g1, const Cartesian_point *g2) const;
79 bool eval(const Cartesian_point *g1, const Cartesian_linestring *g2) const;
80 bool eval(const Cartesian_point *g1, const Cartesian_polygon *g2) const;
81 bool eval(const Cartesian_point *g1,
82 const Cartesian_geometrycollection *g2) const;
83 bool eval(const Cartesian_point *g1, const Cartesian_multipoint *g2) const;
84 bool eval(const Cartesian_point *g1,
85 const Cartesian_multilinestring *g2) const;
86 bool eval(const Cartesian_point *g1, const Cartesian_multipolygon *g2) const;
87
88 //////////////////////////////////////////////////////////////////////////////
89
90 // intersects(Cartesian_linestring, *)
91
92 bool eval(const Cartesian_linestring *g1, const Cartesian_point *g2) const;
93 bool eval(const Cartesian_linestring *g1,
94 const Cartesian_linestring *g2) const;
95 bool eval(const Cartesian_linestring *g1, const Cartesian_polygon *g2) const;
96 bool eval(const Cartesian_linestring *g1,
97 const Cartesian_geometrycollection *g2) const;
98 bool eval(const Cartesian_linestring *g1,
99 const Cartesian_multipoint *g2) const;
100 bool eval(const Cartesian_linestring *g1,
101 const Cartesian_multilinestring *g2) const;
102 bool eval(const Cartesian_linestring *g1,
103 const Cartesian_multipolygon *g2) const;
104
105 //////////////////////////////////////////////////////////////////////////////
106
107 // intersects(Cartesian_polygon, *)
108
109 bool eval(const Cartesian_polygon *g1, const Cartesian_point *g2) const;
110 bool eval(const Cartesian_polygon *g1, const Cartesian_linestring *g2) const;
111 bool eval(const Cartesian_polygon *g1, const Cartesian_polygon *g2) const;
112 bool eval(const Cartesian_polygon *g1,
113 const Cartesian_geometrycollection *g2) const;
114 bool eval(const Cartesian_polygon *g1, const Cartesian_multipoint *g2) const;
115 bool eval(const Cartesian_polygon *g1,
116 const Cartesian_multilinestring *g2) const;
117 bool eval(const Cartesian_polygon *g1,
118 const Cartesian_multipolygon *g2) const;
119
120 //////////////////////////////////////////////////////////////////////////////
121
122 // intersects(Cartesian_geometrycollection, *)
123
124 bool eval(const Cartesian_geometrycollection *g1, const Geometry *g2) const;
125
126 //////////////////////////////////////////////////////////////////////////////
127
128 // intersects(Cartesian_multipoint, *)
129
130 bool eval(const Cartesian_multipoint *g1, const Cartesian_point *g2) const;
131 bool eval(const Cartesian_multipoint *g1,
132 const Cartesian_linestring *g2) const;
133 bool eval(const Cartesian_multipoint *g1, const Cartesian_polygon *g2) const;
134 bool eval(const Cartesian_multipoint *g1,
135 const Cartesian_geometrycollection *g2) const;
136 bool eval(const Cartesian_multipoint *g1,
137 const Cartesian_multipoint *g2) const;
138 bool eval(const Cartesian_multipoint *g1,
139 const Cartesian_multilinestring *g2) const;
140 bool eval(const Cartesian_multipoint *g1,
141 const Cartesian_multipolygon *g2) const;
142
143 //////////////////////////////////////////////////////////////////////////////
144
145 // intersects(Cartesian_multilinestring, *)
146
147 bool eval(const Cartesian_multilinestring *g1,
148 const Cartesian_point *g2) const;
149 bool eval(const Cartesian_multilinestring *g1,
150 const Cartesian_linestring *g2) const;
151 bool eval(const Cartesian_multilinestring *g1,
152 const Cartesian_polygon *g2) const;
153 bool eval(const Cartesian_multilinestring *g1,
154 const Cartesian_geometrycollection *g2) const;
155 bool eval(const Cartesian_multilinestring *g1,
156 const Cartesian_multipoint *g2) const;
157 bool eval(const Cartesian_multilinestring *g1,
158 const Cartesian_multilinestring *g2) const;
159 bool eval(const Cartesian_multilinestring *g1,
160 const Cartesian_multipolygon *g2) const;
161
162 //////////////////////////////////////////////////////////////////////////////
163
164 // intersects(Cartesian_multipolygon, *)
165
166 bool eval(const Cartesian_multipolygon *g1, const Cartesian_point *g2) const;
167 bool eval(const Cartesian_multipolygon *g1,
168 const Cartesian_linestring *g2) const;
169 bool eval(const Cartesian_multipolygon *g1,
170 const Cartesian_polygon *g2) const;
171 bool eval(const Cartesian_multipolygon *g1,
172 const Cartesian_geometrycollection *g2) const;
173 bool eval(const Cartesian_multipolygon *g1,
174 const Cartesian_multipoint *g2) const;
175 bool eval(const Cartesian_multipolygon *g1,
176 const Cartesian_multilinestring *g2) const;
177 bool eval(const Cartesian_multipolygon *g1,
178 const Cartesian_multipolygon *g2) const;
179
180 //////////////////////////////////////////////////////////////////////////////
181
182 // intersects(Geographic_point, *)
183
184 bool eval(const Geographic_point *g1, const Geographic_point *g2) const;
185 bool eval(const Geographic_point *g1, const Geographic_linestring *g2) const;
186 bool eval(const Geographic_point *g1, const Geographic_polygon *g2) const;
187 bool eval(const Geographic_point *g1,
188 const Geographic_geometrycollection *g2) const;
189 bool eval(const Geographic_point *g1, const Geographic_multipoint *g2) const;
190 bool eval(const Geographic_point *g1,
191 const Geographic_multilinestring *g2) const;
192 bool eval(const Geographic_point *g1,
193 const Geographic_multipolygon *g2) const;
194
195 //////////////////////////////////////////////////////////////////////////////
196
197 // intersects(Geographic_linestring, *)
198
199 bool eval(const Geographic_linestring *g1, const Geographic_point *g2) const;
200 bool eval(const Geographic_linestring *g1,
201 const Geographic_linestring *g2) const;
202 bool eval(const Geographic_linestring *g1,
203 const Geographic_polygon *g2) const;
204 bool eval(const Geographic_linestring *g1,
205 const Geographic_geometrycollection *g2) const;
206 bool eval(const Geographic_linestring *g1,
207 const Geographic_multipoint *g2) const;
208 bool eval(const Geographic_linestring *g1,
209 const Geographic_multilinestring *g2) const;
210 bool eval(const Geographic_linestring *g1,
211 const Geographic_multipolygon *g2) const;
212
213 //////////////////////////////////////////////////////////////////////////////
214
215 // intersects(Geographic_polygon, *)
216
217 bool eval(const Geographic_polygon *g1, const Geographic_point *g2) const;
218 bool eval(const Geographic_polygon *g1,
219 const Geographic_linestring *g2) const;
220 bool eval(const Geographic_polygon *g1, const Geographic_polygon *g2) const;
221 bool eval(const Geographic_polygon *g1,
222 const Geographic_geometrycollection *g2) const;
223 bool eval(const Geographic_polygon *g1,
224 const Geographic_multipoint *g2) const;
225 bool eval(const Geographic_polygon *g1,
226 const Geographic_multilinestring *g2) const;
227 bool eval(const Geographic_polygon *g1,
228 const Geographic_multipolygon *g2) const;
229
230 //////////////////////////////////////////////////////////////////////////////
231
232 // intersects(Geographic_geometrycollection, *)
233
234 bool eval(const Geographic_geometrycollection *g1, const Geometry *g2) const;
235
236 //////////////////////////////////////////////////////////////////////////////
237
238 // intersects(Geographic_multipoint, *)
239
240 bool eval(const Geographic_multipoint *g1, const Geographic_point *g2) const;
241 bool eval(const Geographic_multipoint *g1,
242 const Geographic_linestring *g2) const;
243 bool eval(const Geographic_multipoint *g1,
244 const Geographic_polygon *g2) const;
245 bool eval(const Geographic_multipoint *g1,
246 const Geographic_geometrycollection *g2) const;
247 bool eval(const Geographic_multipoint *g1,
248 const Geographic_multipoint *g2) const;
249 bool eval(const Geographic_multipoint *g1,
250 const Geographic_multilinestring *g2) const;
251 bool eval(const Geographic_multipoint *g1,
252 const Geographic_multipolygon *g2) const;
253
254 //////////////////////////////////////////////////////////////////////////////
255
256 // intersects(Geographic_multilinestring, *)
257
258 bool eval(const Geographic_multilinestring *g1,
259 const Geographic_point *g2) const;
260 bool eval(const Geographic_multilinestring *g1,
261 const Geographic_linestring *g2) const;
262 bool eval(const Geographic_multilinestring *g1,
263 const Geographic_polygon *g2) const;
264 bool eval(const Geographic_multilinestring *g1,
265 const Geographic_geometrycollection *g2) const;
266 bool eval(const Geographic_multilinestring *g1,
267 const Geographic_multipoint *g2) const;
268 bool eval(const Geographic_multilinestring *g1,
269 const Geographic_multilinestring *g2) const;
270 bool eval(const Geographic_multilinestring *g1,
271 const Geographic_multipolygon *g2) const;
272
273 //////////////////////////////////////////////////////////////////////////////
274
275 // intersects(Geographic_multipolygon, *)
276
277 bool eval(const Geographic_multipolygon *g1,
278 const Geographic_point *g2) const;
279 bool eval(const Geographic_multipolygon *g1,
280 const Geographic_linestring *g2) const;
281 bool eval(const Geographic_multipolygon *g1,
282 const Geographic_polygon *g2) const;
283 bool eval(const Geographic_multipolygon *g1,
284 const Geographic_geometrycollection *g2) const;
285 bool eval(const Geographic_multipolygon *g1,
286 const Geographic_multipoint *g2) const;
287 bool eval(const Geographic_multipolygon *g1,
288 const Geographic_multilinestring *g2) const;
289 bool eval(const Geographic_multipolygon *g1,
290 const Geographic_multipolygon *g2) const;
291
292 //////////////////////////////////////////////////////////////////////////////
293
294 // intersects(Box, Box)
295
296 bool eval(const Cartesian_box *b1, const Cartesian_box *b2) const;
297 bool eval(const Geographic_box *b1, const Geographic_box *b2) const;
298};
299
300} // namespace gis
301
302#endif // SQL_GIS_INTERSECTS_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
Intersects functor that calls Boost.Geometry with the correct parameter types.
Definition: intersects_functor.h:51
Intersects(double semi_major, double semi_minor)
Creates a new Intersects functor.
Definition: intersects.cc:76
boost::geometry::strategy::intersection::geographic_segments m_geographic_ll_la_aa_strategy
Strategy used for L/L, L/A and A/A.
Definition: intersects_functor.h:62
boost::geometry::strategy::within::geographic_winding< Geographic_point > m_geographic_pl_pa_strategy
Strategy used for P/L and P/A.
Definition: intersects_functor.h:59
double m_semi_minor
Semi-minor axis of ellipsoid.
Definition: intersects_functor.h:56
bool operator()(const Geometry *g1, const Geometry *g2) const override
Definition: intersects.cc:84
bool eval(const Geometry *g1, const Geometry *g2) const
Definition: intersects.cc:103
double m_semi_major
Semi-major axis of ellipsoid.
Definition: intersects_functor.h:54
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