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