MySQL 8.0.30
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, 2022, 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 also distributed 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 included with MySQL.
16//
17// This program is distributed in the hope that it will be useful,
18// but WITHOUT ANY WARRANTY; without even the implied warranty of
19// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20// GNU General Public License, version 2.0, for more details.
21//
22// You should have received a copy of the GNU General Public License
23// along with this program; if not, write to the Free Software
24// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
25
26/// @file
27///
28/// This file declares the intersects functor interface.
29///
30/// The functor is not intended for use directly by MySQL code. It should be
31/// used indirectly through the gis::intersects() function.
32///
33/// @see gis::intersects
34
35#include <boost/geometry.hpp>
36
37#include "sql/gis/box.h"
38#include "sql/gis/functor.h"
39#include "sql/gis/geometries.h"
41
42namespace gis {
43
44/// Intersects functor that calls Boost.Geometry with the correct parameter
45/// types.
46///
47/// The functor throws exceptions and is therefore only intended used to
48/// implement intersects or other geographic functions. It should not be used
49/// directly by other MySQL code.
50class Intersects : 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 Intersects functor.
65 ///
66 /// @param semi_major Semi-major axis of ellipsoid.
67 /// @param semi_minor Semi-minor axis of ellipsoid.
68 Intersects(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 // intersects(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 // intersects(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 // intersects(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 // intersects(Cartesian_geometrycollection, *)
122
123 bool eval(const Cartesian_geometrycollection *g1, const Geometry *g2) const;
124
125 //////////////////////////////////////////////////////////////////////////////
126
127 // intersects(Cartesian_multipoint, *)
128
129 bool eval(const Cartesian_multipoint *g1, const Cartesian_point *g2) const;
130 bool eval(const Cartesian_multipoint *g1,
131 const Cartesian_linestring *g2) const;
132 bool eval(const Cartesian_multipoint *g1, const Cartesian_polygon *g2) const;
133 bool eval(const Cartesian_multipoint *g1,
134 const Cartesian_geometrycollection *g2) const;
135 bool eval(const Cartesian_multipoint *g1,
136 const Cartesian_multipoint *g2) const;
137 bool eval(const Cartesian_multipoint *g1,
138 const Cartesian_multilinestring *g2) const;
139 bool eval(const Cartesian_multipoint *g1,
140 const Cartesian_multipolygon *g2) const;
141
142 //////////////////////////////////////////////////////////////////////////////
143
144 // intersects(Cartesian_multilinestring, *)
145
146 bool eval(const Cartesian_multilinestring *g1,
147 const Cartesian_point *g2) const;
148 bool eval(const Cartesian_multilinestring *g1,
149 const Cartesian_linestring *g2) const;
150 bool eval(const Cartesian_multilinestring *g1,
151 const Cartesian_polygon *g2) const;
152 bool eval(const Cartesian_multilinestring *g1,
153 const Cartesian_geometrycollection *g2) const;
154 bool eval(const Cartesian_multilinestring *g1,
155 const Cartesian_multipoint *g2) const;
156 bool eval(const Cartesian_multilinestring *g1,
157 const Cartesian_multilinestring *g2) const;
158 bool eval(const Cartesian_multilinestring *g1,
159 const Cartesian_multipolygon *g2) const;
160
161 //////////////////////////////////////////////////////////////////////////////
162
163 // intersects(Cartesian_multipolygon, *)
164
165 bool eval(const Cartesian_multipolygon *g1, const Cartesian_point *g2) const;
166 bool eval(const Cartesian_multipolygon *g1,
167 const Cartesian_linestring *g2) const;
168 bool eval(const Cartesian_multipolygon *g1,
169 const Cartesian_polygon *g2) const;
170 bool eval(const Cartesian_multipolygon *g1,
171 const Cartesian_geometrycollection *g2) const;
172 bool eval(const Cartesian_multipolygon *g1,
173 const Cartesian_multipoint *g2) const;
174 bool eval(const Cartesian_multipolygon *g1,
175 const Cartesian_multilinestring *g2) const;
176 bool eval(const Cartesian_multipolygon *g1,
177 const Cartesian_multipolygon *g2) const;
178
179 //////////////////////////////////////////////////////////////////////////////
180
181 // intersects(Geographic_point, *)
182
183 bool eval(const Geographic_point *g1, const Geographic_point *g2) const;
184 bool eval(const Geographic_point *g1, const Geographic_linestring *g2) const;
185 bool eval(const Geographic_point *g1, const Geographic_polygon *g2) const;
186 bool eval(const Geographic_point *g1,
187 const Geographic_geometrycollection *g2) const;
188 bool eval(const Geographic_point *g1, const Geographic_multipoint *g2) const;
189 bool eval(const Geographic_point *g1,
190 const Geographic_multilinestring *g2) const;
191 bool eval(const Geographic_point *g1,
192 const Geographic_multipolygon *g2) const;
193
194 //////////////////////////////////////////////////////////////////////////////
195
196 // intersects(Geographic_linestring, *)
197
198 bool eval(const Geographic_linestring *g1, const Geographic_point *g2) const;
199 bool eval(const Geographic_linestring *g1,
200 const Geographic_linestring *g2) const;
201 bool eval(const Geographic_linestring *g1,
202 const Geographic_polygon *g2) const;
203 bool eval(const Geographic_linestring *g1,
204 const Geographic_geometrycollection *g2) const;
205 bool eval(const Geographic_linestring *g1,
206 const Geographic_multipoint *g2) const;
207 bool eval(const Geographic_linestring *g1,
208 const Geographic_multilinestring *g2) const;
209 bool eval(const Geographic_linestring *g1,
210 const Geographic_multipolygon *g2) const;
211
212 //////////////////////////////////////////////////////////////////////////////
213
214 // intersects(Geographic_polygon, *)
215
216 bool eval(const Geographic_polygon *g1, const Geographic_point *g2) const;
217 bool eval(const Geographic_polygon *g1,
218 const Geographic_linestring *g2) const;
219 bool eval(const Geographic_polygon *g1, const Geographic_polygon *g2) const;
220 bool eval(const Geographic_polygon *g1,
221 const Geographic_geometrycollection *g2) const;
222 bool eval(const Geographic_polygon *g1,
223 const Geographic_multipoint *g2) const;
224 bool eval(const Geographic_polygon *g1,
225 const Geographic_multilinestring *g2) const;
226 bool eval(const Geographic_polygon *g1,
227 const Geographic_multipolygon *g2) const;
228
229 //////////////////////////////////////////////////////////////////////////////
230
231 // intersects(Geographic_geometrycollection, *)
232
233 bool eval(const Geographic_geometrycollection *g1, const Geometry *g2) const;
234
235 //////////////////////////////////////////////////////////////////////////////
236
237 // intersects(Geographic_multipoint, *)
238
239 bool eval(const Geographic_multipoint *g1, const Geographic_point *g2) const;
240 bool eval(const Geographic_multipoint *g1,
241 const Geographic_linestring *g2) const;
242 bool eval(const Geographic_multipoint *g1,
243 const Geographic_polygon *g2) const;
244 bool eval(const Geographic_multipoint *g1,
245 const Geographic_geometrycollection *g2) const;
246 bool eval(const Geographic_multipoint *g1,
247 const Geographic_multipoint *g2) const;
248 bool eval(const Geographic_multipoint *g1,
249 const Geographic_multilinestring *g2) const;
250 bool eval(const Geographic_multipoint *g1,
251 const Geographic_multipolygon *g2) const;
252
253 //////////////////////////////////////////////////////////////////////////////
254
255 // intersects(Geographic_multilinestring, *)
256
257 bool eval(const Geographic_multilinestring *g1,
258 const Geographic_point *g2) const;
259 bool eval(const Geographic_multilinestring *g1,
260 const Geographic_linestring *g2) const;
261 bool eval(const Geographic_multilinestring *g1,
262 const Geographic_polygon *g2) const;
263 bool eval(const Geographic_multilinestring *g1,
264 const Geographic_geometrycollection *g2) const;
265 bool eval(const Geographic_multilinestring *g1,
266 const Geographic_multipoint *g2) const;
267 bool eval(const Geographic_multilinestring *g1,
268 const Geographic_multilinestring *g2) const;
269 bool eval(const Geographic_multilinestring *g1,
270 const Geographic_multipolygon *g2) const;
271
272 //////////////////////////////////////////////////////////////////////////////
273
274 // intersects(Geographic_multipolygon, *)
275
276 bool eval(const Geographic_multipolygon *g1,
277 const Geographic_point *g2) const;
278 bool eval(const Geographic_multipolygon *g1,
279 const Geographic_linestring *g2) const;
280 bool eval(const Geographic_multipolygon *g1,
281 const Geographic_polygon *g2) const;
282 bool eval(const Geographic_multipolygon *g1,
283 const Geographic_geometrycollection *g2) const;
284 bool eval(const Geographic_multipolygon *g1,
285 const Geographic_multipoint *g2) const;
286 bool eval(const Geographic_multipolygon *g1,
287 const Geographic_multilinestring *g2) const;
288 bool eval(const Geographic_multipolygon *g1,
289 const Geographic_multipolygon *g2) const;
290
291 //////////////////////////////////////////////////////////////////////////////
292
293 // intersects(Box, Box)
294
295 bool eval(const Cartesian_box *b1, const Cartesian_box *b2) const;
296 bool eval(const Geographic_box *b1, const Geographic_box *b2) const;
297};
298
299} // namespace gis
300
301#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:40
A Cartesian 2d box.
Definition: box.h:69
A Cartesian 2d geometry collection.
Definition: geometries_cs.h:374
A Cartesian 2d linestring.
Definition: geometries_cs.h:70
A Cartesian 2d multilinestring.
Definition: geometries_cs.h:601
A Cartesian 2d multipoint.
Definition: geometries_cs.h:500
A Cartesian 2d multipolygon.
Definition: geometries_cs.h:719
A Cartesian 2d point.
Definition: geometries_cs.h:46
A Cartesian 2d polygon.
Definition: geometries_cs.h:268
The base class of all functors that takes two geometry arguments.
Definition: functor.h:164
A Geographic 2d box.
Definition: box.h:102
A geographic (ellipsoidal) 2d geometry collection.
Definition: geometries_cs.h:437
A geographic (ellipsoidal) 2d linestring.
Definition: geometries_cs.h:124
A geographic (ellipsoidal) 2d multilinestring.
Definition: geometries_cs.h:660
A geographic (ellipsoidal) 2d multipoint.
Definition: geometries_cs.h:551
A geographic (ellipsoidal) 2d multipolygon.
Definition: geometries_cs.h:773
A geographic (ellipsoidal) 2d point.
Definition: geometries_cs.h:57
A geographic (ellipsoidal) 2d polygon.
Definition: geometries_cs.h:321
Abstract superclass for all geometric objects.
Definition: geometries.h:99
Intersects functor that calls Boost.Geometry with the correct parameter types.
Definition: intersects_functor.h:50
Intersects(double semi_major, double semi_minor)
Creates a new Intersects functor.
Definition: intersects.cc:75
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:61
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:58
double m_semi_minor
Semi-minor axis of ellipsoid.
Definition: intersects_functor.h:55
bool operator()(const Geometry *g1, const Geometry *g2) const override
Definition: intersects.cc:83
bool eval(const Geometry *g1, const Geometry *g2) const
Definition: intersects.cc:102
double m_semi_major
Semi-major axis of ellipsoid.
Definition: intersects_functor.h:53
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:46