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