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