MySQL 9.1.0
Source Code Documentation
wkt_parser.h
Go to the documentation of this file.
1#ifndef SQL_GIS_SRS_WKT_PARSER_H_INCLUDED
2#define SQL_GIS_SRS_WKT_PARSER_H_INCLUDED
3
4// Copyright (c) 2016, 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 <string>
28#include <vector>
29
30#include <boost/variant/variant.hpp>
31
32#include "sql/gis/srid.h"
33#include "sql/gis/srs/srs.h"
34
35namespace gis {
36namespace srs {
37namespace wkt_parser {
38
39/// String type used in the parse tree
40typedef std::string String;
41
42struct Authority {
43 bool valid;
46
47 Authority() : valid(false) {}
48};
49
50struct Spheroid {
55
57};
58
59struct Towgs84 {
60 bool valid;
61 double dx;
62 double dy;
63 double dz;
64 double ex;
65 double ey;
66 double ez;
67 double ppm;
68
70 : valid(false),
71 dx(0.0),
72 dy(0.0),
73 dz(0.0),
74 ex(0.0),
75 ey(0.0),
76 ez(0.0),
77 ppm(0.0) {}
78};
79
80struct Datum {
85};
86
89 double longitude;
91
93};
94
95struct Unit {
99
101};
102
103struct Axis {
106
108};
109
110struct Twin_axes {
111 bool valid;
114
115 Twin_axes() : valid(false) {}
116};
117
125};
126
130};
131
134 double value;
136
138};
139
140typedef std::vector<Projection_parameter> Projection_parameters;
141
150};
151
152typedef boost::variant<Projected_cs, Geographic_cs> Coordinate_system;
153
154/**
155 Parse an SRS definition WKT string.
156
157 The parser understands WKT as defined by the <horz cs>
158 specification in OGC 01-009.
159
160 @param[in] srid Spatial reference system ID to use when reporting errors
161 @param[in] begin Start of WKT string in UTF-8
162 @param[in] end End of WKT string in UTF-8
163 @param[out] cs Coordinate system
164
165 @retval true An error has occurred
166 @retval false Success
167*/
168bool parse_wkt(srid_t srid, const char *begin, const char *end,
170
171} // namespace wkt_parser
172} // namespace srs
173} // namespace gis
174
175#endif // SQL_GIS_SRS_WKT_PARSER_H_INCLUDED
Definition: commit_order_queue.h:34
bool parse_wkt(srid_t srid, const char *begin, const char *end, Coordinate_system *cs)
Parse an SRS definition WKT string.
std::vector< Projection_parameter > Projection_parameters
Definition: wkt_parser.h:140
boost::variant< Projected_cs, Geographic_cs > Coordinate_system
Definition: wkt_parser.h:152
std::string String
String type used in the parse tree.
Definition: wkt_parser.h:40
Axis_direction
Coordinate axis direction.
Definition: srs.h:86
Definition: area.cc:47
std::uint32_t srid_t
A spatial reference system ID (SRID).
Definition: srid.h:33
const char * begin(const char *const c)
Definition: base64.h:44
Definition: wkt_parser.h:42
Authority()
Definition: wkt_parser.h:47
bool valid
Definition: wkt_parser.h:43
String code
Definition: wkt_parser.h:45
String name
Definition: wkt_parser.h:44
Definition: wkt_parser.h:103
Axis()
Definition: wkt_parser.h:107
Axis_direction direction
Definition: wkt_parser.h:105
String name
Definition: wkt_parser.h:104
Definition: wkt_parser.h:80
Towgs84 towgs84
Definition: wkt_parser.h:83
Spheroid spheroid
Definition: wkt_parser.h:82
Authority authority
Definition: wkt_parser.h:84
String name
Definition: wkt_parser.h:81
Definition: wkt_parser.h:118
Authority authority
Definition: wkt_parser.h:124
Datum datum
Definition: wkt_parser.h:120
String name
Definition: wkt_parser.h:119
Prime_meridian prime_meridian
Definition: wkt_parser.h:121
Twin_axes axes
Definition: wkt_parser.h:123
Unit angular_unit
Definition: wkt_parser.h:122
Definition: wkt_parser.h:87
double longitude
Definition: wkt_parser.h:89
Prime_meridian()
Definition: wkt_parser.h:92
String name
Definition: wkt_parser.h:88
Authority authority
Definition: wkt_parser.h:90
Definition: wkt_parser.h:142
Projection projection
Definition: wkt_parser.h:145
Projection_parameters parameters
Definition: wkt_parser.h:146
Geographic_cs geographic_cs
Definition: wkt_parser.h:144
String name
Definition: wkt_parser.h:143
Twin_axes axes
Definition: wkt_parser.h:148
Authority authority
Definition: wkt_parser.h:149
Unit linear_unit
Definition: wkt_parser.h:147
Definition: wkt_parser.h:132
Projection_parameter()
Definition: wkt_parser.h:137
double value
Definition: wkt_parser.h:134
String name
Definition: wkt_parser.h:133
Authority authority
Definition: wkt_parser.h:135
Definition: wkt_parser.h:127
Authority authority
Definition: wkt_parser.h:129
String name
Definition: wkt_parser.h:128
Definition: wkt_parser.h:50
String name
Definition: wkt_parser.h:51
double inverse_flattening
Definition: wkt_parser.h:53
Authority authority
Definition: wkt_parser.h:54
Spheroid()
Definition: wkt_parser.h:56
double semi_major_axis
Definition: wkt_parser.h:52
Definition: wkt_parser.h:59
double dy
Definition: wkt_parser.h:62
double ppm
Definition: wkt_parser.h:67
double ez
Definition: wkt_parser.h:66
double ey
Definition: wkt_parser.h:65
double dz
Definition: wkt_parser.h:63
Towgs84()
Definition: wkt_parser.h:69
bool valid
Definition: wkt_parser.h:60
double ex
Definition: wkt_parser.h:64
double dx
Definition: wkt_parser.h:61
Definition: wkt_parser.h:110
Axis x
Definition: wkt_parser.h:112
bool valid
Definition: wkt_parser.h:111
Axis y
Definition: wkt_parser.h:113
Twin_axes()
Definition: wkt_parser.h:115
Definition: wkt_parser.h:95
Unit()
Definition: wkt_parser.h:100
double conversion_factor
Definition: wkt_parser.h:97
Authority authority
Definition: wkt_parser.h:98
String name
Definition: wkt_parser.h:96