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