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