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