MySQL 9.1.0
Source Code Documentation
symdifference_functor.h
Go to the documentation of this file.
1#ifndef SQL_GIS_SYMDIFFERENCE_FUNCTOR_H_INCLUDED
2#define SQL_GIS_SYMDIFFERENCE_FUNCTOR_H_INCLUDED
3
4// Copyright (c) 2021, 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 symdifference functor interface.
30///
31/// The functor is not intended for use directly by MySQL code. It should be
32/// used indirectly through the gis::symdifference() function.
33///
34/// @see gis::symdifference
35
36#include <boost/geometry.hpp>
37
38#include "sql/gis/functor.h"
39#include "sql/gis/geometries.h"
41
42namespace gis {
43
44/// SymDifference 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 symdifference or other geographic functions. It should not be used
49/// directly by other MySQL code.
50class SymDifference : public Functor<std::unique_ptr<Geometry>> {
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<>
59 /// Strategy used for L/L, L/A and A/A.
60 boost::geometry::strategy::intersection::geographic_segments<>
62
63 public:
64 SymDifference(double semi_major, double semi_minor);
65 double semi_minor() const { return m_semi_minor; }
66 double semi_major() const { return m_semi_major; }
68 boost::geometry::strategy::intersection::geographic_segments<>
71 }
72 std::unique_ptr<Geometry> operator()(const Geometry *g1,
73 const Geometry *g2) const override;
74 std::unique_ptr<Geometry> eval(const Geometry *g1, const Geometry *g2) const;
75
76 //////////////////////////////////////////////////////////////////////////////
77
78 // symdifference(Cartesian_point, *)
79
80 std::unique_ptr<Cartesian_multipoint> eval(const Cartesian_point *g1,
81 const Cartesian_point *g2) const;
82 std::unique_ptr<Cartesian_geometrycollection> eval(
83 const Cartesian_point *g1, const Cartesian_linestring *g2) const;
84 std::unique_ptr<Cartesian_geometrycollection> eval(
85 const Cartesian_point *g1, const Cartesian_polygon *g2) const;
86 std::unique_ptr<Cartesian_multipoint> eval(
87 const Cartesian_point *g1, const Cartesian_multipoint *g2) const;
88 std::unique_ptr<Cartesian_geometrycollection> eval(
89 const Cartesian_point *g1, const Cartesian_multilinestring *g2) const;
90 std::unique_ptr<Cartesian_geometrycollection> eval(
91 const Cartesian_point *g1, const Cartesian_multipolygon *g2) const;
92 std::unique_ptr<Geometry> eval(const Cartesian_point *g1,
93 const Cartesian_geometrycollection *g2) const;
94
95 //////////////////////////////////////////////////////////////////////////////
96
97 // symdifference(Cartesian_linestring, *)
98
99 std::unique_ptr<Geometry> eval(const Cartesian_linestring *g1,
100 const Cartesian_point *g2) const;
101 std::unique_ptr<Cartesian_multilinestring> eval(
102 const Cartesian_linestring *g1, const Cartesian_linestring *g2) const;
103 std::unique_ptr<Cartesian_geometrycollection> eval(
104 const Cartesian_linestring *g1, const Cartesian_polygon *g2) const;
105 std::unique_ptr<Cartesian_geometrycollection> eval(
106 const Cartesian_linestring *g1, const Cartesian_multipoint *g2) const;
107 std::unique_ptr<Cartesian_multilinestring> eval(
108 const Cartesian_linestring *g1,
109 const Cartesian_multilinestring *g2) const;
110 std::unique_ptr<Cartesian_geometrycollection> eval(
111 const Cartesian_linestring *g1, const Cartesian_multipolygon *g2) const;
112 std::unique_ptr<Geometry> eval(const Cartesian_linestring *g1,
113 const Cartesian_geometrycollection *g2) const;
114
115 //////////////////////////////////////////////////////////////////////////////
116
117 // symdifference(Cartesian_polygon, *)
118
119 std::unique_ptr<Geometry> eval(const Cartesian_polygon *g1,
120 const Cartesian_point *g2) const;
121 std::unique_ptr<Geometry> eval(const Cartesian_polygon *g1,
122 const Cartesian_linestring *g2) const;
123 std::unique_ptr<Cartesian_multipolygon> eval(
124 const Cartesian_polygon *g1, const Cartesian_polygon *g2) const;
125 std::unique_ptr<Cartesian_geometrycollection> eval(
126 const Cartesian_polygon *g1, const Cartesian_multipoint *g2) const;
127 std::unique_ptr<Cartesian_geometrycollection> eval(
128 const Cartesian_polygon *g1, const Cartesian_multilinestring *g2) const;
129 std::unique_ptr<Cartesian_multipolygon> eval(
130 const Cartesian_polygon *g1, const Cartesian_multipolygon *g2) const;
131 std::unique_ptr<Geometry> eval(const Cartesian_polygon *g1,
132 const Cartesian_geometrycollection *g2) const;
133
134 //////////////////////////////////////////////////////////////////////////////
135
136 // symdifference(Cartesian_geometrycollection, *)
137
138 std::unique_ptr<Geometry> eval(const Cartesian_geometrycollection *g1,
139 const Cartesian_geometrycollection *g2) const;
140
141 std::unique_ptr<Geometry> eval(const Cartesian_geometrycollection *g1,
142 const Geometry *g2) const;
143
144 //////////////////////////////////////////////////////////////////////////////
145
146 // symdifference(Cartesian_multipoint, *)
147
148 std::unique_ptr<Geometry> eval(const Cartesian_multipoint *g1,
149 const Cartesian_point *g2) const;
150 std::unique_ptr<Geometry> eval(const Cartesian_multipoint *g1,
151 const Cartesian_linestring *g2) const;
152 std::unique_ptr<Geometry> eval(const Cartesian_multipoint *g1,
153 const Cartesian_polygon *g2) const;
154 std::unique_ptr<Cartesian_multipoint> eval(
155 const Cartesian_multipoint *g1, const Cartesian_multipoint *g2) const;
156 std::unique_ptr<Cartesian_geometrycollection> eval(
157 const Cartesian_multipoint *g1,
158 const Cartesian_multilinestring *g2) const;
159 std::unique_ptr<Cartesian_geometrycollection> eval(
160 const Cartesian_multipoint *g1, const Cartesian_multipolygon *g2) const;
161 std::unique_ptr<Geometry> eval(const Cartesian_multipoint *g1,
162 const Cartesian_geometrycollection *g2) const;
163
164 //////////////////////////////////////////////////////////////////////////////
165
166 // symdifference(Cartesian_multilinestring, *)
167
168 std::unique_ptr<Geometry> eval(const Cartesian_multilinestring *g1,
169 const Cartesian_point *g2) const;
170 std::unique_ptr<Geometry> eval(const Cartesian_multilinestring *g1,
171 const Cartesian_linestring *g2) const;
172 std::unique_ptr<Geometry> eval(const Cartesian_multilinestring *g1,
173 const Cartesian_polygon *g2) const;
174 std::unique_ptr<Geometry> eval(const Cartesian_multilinestring *g1,
175 const Cartesian_multipoint *g2) const;
176 std::unique_ptr<Cartesian_multilinestring> eval(
178 const Cartesian_multilinestring *g2) const;
179 std::unique_ptr<Cartesian_geometrycollection> eval(
181 const Cartesian_multipolygon *g2) const;
182 std::unique_ptr<Geometry> eval(const Cartesian_multilinestring *g1,
183 const Cartesian_geometrycollection *g2) const;
184
185 //////////////////////////////////////////////////////////////////////////////
186
187 // symdifference(Cartesian_multipolygon, *)
188
189 std::unique_ptr<Geometry> eval(const Cartesian_multipolygon *g1,
190 const Cartesian_point *g2) const;
191 std::unique_ptr<Geometry> eval(const Cartesian_multipolygon *g1,
192 const Cartesian_linestring *g2) const;
193 std::unique_ptr<Geometry> eval(const Cartesian_multipolygon *g1,
194 const Cartesian_polygon *g2) const;
195 std::unique_ptr<Geometry> eval(const Cartesian_multipolygon *g1,
196 const Cartesian_multipoint *g2) const;
197 std::unique_ptr<Geometry> eval(const Cartesian_multipolygon *g1,
198 const Cartesian_multilinestring *g2) const;
199 std::unique_ptr<Cartesian_multipolygon> eval(
200 const Cartesian_multipolygon *g1, const Cartesian_multipolygon *g2) const;
201 std::unique_ptr<Geometry> eval(const Cartesian_multipolygon *g1,
202 const Cartesian_geometrycollection *g2) const;
203
204 //////////////////////////////////////////////////////////////////////////////
205
206 // symdifference(Geographic_point, *)
207
208 std::unique_ptr<Geographic_multipoint> eval(const Geographic_point *g1,
209 const Geographic_point *g2) const;
210 std::unique_ptr<Geographic_geometrycollection> eval(
211 const Geographic_point *g1, const Geographic_linestring *g2) const;
212 std::unique_ptr<Geographic_geometrycollection> eval(
213 const Geographic_point *g1, const Geographic_polygon *g2) const;
214 std::unique_ptr<Geographic_multipoint> eval(
215 const Geographic_point *g1, const Geographic_multipoint *g2) const;
216 std::unique_ptr<Geographic_geometrycollection> eval(
217 const Geographic_point *g1, const Geographic_multilinestring *g2) const;
218 std::unique_ptr<Geographic_geometrycollection> eval(
219 const Geographic_point *g1, const Geographic_multipolygon *g2) const;
220 std::unique_ptr<Geometry> eval(const Geographic_point *g1,
221 const Geographic_geometrycollection *g2) const;
222
223 //////////////////////////////////////////////////////////////////////////////
224
225 // symdifference(Geographic_linestring, *)
226
227 std::unique_ptr<Geometry> eval(const Geographic_linestring *g1,
228 const Geographic_point *g2) const;
229 std::unique_ptr<Geographic_multilinestring> eval(
230 const Geographic_linestring *g1, const Geographic_linestring *g2) const;
231 std::unique_ptr<Geographic_geometrycollection> eval(
232 const Geographic_linestring *g1, const Geographic_polygon *g2) const;
233 std::unique_ptr<Geographic_geometrycollection> eval(
234 const Geographic_linestring *g1, const Geographic_multipoint *g2) const;
235 std::unique_ptr<Geographic_multilinestring> eval(
236 const Geographic_linestring *g1,
237 const Geographic_multilinestring *g2) const;
238 std::unique_ptr<Geographic_geometrycollection> eval(
239 const Geographic_linestring *g1, const Geographic_multipolygon *g2) const;
240 std::unique_ptr<Geometry> eval(const Geographic_linestring *g1,
241 const Geographic_geometrycollection *g2) const;
242
243 //////////////////////////////////////////////////////////////////////////////
244
245 // symdifference(Geographic_polygon, *)
246
247 std::unique_ptr<Geometry> eval(const Geographic_polygon *g1,
248 const Geographic_point *g2) const;
249 std::unique_ptr<Geometry> eval(const Geographic_polygon *g1,
250 const Geographic_linestring *g2) const;
251 std::unique_ptr<Geographic_multipolygon> eval(
252 const Geographic_polygon *g1, const Geographic_polygon *g2) const;
253 std::unique_ptr<Geographic_geometrycollection> eval(
254 const Geographic_polygon *g1, const Geographic_multipoint *g2) const;
255 std::unique_ptr<Geographic_geometrycollection> eval(
256 const Geographic_polygon *g1, const Geographic_multilinestring *g2) const;
257 std::unique_ptr<Geographic_multipolygon> eval(
258 const Geographic_polygon *g1, const Geographic_multipolygon *g2) const;
259 std::unique_ptr<Geometry> eval(const Geographic_polygon *g1,
260 const Geographic_geometrycollection *g2) const;
261
262 //////////////////////////////////////////////////////////////////////////////
263
264 // symdifference(Geographic_geometrycollection, *)
265
266 std::unique_ptr<Geometry> eval(const Geographic_geometrycollection *g1,
267 const Geographic_geometrycollection *g2) const;
268
269 std::unique_ptr<Geometry> eval(const Geographic_geometrycollection *g1,
270 const Geometry *g2) const;
271
272 //////////////////////////////////////////////////////////////////////////////
273
274 // symdifference(Geographic_multipoint, *)
275
276 std::unique_ptr<Geometry> eval(const Geographic_multipoint *g1,
277 const Geographic_point *g2) const;
278 std::unique_ptr<Geometry> eval(const Geographic_multipoint *g1,
279 const Geographic_linestring *g2) const;
280 std::unique_ptr<Geometry> eval(const Geographic_multipoint *g1,
281 const Geographic_polygon *g2) const;
282 std::unique_ptr<Geographic_multipoint> eval(
283 const Geographic_multipoint *g1, const Geographic_multipoint *g2) const;
284 std::unique_ptr<Geographic_geometrycollection> eval(
285 const Geographic_multipoint *g1,
286 const Geographic_multilinestring *g2) const;
287 std::unique_ptr<Geographic_geometrycollection> eval(
288 const Geographic_multipoint *g1, const Geographic_multipolygon *g2) const;
289 std::unique_ptr<Geometry> eval(const Geographic_multipoint *g1,
290 const Geographic_geometrycollection *g2) const;
291
292 //////////////////////////////////////////////////////////////////////////////
293
294 // symdifference(Geographic_multilinestring, *)
295
296 std::unique_ptr<Geometry> eval(const Geographic_multilinestring *g1,
297 const Geographic_point *g2) const;
298 std::unique_ptr<Geometry> eval(const Geographic_multilinestring *g1,
299 const Geographic_linestring *g2) const;
300 std::unique_ptr<Geometry> eval(const Geographic_multilinestring *g1,
301 const Geographic_polygon *g2) const;
302 std::unique_ptr<Geometry> eval(const Geographic_multilinestring *g1,
303 const Geographic_multipoint *g2) const;
304 std::unique_ptr<Geographic_multilinestring> eval(
306 const Geographic_multilinestring *g2) const;
307 std::unique_ptr<Geographic_geometrycollection> eval(
309 const Geographic_multipolygon *g2) const;
310 std::unique_ptr<Geometry> eval(const Geographic_multilinestring *g1,
311 const Geographic_geometrycollection *g2) const;
312
313 //////////////////////////////////////////////////////////////////////////////
314
315 // symdifference(Geographic_multipolygon, *)
316
317 std::unique_ptr<Geometry> eval(const Geographic_multipolygon *g1,
318 const Geographic_point *g2) const;
319 std::unique_ptr<Geometry> eval(const Geographic_multipolygon *g1,
320 const Geographic_linestring *g2) const;
321 std::unique_ptr<Geometry> eval(const Geographic_multipolygon *g1,
322 const Geographic_polygon *g2) const;
323 std::unique_ptr<Geometry> eval(const Geographic_multipolygon *g1,
324 const Geographic_multipoint *g2) const;
325 std::unique_ptr<Geometry> eval(const Geographic_multipolygon *g1,
326 const Geographic_multilinestring *g2) const;
327 std::unique_ptr<Geographic_multipolygon> eval(
328 const Geographic_multipolygon *g1,
329 const Geographic_multipolygon *g2) const;
330 std::unique_ptr<Geometry> eval(const Geographic_multipolygon *g1,
331 const Geographic_geometrycollection *g2) const;
332};
333
334} // namespace gis
335
336#endif // SQL_GIS_SYMDIFFERENCE_FUNCTOR_H_INCLUDED
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 (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
SymDifference functor that calls Boost.Geometry with the correct parameter types.
Definition: symdifference_functor.h:50
double semi_major() const
Definition: symdifference_functor.h:66
double m_semi_major
Semi-major axis of ellipsoid.
Definition: symdifference_functor.h:53
double semi_minor() const
Definition: symdifference_functor.h:65
SymDifference(double semi_major, double semi_minor)
Definition: symdifference_functor.cc:228
std::unique_ptr< Geometry > eval(const Geometry *g1, const Geometry *g2) const
Definition: symdifference_functor.cc:246
boost::geometry::strategy::intersection::geographic_segments get_ll_la_aa_strategy() const
Definition: symdifference_functor.h:69
double m_semi_minor
Semi-minor axis of ellipsoid.
Definition: symdifference_functor.h:55
boost::geometry::strategy::within::geographic_winding m_geographic_pl_pa_strategy
Strategy used for P/L and P/A.
Definition: symdifference_functor.h:58
std::unique_ptr< Geometry > operator()(const Geometry *g1, const Geometry *g2) const override
Definition: symdifference_functor.cc:236
boost::geometry::strategy::intersection::geographic_segments m_geographic_ll_la_aa_strategy
Strategy used for L/L, L/A and A/A.
Definition: symdifference_functor.h:61
auto get_pl_pa_strategy() const
Definition: symdifference_functor.h:67
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