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