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