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