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