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