MySQL  8.0.26
Source Code Documentation
wkb_visitor.h
Go to the documentation of this file.
1 #ifndef SQL_GIS_WKB_VISITOR_H_INCLUDED
2 #define SQL_GIS_WKB_VISITOR_H_INCLUDED
3 
4 // Copyright (c) 2018, 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 #include "sql/dd/types/spatial_reference_system.h" // dd::Spatial_reference_system
28 
29 namespace gis {
30 
31 /// A visitor that serializes the geometry to little-endian WKB and appends it
32 /// to a string.
33 class Wkb_visitor : public Nop_visitor {
34  private:
35  /// Spatial reference system of the geometry.
37  /// The WKB string.
38  const char *m_wkb;
39  /// Size of the buffer allocated for the WKB string.
40  const size_t m_wkb_size;
41  /// The position of the next character to be added to the string.
43 
44  public:
45  /// Construct a new WKB visitor.
46  ///
47  /// @param[in] srs The spatial reference system of the geometry.
48  /// @param[in] wkb The string to write the WKB to.
49  /// @param[in] wkb_size The length of the WKB string buffer.
51  size_t wkb_size)
52  : m_srs(srs),
53  m_wkb(wkb),
54  m_wkb_size(wkb_size),
56 
58  bool visit_enter(Geometry *) override {
59  /* purecov: begin deadcode */
60  assert(false);
61  return true;
62  /* purecov: end */
63  }
64  bool visit_enter(Linestring *ls) override;
65  bool visit_enter(Polygon *py) override;
66  bool visit_enter(Geometrycollection *gc) override;
67 
68  using Nop_visitor::visit;
69  bool visit(Point *pt) override;
70 };
71 
72 } // namespace gis
73 
74 #endif // SQL_GIS_WKB_VISITOR_H_INCLUDED
Definition: spatial_reference_system.h:52
Abstract superclass for all geometric objects.
Definition: geometries.h:99
A collection of geometries.
Definition: geometries.h:412
A string of connected line segments.
Definition: geometries.h:255
A visitor that implements the entire interface and does nothing.
Definition: geometry_visitor.h:121
bool visit_enter(Geometry *) override
Enters a compound geometry.
Definition: geometry_visitor.h:123
bool visit(Geometry *) override
Visits a geometry.
Definition: geometry_visitor.h:158
A 2d point.
Definition: geometries.h:149
A polygon consisting of an outer ring and zero or more interior rings defining holes in the polygon.
Definition: geometries.h:351
A visitor that serializes the geometry to little-endian WKB and appends it to a string.
Definition: wkb_visitor.h:33
const dd::Spatial_reference_system * m_srs
Spatial reference system of the geometry.
Definition: wkb_visitor.h:36
char * m_wkb_current_position
The position of the next character to be added to the string.
Definition: wkb_visitor.h:42
bool visit_enter(Geometry *) override
Definition: geometry_visitor.h:123
bool visit(Geometry *) override
Definition: geometry_visitor.h:158
bool visit_enter(Geometry *) override
Enters a compound geometry.
Definition: wkb_visitor.h:58
Wkb_visitor(const dd::Spatial_reference_system *srs, char *wkb, size_t wkb_size)
Construct a new WKB visitor.
Definition: wkb_visitor.h:50
const char * m_wkb
The WKB string.
Definition: wkb_visitor.h:38
const size_t m_wkb_size
Size of the buffer allocated for the WKB string.
Definition: wkb_visitor.h:40
The geometries implement a hierarchical visitor pattern.
Definition: area.cc:46