MySQL 8.0.39
Source Code Documentation
spatial_reference_system.h
Go to the documentation of this file.
1/* Copyright (c) 2016, 2024, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is designed to work with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have either included with
13 the program or referenced in the documentation.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef DD__SPATIAL_REFERENCE_SYSTEM_INCLUDED
25#define DD__SPATIAL_REFERENCE_SYSTEM_INCLUDED
26
27#include <cstddef> // std::nullptr_t
28#include <optional>
29
30#include "my_inttypes.h"
31#include "sql/dd/impl/raw/object_keys.h" // IWYU pragma: keep
32#include "sql/dd/types/entity_object.h" // dd::Entity_object
33#include "sql/gis/geometries.h" // gis::Coordinate_system
34#include "sql/gis/srid.h" // gis::srid_t
35
36class THD;
37
38namespace dd {
39
40///////////////////////////////////////////////////////////////////////////
41
42class Item_name_key;
43class Primary_id_key;
44class Spatial_reference_system_impl;
45class Void_key;
46
47namespace tables {
48class Spatial_reference_systems;
49}
50
51///////////////////////////////////////////////////////////////////////////
52
54 public:
61
62 // We need a set of functions to update a preallocated key.
63 virtual bool update_id_key(Id_key *key) const {
64 return update_id_key(key, id());
65 }
66
67 static bool update_id_key(Id_key *key, Object_id id);
68
69 virtual bool update_name_key(Name_key *key) const {
70 return update_name_key(key, name());
71 }
72
73 static bool update_name_key(Name_key *key, const String_type &name);
74
75 virtual bool update_aux_key(Aux_key *) const { return true; }
76
77 public:
78 ~Spatial_reference_system() override = default;
79
80 /////////////////////////////////////////////////////////////////////////
81 // created
82 /////////////////////////////////////////////////////////////////////////
83
84 virtual ulonglong created(bool convert_time) const = 0;
85 virtual void set_created(ulonglong created) = 0;
86
87 /////////////////////////////////////////////////////////////////////////
88 // last_altered
89 /////////////////////////////////////////////////////////////////////////
90
91 virtual ulonglong last_altered(bool convert_time) const = 0;
93
94 /////////////////////////////////////////////////////////////////////////
95 // organization
96 /////////////////////////////////////////////////////////////////////////
97
98 virtual const std::optional<String_type> &organization() const = 0;
99 virtual void set_organization(const String_type &organization) = 0;
100 virtual void set_organization(std::nullptr_t) = 0;
101
102 /////////////////////////////////////////////////////////////////////////
103 // organization_coordsys_id
104 /////////////////////////////////////////////////////////////////////////
105
106 virtual const std::optional<gis::srid_t> &organization_coordsys_id()
107 const = 0;
110 virtual void set_organization_coordsys_id(std::nullptr_t) = 0;
111
112 /////////////////////////////////////////////////////////////////////////
113 // definition
114 /////////////////////////////////////////////////////////////////////////
115
116 virtual const String_type &definition() const = 0;
117 virtual void set_definition(const String_type &definition) = 0;
118 virtual gis::Coordinate_system cs_type() const = 0;
119 virtual bool is_projected() const = 0;
120 virtual bool is_cartesian() const = 0;
121 virtual bool is_geographic() const = 0;
122
123 /**
124 Check whether an SRS has latitude-longitude axis ordering.
125
126 @retval true the axis order is latitude-longitude
127 @retval false the SRS is not geographic, or is geographic longitude-latitude
128 */
129 virtual bool is_lat_long() const = 0;
130
131 virtual double semi_major_axis() const = 0;
132 virtual double semi_minor_axis() const = 0;
133 virtual double linear_unit() const = 0;
134 virtual double angular_unit() const = 0;
135 virtual double prime_meridian() const = 0;
136 virtual bool positive_east() const = 0;
137 virtual bool positive_north() const = 0;
138
139 /// Checks whether the SRS definition is missing a TOWGS84 clause.
140 ///
141 /// TOWGS84 clauses are not mandatory. However, in order to transform to/from
142 /// an SRS, the SRS must either be WGS 84, be a projection of WGS 84, or have
143 /// a TOWGS84 clause in the definition.
144 ///
145 /// @retval true The SRS is missing a TOWGS84 clause.
146 /// @retval false The SRS has or doesn't need a TOWGS84 clause.
147 virtual bool missing_towgs84() const = 0;
148
149 /// Converts a coordinate value from the SRS unit to radians.
150 ///
151 /// The conversion does not take axis direction or meridian shifting into
152 /// account.
153 ///
154 /// @param[in] d Value in the SRS unit.
155 ///
156 /// @return Value in radians.
157 virtual double to_radians(double d) const = 0;
158
159 /// Converts a coordinate value from radians to the SRS unit.
160 ///
161 /// The conversion does not take axis direction or meridian shifting into
162 /// account.
163 ///
164 /// @param[in] d Value in radians.
165 ///
166 /// @return Value in the SRS unit.
167 virtual double from_radians(double d) const = 0;
168
169 /// Converts a latitude value from the SRS unit and direction to the in-memory
170 /// representation of latitude (radians, positive North).
171 ///
172 /// @param[in] d Latitude in the SRS unit and axis direction.
173 ///
174 /// @return Latitude in radians, positive North.
175 virtual double to_normalized_latitude(double d) const = 0;
176
177 /// Converts a latitude value from the in-memory representation of latitude
178 /// (radians, positive North) to the SRS unit and direction.
179 ///
180 /// @param[in] d Latitude in radians, positive North.
181 ///
182 /// @return Latitude in the SRS unit and axis direction.
183 virtual double from_normalized_latitude(double d) const = 0;
184
185 /// Converts a longitude value from the SRS unit, direction and meridian to
186 /// the in-memory representation of longitude (radians, positive East,
187 /// Greenwich meridian).
188 ///
189 /// @param[in] d Longitude in the SRS unit, axis direction and meridian.
190 ///
191 /// @return Longitude in radians, positive East, Greenwich meridian.
192 virtual double to_normalized_longitude(double d) const = 0;
193
194 /// Converts a longitude value from the in-memory representation of longitude
195 /// (radians, positive East, Greenwich meridian) to the SRS unit, direction
196 /// and meridian.
197 ///
198 /// @param[in] d Longitude in radians, positive East, Greenwich meridian.
199 ///
200 /// @return Longitude in the SRS unit, axis direction and meridian.
201 virtual double from_normalized_longitude(double d) const = 0;
202
203 /// Checks if this SRS can be changed to another SRS definition without
204 /// changing any computations.
205 ///
206 /// It's not allowed to change any numbers that affect computations, but it is
207 /// allowed to add TOWGS84 parameters if the SRS doesn't already have any.
208 ///
209 /// @param[in] srs The SRS to compare with.
210 ///
211 /// @retval true The two SRSs are semantically the same.
212 /// @retval false The two SRss are not semantically the same, or of types
213 /// which comparison rules are unknown (e.g., unknown projection).
214 virtual bool can_be_modified_to(
215 const Spatial_reference_system &srs) const = 0;
216
217 /// Gets the proj4 parameters for this SRS.
218 ///
219 /// An empty string is returned in case we don't know how to create proj4
220 /// parameters for this SRS.
221 ///
222 /// @return The proj4 parameter string, or an empty string.
223 virtual String_type proj4_parameters() const = 0;
224
225 /////////////////////////////////////////////////////////////////////////
226 // description
227 /////////////////////////////////////////////////////////////////////////
228
229 virtual const std::optional<String_type> &description() const = 0;
230 virtual void set_description(const String_type &description) = 0;
231 virtual void set_description(std::nullptr_t) = 0;
232
233 /**
234 Allocate a new object and invoke the copy constructor
235
236 @return pointer to dynamically allocated copy
237 */
238 virtual Spatial_reference_system *clone() const = 0;
239
240 /**
241 Allocate a new object which can serve as a placeholder for the original
242 object in the Dictionary_client's dropped registry. Such object has the
243 same keys as the original but has no other info and as result occupies
244 less memory.
245 */
247 const = 0;
248};
249
250///////////////////////////////////////////////////////////////////////////
251
252} // namespace dd
253
254#endif // DD__SPATIAL_REFERENCE_SYSTEM_INCLUDE
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:34
Base class for dictionary objects which has single column integer primary key.
Definition: entity_object.h:48
virtual const String_type & name() const =0
Definition: object_keys.h:166
Definition: object_keys.h:77
Definition: spatial_reference_system_impl.h:63
Definition: spatial_reference_system.h:53
virtual double to_radians(double d) const =0
Converts a coordinate value from the SRS unit to radians.
virtual double from_normalized_longitude(double d) const =0
Converts a longitude value from the in-memory representation of longitude (radians,...
Primary_id_key Id_key
Definition: spatial_reference_system.h:58
virtual bool is_geographic() const =0
virtual double angular_unit() const =0
virtual const String_type & definition() const =0
virtual bool is_lat_long() const =0
Check whether an SRS has latitude-longitude axis ordering.
Void_key Aux_key
Definition: spatial_reference_system.h:60
virtual bool is_projected() const =0
virtual const std::optional< String_type > & description() const =0
virtual Spatial_reference_system * clone_dropped_object_placeholder() const =0
Allocate a new object which can serve as a placeholder for the original object in the Dictionary_clie...
virtual bool update_name_key(Name_key *key) const
Definition: spatial_reference_system.h:69
virtual bool update_id_key(Id_key *key) const
Definition: spatial_reference_system.h:63
virtual void set_organization(const String_type &organization)=0
virtual void set_description(const String_type &description)=0
virtual void set_created(ulonglong created)=0
Spatial_reference_system_impl Impl
Definition: spatial_reference_system.h:55
virtual void set_organization_coordsys_id(std::nullptr_t)=0
~Spatial_reference_system() override=default
virtual void set_description(std::nullptr_t)=0
virtual bool positive_north() const =0
virtual double from_radians(double d) const =0
Converts a coordinate value from radians to the SRS unit.
virtual bool is_cartesian() const =0
virtual bool can_be_modified_to(const Spatial_reference_system &srs) const =0
Checks if this SRS can be changed to another SRS definition without changing any computations.
virtual bool positive_east() const =0
virtual String_type proj4_parameters() const =0
Gets the proj4 parameters for this SRS.
Spatial_reference_system Cache_partition
Definition: spatial_reference_system.h:56
virtual double from_normalized_latitude(double d) const =0
Converts a latitude value from the in-memory representation of latitude (radians, positive North) to ...
virtual double prime_meridian() const =0
virtual Spatial_reference_system * clone() const =0
Allocate a new object and invoke the copy constructor.
virtual double to_normalized_latitude(double d) const =0
Converts a latitude value from the SRS unit and direction to the in-memory representation of latitude...
virtual void set_last_altered(ulonglong last_altered)=0
virtual ulonglong last_altered(bool convert_time) const =0
virtual bool update_aux_key(Aux_key *) const
Definition: spatial_reference_system.h:75
virtual double semi_minor_axis() const =0
virtual ulonglong created(bool convert_time) const =0
virtual const std::optional< gis::srid_t > & organization_coordsys_id() const =0
virtual double to_normalized_longitude(double d) const =0
Converts a longitude value from the SRS unit, direction and meridian to the in-memory representation ...
virtual gis::Coordinate_system cs_type() const =0
virtual const std::optional< String_type > & organization() const =0
virtual void set_organization(std::nullptr_t)=0
virtual void set_definition(const String_type &definition)=0
virtual double linear_unit() const =0
virtual double semi_major_axis() const =0
virtual bool missing_towgs84() const =0
Checks whether the SRS definition is missing a TOWGS84 clause.
Item_name_key Name_key
Definition: spatial_reference_system.h:59
tables::Spatial_reference_systems DD_table
Definition: spatial_reference_system.h:57
virtual void set_organization_coordsys_id(gis::srid_t organization_coordsys_id)=0
Definition: object_keys.h:54
Definition: spatial_reference_systems.h:44
This file declares the geometry class hierarchy used by the server as the internal representation of ...
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:56
The version of the current data dictionary table definitions.
Definition: dictionary_client.h:43
unsigned long long Object_id
Definition: object_id.h:31
Char_string_template< String_type_allocator > String_type
Definition: string_type.h:51
Coordinate_system
Types of coordinate systems.
Definition: geometries.h:69
std::uint32_t srid_t
A spatial reference system ID (SRID).
Definition: srid.h:33
required string key
Definition: replication_asynchronous_connection_failover.proto:60