MySQL  8.0.28
Source Code Documentation
geometries.h
Go to the documentation of this file.
1 #ifndef SQL_GIS_GEOMETRIES_H_INCLUDED
2 #define SQL_GIS_GEOMETRIES_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 geometry class hierarchy used by the server as the
29 /// internal representation of geometries.
30 ///
31 /// The hierarchy is closely modelled after the hierarchy in SFA-CA
32 /// (OGC 06-103r4), but since Boost.Geometry depends on type traits to
33 /// know if a geometry is in a Cartesian or geographic SRS, there are
34 /// Cartesian and geographic specializations of each instantiable type
35 /// in the SFA-CA. These are defined in geometries_cs.h.
36 ///
37 /// Because of Boost.Geometry, iterators have to be of coordinate system
38 /// specific types. It is therefore not possible to have the standard begin()
39 /// and end() iterators in the common superclass. Instead, operator[] is
40 /// provided as a coordinate system agnostic option.
41 ///
42 /// @see geometries_cs.h
43 
44 #include <cmath>
45 #include <cstdint>
46 
47 namespace gis {
48 
49 /// Types of geometry objects. Not all are instantiable.
50 ///
51 /// The values and the storage type are the same as used in WKB.
52 enum class Geometry_type : std::uint32_t {
53  kGeometry = 0,
54  kPoint = 1,
55  kLinestring = 2,
56  kPolygon = 3,
57  kMultipoint = 4,
58  kMultilinestring = 5,
59  kMultipolygon = 6,
61  // kMulticurve = 11,
62  // kMultisurface = 12,
63  // kCurve = 13,
64  // kSurface = 14,
65 };
66 
67 /// Types of coordinate systems.
68 enum class Coordinate_system {
69  /// A Cartesian plane with the same unit in both directions.
70  kCartesian = 0,
71  /// An ellipsoidal system with longitude and latitude coordinates,
72  /// both in the same unit.
73  kGeographic = 1
74 };
75 
76 /// Direction of a ring.
77 enum class Ring_direction {
78  /// Clockwise.
79  kCW = 0,
80  /// Counterclockwise.
81  kCCW = 1,
82  /// Unknown.
83  ///
84  /// Used only as an output value when the function is unable to determine the
85  /// ring direction, e.g., if the ring contains only repetitions of the same
86  /// point, or if there is a spike in the ring.
87  kUnknown = 2
88 };
89 
90 class Geometry_visitor;
91 
92 /// Abstract superclass for all geometric objects.
93 ///
94 /// Geometry is a non-instantiable type in SQL.
95 ///
96 /// The hierarchy is first divided into abstract classes according to the SFA-CA
97 /// geometry type hierarchy, and then divided into concrete subclasses for each
98 /// coordinate system.
99 class Geometry {
100  public:
101  Geometry() = default;
102  virtual ~Geometry() = default;
103  Geometry(const Geometry &) = default;
104  Geometry &operator=(const Geometry &) = default;
105 
106  // Returns a copy of an instantiable subclass of Geometry.
107 
108  virtual Geometry *clone() const = 0;
109 
110  /// Gets the geometry type of the object.
111  ///
112  /// @return The type of this object
113  virtual Geometry_type type() const = 0;
114 
115  /// Gets the coordinate system.
116  ///
117  /// @return The coordiante system type.
119 
120  /// Applies a hierarchical visitor to this geometry.
121  ///
122  /// @see gis::Geometry_visitor
123  ///
124  /// @param v A hierarchical visitor.
125  ///
126  /// @retval true The execution was aborted by the visitor.
127  /// @retval false The execution completed.
128  virtual bool accept(Geometry_visitor *v) = 0;
129 
130  /// Check if this is an empty geometry.
131  ///
132  /// The definition of empty geometries is the one in SFA-CA (OGC 06-103r4,
133  /// Sect. 6.1.2.2), i.e., an empty point set.
134  ///
135  /// @note This is different from the function "empty", which returns true if a
136  /// geometry contains no subgeometries. E.g., a geometry collection may
137  /// contain another geometry collection which is empty. In this case, the
138  /// "empty" function would return false on the outermost geometry collection,
139  /// while "is_empty" would return true.
140  ///
141  /// @retval true The geometry represents the empty point set.
142  /// @retval false The geometry represent a non-empty point set.
143  virtual bool is_empty() const = 0;
144 };
145 
146 /// A 2d point.
147 ///
148 /// Point is an instantiable type in SQL.
149 class Point : public Geometry {
150  public:
151  Point() : m_x(std::nan("")), m_y(std::nan("")) {}
152  Point(double x, double y) : m_x(x), m_y(y) {}
153  Geometry_type type() const override { return Geometry_type::kPoint; }
154  bool accept(Geometry_visitor *v) override;
155  bool is_empty() const override {
156  return (std::isnan(m_x) || std::isnan(m_y));
157  }
158 
159  // Returns a copy of a subclass of Point.
160 
161  Point *clone() const override = 0;
162 
163  /// Gets a coordinate value.
164  ///
165  /// This function signature must match the expectations of Boost.Geometry.
166  ///
167  /// @tparam K Coordinate number, zero indexed.
168  /// @return The coordinate value.
169  template <std::size_t K>
170  double get() const;
171 
172  /// Gets the first coordinate value.
173  ///
174  /// For geographic points, the first coordinate is longitude.
175  ///
176  /// @return The first coordinate value.
177  double x() const;
178 
179  /// Gets the second coordinate value.
180  ///
181  /// For geographic points, the second coordinate is latitude.
182  ///
183  /// @return The second coordinate value.
184  double y() const;
185 
186  /// Sets a coordinate.
187  ///
188  /// This function signature must match the expectations of Boost.Geometry.
189  ///
190  /// @tparam K Coordinate number, zero indexed.
191  /// @param d The coordinate value.
192  template <std::size_t K>
193  void set(double d);
194 
195  /// Sets the first coordinate value.
196  ///
197  /// For geographic points, the first coordinate is longitude.
198  ///
199  /// @param d The coordinate value.
200  void x(double d);
201 
202  /// Sets the second coordinate value.
203  ///
204  /// For geographic points, the second coordinate is latitude.
205  ///
206  /// @param d The coordinate value.
207  void y(double d);
208 
209  private:
210  /// First coordinate (X or longitude).
211  ///
212  /// Geographic coordinates are in radians, positive to the East of
213  /// Greenwich. Cartesian coordinates are in the SRSs length unit.
214  double m_x;
215 
216  /// Second coordinate (Y or latitude).
217  ///
218  /// Geographic coordinates are in radians, positive to the North of the
219  /// Equator. Cartesian coordinates are in the SRSs length unit.
220  double m_y;
221 };
222 
223 /// Compares two points.
224 ///
225 /// The point with the lowest X coordinate is the smaller point. If X
226 /// coordinates are equal, the point with the lowest Y coordinate is the
227 /// smaller.
228 ///
229 /// @param lhs Left hand side.
230 /// @param rhs Right hand side.
231 ///
232 /// @retval true Left hand side sorts before right hand side.
233 /// @retval false Left hand side does not sort before right hand side.
234 inline bool operator<(const Point &lhs, const Point &rhs) {
235  return (lhs.x() < rhs.x()) || (lhs.x() == rhs.x() && lhs.y() < rhs.y());
236 }
237 
238 /// An abstract 2d curve.
239 ///
240 /// Curve is a non-instantiable type in SQL.
241 class Curve : public Geometry {
242  public:
243  Geometry_type type() const override = 0;
244  bool accept(Geometry_visitor *v) override = 0;
245 };
246 
247 /// A string of connected line segments.
248 ///
249 /// Linestring is an instantiable type in SQL.
250 ///
251 /// According to the SFA-CA, linestrings have a linear interpolation between
252 /// points. In MySQL, a linestring represents the geodesic. On a plane, this is
253 /// linear interpolation, but on an ellipsoid, it's the shortest path along the
254 /// ellipsoid surface.
255 class Linestring : public Curve {
256  public:
257  Geometry_type type() const override { return Geometry_type::kLinestring; }
258  bool accept(Geometry_visitor *v) override = 0;
259  bool is_empty() const override { return empty(); }
260 
261  /// Creates a subclass of Linestring from a Coordinate_system
262  ///
263  /// @param[in] coordinate_system Coordinate system to create a Linestring for.
264  /// @return A pointer to a Linestring that caller must free when it is done
265  /// with it.
267 
268  // Returns a copy of a subclass of Linestring.
269  Linestring *clone() const override = 0;
270 
271  /// Adds a point to the end of the linestring.
272  ///
273  /// @param pt The point to add.
274  virtual void push_back(const Point &pt) = 0;
275  virtual void push_back(Point &&pt) = 0;
276 
277  /// Removes a point from the front of the linestring.
278  virtual void pop_front() = 0;
279 
280  /// Checks if the linestring is empty.
281  ///
282  /// Here, the definition of empty is that the linestring does not contain any
283  /// points. An invalid linestring with only one coordinate is not empty.
284  ///
285  /// @retval true The linestring is empty.
286  /// @retval false The linestring is not empty.
287  virtual bool empty() const = 0;
288 
289  /// Returns the size of (number of points in) the linestring.
290  ///
291  /// @return Number of points in the linestring.
292  virtual std::size_t size() const = 0;
293 
294  /// Removes all points from the linestring.
295  virtual void clear() noexcept = 0;
296  /// Returns the last point of the linestring.
297  ///
298  /// @return Last point of linestring
299  virtual Point &back() = 0;
300  virtual const Point &back() const = 0;
301 
302  /// Returns the first point of the linestring.
303  ///
304  /// @return First point of linestring
305  virtual Point &front() = 0;
306  virtual const Point &front() const = 0;
307 
308  virtual Point &operator[](std::size_t i) = 0;
309  virtual const Point &operator[](std::size_t i) const = 0;
310 };
311 
312 /// A ring-shaped linestring.
313 ///
314 /// Linearring is a non-instantiable type in SQL. It is used to represent
315 /// polygon rings.
316 ///
317 /// The start and end point of the linestring must be the same (assumed, but not
318 /// enforced, by the implementation).
319 class Linearring : public Linestring {
320  public:
321  bool accept(Geometry_visitor *v) override = 0;
322 
323  /// Creates a subclass of Linearring from a Coordinate_system
324  ///
325  /// @param[in] coordinate_system Coordinate system to create a Linearring for.
326  /// @return A pointer to a Linearring that caller must free when it is done
327  /// with it.
328  static Linearring *create_linearring(Coordinate_system coordinate_system);
329 };
330 
331 /// An abstract 2d surface.
332 ///
333 /// Surface is a non-instantiable type in SQL.
334 class Surface : public Geometry {
335  public:
336  bool accept(Geometry_visitor *v) override = 0;
337 
338  Geometry_type type() const override = 0;
339 };
340 
341 /// A polygon consisting of an outer ring and zero or more interior rings
342 /// defining holes in the polygon.
343 ///
344 /// Polygon is an instantiable type in SQL.
345 ///
346 /// The interior rings must be inside the exterior ring (not enforced by the
347 /// implementation).
348 class Polygon : public Surface {
349  public:
350  Geometry_type type() const override { return Geometry_type::kPolygon; }
351  bool accept(Geometry_visitor *v) override = 0;
352  bool is_empty() const override { return empty(); }
353 
354  /// Creates a subclass of Polygon from a Coordinate_system
355  ///
356  /// @param[in] coordinate_system Coordinate system to create a Polygon for.
357  /// @return A pointer to a Polygon that caller must free when it is done
358  /// with it.
360 
361  // Returns a copy of a subclass of Polygon.
362  Polygon *clone() const override = 0;
363 
364  /// Adds a linear ring to the polygon.
365  ///
366  /// The first ring will become the exterior ring. All following rings will be
367  /// interior rings (holes).
368  ///
369  /// @param lr The linear ring to add.
370  virtual void push_back(const Linearring &lr) = 0;
371  virtual void push_back(Linearring &&lr) = 0;
372 
373  /// Checks if the polygon is empty.
374  ///
375  /// The polygon is considered empty if it has no rings.
376  ///
377  /// @retval true The polygon is empty.
378  /// @retval false The polygon is not empty.
379  virtual bool empty() const = 0;
380 
381  /// Returns the size of the polygon.
382  ///
383  /// @return Number of rings in the polygon (exterior + interior).
384  virtual std::size_t size() const = 0;
385 
386  /// Returns the exterior ring of the polygon.
387  ///
388  /// @note If the polygon currently has no exterior ring, an empty one is
389  /// added.
390  ///
391  /// @return The exterior ring.
392  virtual Linearring &exterior_ring() = 0;
393 
394  /// Returns an interior ring of the polygon.
395  ///
396  /// @param n Ring number, zero indexed.
397  ///
398  /// @return The interior ring.
399  virtual Linearring &interior_ring(std::size_t n) = 0;
400 };
401 
402 /// A collection of geometries.
403 ///
404 /// Geometrycollection is an instantiable type in SQL. It is the only
405 /// instantiable non-leaf geometry type.
406 ///
407 /// The Geometrycollection class places no restrictions on type, overlapping,
408 /// etc. Subclasses do.
409 class Geometrycollection : public Geometry {
410  public:
411  Geometry_type type() const override {
413  }
414  bool accept(Geometry_visitor *v) override = 0;
415 
416  /// Creates a subclass of Geometrycollection from a Coordinate_system
417  ///
418  /// @param[in] coordinate_system Coordinate system to create a
419  /// Geometrycollection for.
420  /// @return A pointer to a Geometrycollection that caller must free when it is
421  /// done with it.
424 
425  /// Adds a geometry to the collection.
426  ///
427  /// @param g The geometry to add.
428  virtual void push_back(const Geometry &g) = 0;
429  virtual void push_back(Geometry &&g) = 0;
430 
431  /// Removes a geometry from the front of the collection.
432  virtual void pop_front() = 0;
433 
434  /// Checks if the collection is empty.
435  ///
436  /// @retval true The polygon is empty.
437  /// @retval false The polygon is not empty.
438  virtual bool empty() const = 0;
439 
440  /// Returns the size of the geometrycollection.
441  ///
442  /// @return Number of geometries in the geometrycollection.
443  virtual std::size_t size() const = 0;
444 
445  /// Resizes the geometrycollection to contain a given number of elements.
446  ///
447  /// If the new size is smaller than the current size, the remaining geometries
448  /// are discarded.
449  ///
450  /// @param[in] count The new number of geometries.
451  virtual void resize(std::size_t count) = 0;
452 
453  /// Removes all geometries from the geometrycollection.
454  virtual void clear() noexcept = 0;
455 
456  /// Returns the first geometry of the collection.
457  ///
458  /// @return First geometry of the collection
459  virtual Geometry &front() = 0;
460  virtual const Geometry &front() const = 0;
461 
462  virtual Geometry &operator[](std::size_t i) = 0;
463  virtual const Geometry &operator[](std::size_t i) const = 0;
464  /// Clone pattern to easily duplicate a Geometrycollection.
465  ///
466  /// @return A pointer to a copy of the Geometrycollection that caller
467  /// must free when it is done with it.
468  Geometrycollection *clone() const override = 0;
469 
470  /// Creates a subclass from a Coordinate_system
471  ///
472  /// @param[in] coordinate_system Coordinate system to create a
473  /// geometrycollection for
474  /// @return A pointer to a Geometrycollection that caller must free when it is
475  /// done with it.
478 };
479 
480 /// A collection of points.
481 ///
482 /// Multipoint is an instantiable type in SQL.
484  public:
485  Geometry_type type() const override { return Geometry_type::kMultipoint; }
486 
487  bool accept(Geometry_visitor *v) override = 0;
488 
489  /// Clone pattern to easily duplicate a Multipoint.
490  ///
491  /// @return A pointer to a copy of the Multipoint that caller
492  /// must free when it is done with it.
493  Multipoint *clone() const override = 0;
494 
495  /// Returns the first point of the Multipoint.
496  ///
497  /// @return First point of the Multipoint
498  Point &front() override = 0;
499  const Point &front() const override = 0;
500 
501  /// Creates a subclass of Multipoint from a Coordinate_system
502  ///
503  /// @param[in] coordinate_system Coordinate system to create a Multipoint for.
504  /// @return A pointer to a Multipoint that caller must free when it is done
505  /// with it.
506 
508 };
509 
510 /// An abstract collection of curves.
511 ///
512 /// Multicurve is a non-instantiable type in SQL.
514  public:
515  Geometry_type type() const override = 0;
516  bool accept(Geometry_visitor *v) override = 0;
517 };
518 
519 /// A colletion of linestrings.
520 ///
521 /// Multilinestring is an instantiable type in SQL.
522 class Multilinestring : public Multicurve {
523  public:
524  Geometry_type type() const override {
526  }
527  bool accept(Geometry_visitor *v) override = 0;
528 
529  /// Clone pattern to easily duplicate a Multilinestring.
530  ///
531  /// @return A pointer to a copy of the Multilinestring that caller
532  /// must free when it is done with it.
533  Multilinestring *clone() const override = 0;
534 
535  /// Returns the first linestring of the Multilinestring.
536  ///
537  /// @return First linestring of the Multilinestring
538  Linestring &front() override = 0;
539  const Linestring &front() const override = 0;
540 
541  /// Creates a subclass of Multilinestring from a Coordinate_system
542  ///
543  /// @param[in] coordinate_system Coordinate system to create a Multilinestring
544  /// for.
545  /// @return A pointer to a Multilinestring that caller must free when it is
546  /// done with it.
549 };
550 
551 /// An abstract collection of surfaces.
552 ///
553 /// Multisurface is a non-instantiable type in SQL.
555  public:
556  Geometry_type type() const override = 0;
557  bool accept(Geometry_visitor *v) override = 0;
558 };
559 
560 /// A collection of polygons.
561 ///
562 /// Multipolygon is an instantiable type in SQL.
563 class Multipolygon : public Multisurface {
564  public:
565  Geometry_type type() const override { return Geometry_type::kMultipolygon; }
566  bool accept(Geometry_visitor *v) override = 0;
567 
568  /// Clone pattern to easily duplicate a Multipolygon.
569  ///
570  /// @return A pointer to a copy of the Multipolygon that caller
571  /// must free when it is done with it.
572  Multipolygon *clone() const override = 0;
573 
574  /// Returns the first polygon of the Multipolygon.
575  ///
576  /// @return First polygon of the Multipolygon
577  Polygon &front() override = 0;
578  const Polygon &front() const override = 0;
579 
580  /// Creates a subclass of Multipolygon from a Coordinate_system
581  ///
582  /// @param[in] coordinate_system Coordinate system to create a Multipolygon
583  /// for.
584  /// @return A pointer to a Multipolygon that caller must free when it is done
585  /// with it.
587 };
588 
589 /// Get the type name string corresponding to a geometry type.
590 ///
591 /// @param type The geometry type.
592 ///
593 /// @return A string containing the type name (in uppercase).
594 const char *type_to_name(Geometry_type type);
595 
596 } // namespace gis
597 
598 #endif // SQL_GIS_GEOMETRIES_H_INCLUDED
An abstract 2d curve.
Definition: geometries.h:241
bool accept(Geometry_visitor *v) override=0
Applies a hierarchical visitor to this geometry.
Geometry_type type() const override=0
Gets the geometry type of the object.
Abstract visitor class to be used on class Geometry and descendants.
Definition: geometry_visitor.h:45
Abstract superclass for all geometric objects.
Definition: geometries.h:99
virtual Coordinate_system coordinate_system() const =0
Gets the coordinate system.
virtual bool is_empty() const =0
Check if this is an empty geometry.
virtual bool accept(Geometry_visitor *v)=0
Applies a hierarchical visitor to this geometry.
virtual ~Geometry()=default
Geometry()=default
virtual Geometry_type type() const =0
Gets the geometry type of the object.
virtual Geometry * clone() const =0
Geometry & operator=(const Geometry &)=default
Geometry(const Geometry &)=default
A collection of geometries.
Definition: geometries.h:409
virtual void pop_front()=0
Removes a geometry from the front of the collection.
virtual void push_back(const Geometry &g)=0
Adds a geometry to the collection.
Geometry_type type() const override
Gets the geometry type of the object.
Definition: geometries.h:411
bool accept(Geometry_visitor *v) override=0
Applies a hierarchical visitor to this geometry.
static Geometrycollection * CreateGeometrycollection(Coordinate_system coordinate_system)
Creates a subclass of Geometrycollection from a Coordinate_system.
virtual bool empty() const =0
Checks if the collection is empty.
virtual void clear() noexcept=0
Removes all geometries from the geometrycollection.
virtual void resize(std::size_t count)=0
Resizes the geometrycollection to contain a given number of elements.
virtual std::size_t size() const =0
Returns the size of the geometrycollection.
virtual void push_back(Geometry &&g)=0
A ring-shaped linestring.
Definition: geometries.h:319
bool accept(Geometry_visitor *v) override=0
Applies a hierarchical visitor to this geometry.
A string of connected line segments.
Definition: geometries.h:255
virtual void push_back(const Point &pt)=0
Adds a point to the end of the linestring.
virtual void clear() noexcept=0
Removes all points from the linestring.
bool accept(Geometry_visitor *v) override=0
Applies a hierarchical visitor to this geometry.
bool is_empty() const override
Check if this is an empty geometry.
Definition: geometries.h:259
Linestring * clone() const override=0
virtual void push_back(Point &&pt)=0
virtual Point & back()=0
Returns the last point of the linestring.
virtual std::size_t size() const =0
Returns the size of (number of points in) the linestring.
virtual Point & front()=0
Returns the first point of the linestring.
virtual void pop_front()=0
Removes a point from the front of the linestring.
virtual bool empty() const =0
Checks if the linestring is empty.
static Linestring * create_linestring(Coordinate_system coordinate_system)
Creates a subclass of Linestring from a Coordinate_system.
Definition: geometries.cc:73
Geometry_type type() const override
Gets the geometry type of the object.
Definition: geometries.h:257
An abstract collection of curves.
Definition: geometries.h:513
Geometry_type type() const override=0
Gets the geometry type of the object.
bool accept(Geometry_visitor *v) override=0
Applies a hierarchical visitor to this geometry.
A colletion of linestrings.
Definition: geometries.h:522
const Linestring & front() const override=0
Multilinestring * clone() const override=0
Clone pattern to easily duplicate a Multilinestring.
bool accept(Geometry_visitor *v) override=0
Applies a hierarchical visitor to this geometry.
Geometry_type type() const override
Gets the geometry type of the object.
Definition: geometries.h:524
Linestring & front() override=0
Returns the first linestring of the Multilinestring.
A collection of points.
Definition: geometries.h:483
Point & front() override=0
Returns the first point of the Multipoint.
Geometry_type type() const override
Gets the geometry type of the object.
Definition: geometries.h:485
const Point & front() const override=0
bool accept(Geometry_visitor *v) override=0
Applies a hierarchical visitor to this geometry.
Multipoint * clone() const override=0
Clone pattern to easily duplicate a Multipoint.
A collection of polygons.
Definition: geometries.h:563
Multipolygon * clone() const override=0
Clone pattern to easily duplicate a Multipolygon.
Geometry_type type() const override
Gets the geometry type of the object.
Definition: geometries.h:565
const Polygon & front() const override=0
Polygon & front() override=0
Returns the first polygon of the Multipolygon.
bool accept(Geometry_visitor *v) override=0
Applies a hierarchical visitor to this geometry.
An abstract collection of surfaces.
Definition: geometries.h:554
bool accept(Geometry_visitor *v) override=0
Applies a hierarchical visitor to this geometry.
Geometry_type type() const override=0
Gets the geometry type of the object.
A 2d point.
Definition: geometries.h:149
void set(double d)
Sets a coordinate.
bool is_empty() const override
Check if this is an empty geometry.
Definition: geometries.h:155
double get() const
Gets a coordinate value.
double x() const
Gets the first coordinate value.
Definition: geometries.cc:45
Point(double x, double y)
Definition: geometries.h:152
bool accept(Geometry_visitor *v) override
Applies a hierarchical visitor to this geometry.
Definition: geometries.cc:33
Geometry_type type() const override
Gets the geometry type of the object.
Definition: geometries.h:153
double m_x
First coordinate (X or longitude).
Definition: geometries.h:214
double m_y
Second coordinate (Y or latitude).
Definition: geometries.h:220
Point * clone() const override=0
Point()
Definition: geometries.h:151
double y() const
Gets the second coordinate value.
Definition: geometries.cc:47
A polygon consisting of an outer ring and zero or more interior rings defining holes in the polygon.
Definition: geometries.h:348
bool is_empty() const override
Check if this is an empty geometry.
Definition: geometries.h:352
virtual Linearring & exterior_ring()=0
Returns the exterior ring of the polygon.
virtual bool empty() const =0
Checks if the polygon is empty.
virtual Linearring & interior_ring(std::size_t n)=0
Returns an interior ring of the polygon.
virtual void push_back(Linearring &&lr)=0
virtual std::size_t size() const =0
Returns the size of the polygon.
Geometry_type type() const override
Gets the geometry type of the object.
Definition: geometries.h:350
Polygon * clone() const override=0
bool accept(Geometry_visitor *v) override=0
Applies a hierarchical visitor to this geometry.
virtual void push_back(const Linearring &lr)=0
Adds a linear ring to the polygon.
An abstract 2d surface.
Definition: geometries.h:334
bool accept(Geometry_visitor *v) override=0
Applies a hierarchical visitor to this geometry.
Geometry_type type() const override=0
Gets the geometry type of the object.
static int count
Definition: myisam_ftdump.cc:42
Definition: area.cc:46
Coordinate_system
Types of coordinate systems.
Definition: geometries.h:68
@ kCartesian
A Cartesian plane with the same unit in both directions.
@ kGeographic
An ellipsoidal system with longitude and latitude coordinates, both in the same unit.
const char * type_to_name(Geometry_type type)
Get the type name string corresponding to a geometry type.
Definition: geometries.cc:687
Geometry_type
Types of geometry objects.
Definition: geometries.h:52
bool operator<(const Point &lhs, const Point &rhs)
Compares two points.
Definition: geometries.h:234
Ring_direction
Direction of a ring.
Definition: geometries.h:77
@ kCCW
Counterclockwise.
Definition: varlen_sort.h:183
static Geometry * create_multilinestring(char *buffer)
Definition: spatial.cc:265
static Geometry * create_multipolygon(char *buffer)
Definition: spatial.cc:261
static Geometry * create_polygon(char *buffer)
Definition: spatial.cc:253
static Geometry * create_multipoint(char *buffer)
Definition: spatial.cc:257
static Geometry * create_geometrycollection(char *buffer)
Definition: spatial.cc:269
int n
Definition: xcom_base.cc:505