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