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