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