MySQL  8.0.26
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 #if defined(__SUNPRO_CC)
322  ~Linearring() override = default;
323 #endif
324  bool accept(Geometry_visitor *v) override = 0;
325 
326  /// Creates a subclass of Linearring from a Coordinate_system
327  ///
328  /// @param[in] coordinate_system Coordinate system to create a Linearring for.
329  /// @return A pointer to a Linearring that caller must free when it is done
330  /// with it.
331  static Linearring *create_linearring(Coordinate_system coordinate_system);
332 };
333 
334 /// An abstract 2d surface.
335 ///
336 /// Surface is a non-instantiable type in SQL.
337 class Surface : public Geometry {
338  public:
339  bool accept(Geometry_visitor *v) override = 0;
340 
341  Geometry_type type() const override = 0;
342 };
343 
344 /// A polygon consisting of an outer ring and zero or more interior rings
345 /// defining holes in the polygon.
346 ///
347 /// Polygon is an instantiable type in SQL.
348 ///
349 /// The interior rings must be inside the exterior ring (not enforced by the
350 /// implementation).
351 class Polygon : public Surface {
352  public:
353  Geometry_type type() const override { return Geometry_type::kPolygon; }
354  bool accept(Geometry_visitor *v) override = 0;
355  bool is_empty() const override { return empty(); }
356 
357  /// Creates a subclass of Polygon from a Coordinate_system
358  ///
359  /// @param[in] coordinate_system Coordinate system to create a Polygon for.
360  /// @return A pointer to a Polygon that caller must free when it is done
361  /// with it.
363 
364  // Returns a copy of a subclass of Polygon.
365  Polygon *clone() const override = 0;
366 
367  /// Adds a linear ring to the polygon.
368  ///
369  /// The first ring will become the exterior ring. All following rings will be
370  /// interior rings (holes).
371  ///
372  /// @param lr The linear ring to add.
373  virtual void push_back(const Linearring &lr) = 0;
374  virtual void push_back(Linearring &&lr) = 0;
375 
376  /// Checks if the polygon is empty.
377  ///
378  /// The polygon is considered empty if it has no rings.
379  ///
380  /// @retval true The polygon is empty.
381  /// @retval false The polygon is not empty.
382  virtual bool empty() const = 0;
383 
384  /// Returns the size of the polygon.
385  ///
386  /// @return Number of rings in the polygon (exterior + interior).
387  virtual std::size_t size() const = 0;
388 
389  /// Returns the exterior ring of the polygon.
390  ///
391  /// @note If the polygon currently has no exterior ring, an empty one is
392  /// added.
393  ///
394  /// @return The exterior ring.
395  virtual Linearring &exterior_ring() = 0;
396 
397  /// Returns an interior ring of the polygon.
398  ///
399  /// @param n Ring number, zero indexed.
400  ///
401  /// @return The interior ring.
402  virtual Linearring &interior_ring(std::size_t n) = 0;
403 };
404 
405 /// A collection of geometries.
406 ///
407 /// Geometrycollection is an instantiable type in SQL. It is the only
408 /// instantiable non-leaf geometry type.
409 ///
410 /// The Geometrycollection class places no restrictions on type, overlapping,
411 /// etc. Subclasses do.
412 class Geometrycollection : public Geometry {
413  public:
414  Geometry_type type() const override {
416  }
417  bool accept(Geometry_visitor *v) override = 0;
418 
419  /// Creates a subclass of Geometrycollection from a Coordinate_system
420  ///
421  /// @param[in] coordinate_system Coordinate system to create a
422  /// Geometrycollection for.
423  /// @return A pointer to a Geometrycollection that caller must free when it is
424  /// done with it.
427 
428  /// Adds a geometry to the collection.
429  ///
430  /// @param g The geometry to add.
431  virtual void push_back(const Geometry &g) = 0;
432  virtual void push_back(Geometry &&g) = 0;
433 
434  /// Removes a geometry from the front of the collection.
435  virtual void pop_front() = 0;
436 
437  /// Checks if the collection is empty.
438  ///
439  /// @retval true The polygon is empty.
440  /// @retval false The polygon is not empty.
441  virtual bool empty() const = 0;
442 
443  /// Returns the size of the geometrycollection.
444  ///
445  /// @return Number of geometries in the geometrycollection.
446  virtual std::size_t size() const = 0;
447 
448  /// Resizes the geometrycollection to contain a given number of elements.
449  ///
450  /// If the new size is smaller than the current size, the remaining geometries
451  /// are discarded.
452  ///
453  /// @param[in] count The new number of geometries.
454  virtual void resize(std::size_t count) = 0;
455 
456  /// Removes all geometries from the geometrycollection.
457  virtual void clear() noexcept = 0;
458 
459  /// Returns the first geometry of the collection.
460  ///
461  /// @return First geometry of the collection
462  virtual Geometry &front() = 0;
463  virtual const Geometry &front() const = 0;
464 
465  virtual Geometry &operator[](std::size_t i) = 0;
466  virtual const Geometry &operator[](std::size_t i) const = 0;
467  /// Clone pattern to easily duplicate a Geometrycollection.
468  ///
469  /// @return A pointer to a copy of the Geometrycollection that caller
470  /// must free when it is done with it.
471  Geometrycollection *clone() const override = 0;
472 
473  /// Creates a subclass from a Coordinate_system
474  ///
475  /// @param[in] coordinate_system Coordinate system to create a
476  /// geometrycollection for
477  /// @return A pointer to a Geometrycollection that caller must free when it is
478  /// done with it.
481 };
482 
483 /// A collection of points.
484 ///
485 /// Multipoint is an instantiable type in SQL.
487  public:
488  Geometry_type type() const override { return Geometry_type::kMultipoint; }
489 
490  bool accept(Geometry_visitor *v) override = 0;
491 
492  /// Clone pattern to easily duplicate a Multipoint.
493  ///
494  /// @return A pointer to a copy of the Multipoint that caller
495  /// must free when it is done with it.
496  Multipoint *clone() const override = 0;
497 
498  /// Returns the first point of the Multipoint.
499  ///
500  /// @return First point of the Multipoint
501  Point &front() override = 0;
502  const Point &front() const override = 0;
503 
504  /// Creates a subclass of Multipoint from a Coordinate_system
505  ///
506  /// @param[in] coordinate_system Coordinate system to create a Multipoint for.
507  /// @return A pointer to a Multipoint that caller must free when it is done
508  /// with it.
509 
511 };
512 
513 /// An abstract collection of curves.
514 ///
515 /// Multicurve is a non-instantiable type in SQL.
517  public:
518  Geometry_type type() const override = 0;
519  bool accept(Geometry_visitor *v) override = 0;
520 };
521 
522 /// A colletion of linestrings.
523 ///
524 /// Multilinestring is an instantiable type in SQL.
525 class Multilinestring : public Multicurve {
526  public:
527  Geometry_type type() const override {
529  }
530  bool accept(Geometry_visitor *v) override = 0;
531 
532  /// Clone pattern to easily duplicate a Multilinestring.
533  ///
534  /// @return A pointer to a copy of the Multilinestring that caller
535  /// must free when it is done with it.
536  Multilinestring *clone() const override = 0;
537 
538  /// Returns the first linestring of the Multilinestring.
539  ///
540  /// @return First linestring of the Multilinestring
541  Linestring &front() override = 0;
542  const Linestring &front() const override = 0;
543 
544  /// Creates a subclass of Multilinestring from a Coordinate_system
545  ///
546  /// @param[in] coordinate_system Coordinate system to create a Multilinestring
547  /// for.
548  /// @return A pointer to a Multilinestring that caller must free when it is
549  /// done with it.
552 };
553 
554 /// An abstract collection of surfaces.
555 ///
556 /// Multisurface is a non-instantiable type in SQL.
558  public:
559  Geometry_type type() const override = 0;
560  bool accept(Geometry_visitor *v) override = 0;
561 };
562 
563 /// A collection of polygons.
564 ///
565 /// Multipolygon is an instantiable type in SQL.
566 class Multipolygon : public Multisurface {
567  public:
568  Geometry_type type() const override { return Geometry_type::kMultipolygon; }
569  bool accept(Geometry_visitor *v) override = 0;
570 
571  /// Clone pattern to easily duplicate a Multipolygon.
572  ///
573  /// @return A pointer to a copy of the Multipolygon that caller
574  /// must free when it is done with it.
575  Multipolygon *clone() const override = 0;
576 
577  /// Returns the first polygon of the Multipolygon.
578  ///
579  /// @return First polygon of the Multipolygon
580  Polygon &front() override = 0;
581  const Polygon &front() const override = 0;
582 
583  /// Creates a subclass of Multipolygon from a Coordinate_system
584  ///
585  /// @param[in] coordinate_system Coordinate system to create a Multipolygon
586  /// for.
587  /// @return A pointer to a Multipolygon that caller must free when it is done
588  /// with it.
590 };
591 
592 /// Get the type name string corresponding to a geometry type.
593 ///
594 /// @param type The geometry type.
595 ///
596 /// @return A string containing the type name (in uppercase).
597 const char *type_to_name(Geometry_type type);
598 
599 } // namespace gis
600 
601 #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:412
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:414
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:516
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:525
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:527
Linestring & front() override=0
Returns the first linestring of the Multilinestring.
A collection of points.
Definition: geometries.h:486
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:488
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:566
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:568
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:557
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:351
bool is_empty() const override
Check if this is an empty geometry.
Definition: geometries.h:355
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:353
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:337
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:445