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