MySQL 9.1.0
Source Code Documentation
equals_functor.h
Go to the documentation of this file.
1#ifndef SQL_GIS_EQUALS_FUNCTOR_H_INCLUDED
2#define SQL_GIS_EQUALS_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 equals functor interface.
30///
31/// The functor is not intended for use directly by MySQL code. It should be
32/// used indirectly through the gis::equals() function.
33///
34/// @see gis::equals
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/// Equals 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 equals or other geographic functions. It should not be used
50/// directly by other MySQL code.
51class Equals : public Functor<bool> {
52 private:
53 /// Semi-major axis of ellipsoid.
55 /// Semi-minor axis of ellipsoid.
57 /// Strategy used for L/L and A/A.
58 boost::geometry::strategy::intersection::geographic_segments<>
60
61 public:
62 /// Creates a new Equals functor.
63 ///
64 /// @param semi_major Semi-major axis of ellipsoid.
65 /// @param semi_minor Semi-minor axis of ellipsoid.
66 Equals(double semi_major, double semi_minor);
67 double semi_major() const { return m_semi_major; }
68 double semi_minor() const { return m_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 // equals(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 // equals(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 // equals(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 // equals(Cartesian_geometrycollection, *)
122
123 bool eval(const Cartesian_geometrycollection *g1, const Geometry *g2) const;
124
125 //////////////////////////////////////////////////////////////////////////////
126
127 // equals(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 // equals(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 // equals(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 // equals(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 // equals(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 // equals(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 // equals(Geographic_geometrycollection, *)
232
233 bool eval(const Geographic_geometrycollection *g1, const Geometry *g2) const;
234
235 //////////////////////////////////////////////////////////////////////////////
236
237 // equals(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 // equals(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 // equals(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 // equals(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_EQUALS_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
Equals functor that calls Boost.Geometry with the correct parameter types.
Definition: equals_functor.h:51
Equals(double semi_major, double semi_minor)
Creates a new Equals functor.
Definition: equals.cc:148
double m_semi_minor
Semi-minor axis of ellipsoid.
Definition: equals_functor.h:56
boost::geometry::strategy::intersection::geographic_segments m_geographic_ll_aa_strategy
Strategy used for L/L and A/A.
Definition: equals_functor.h:59
double semi_minor() const
Definition: equals_functor.h:68
bool operator()(const Geometry *g1, const Geometry *g2) const override
Definition: equals.cc:154
double semi_major() const
Definition: equals_functor.h:67
bool eval(const Geometry *g1, const Geometry *g2) const
Definition: equals.cc:173
double m_semi_major
Semi-major axis of ellipsoid.
Definition: equals_functor.h:54
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
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