MySQL  8.0.21
Source Code Documentation
spatial_reference_system.h
Go to the documentation of this file.
1 /* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
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 
28 #include "my_inttypes.h"
29 #include "nullable.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 
35 class THD;
36 
37 namespace dd {
38 
39 ///////////////////////////////////////////////////////////////////////////
40 
41 class Item_name_key;
42 class Primary_id_key;
43 class Spatial_reference_system_impl;
44 class Void_key;
45 
46 namespace tables {
47 class Spatial_reference_systems;
48 }
49 
50 ///////////////////////////////////////////////////////////////////////////
51 
52 class Spatial_reference_system : virtual public Entity_object {
53  public:
59  typedef Void_key Aux_key;
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:
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;
91  virtual void set_last_altered(ulonglong last_altered) = 0;
92 
93  /////////////////////////////////////////////////////////////////////////
94  // organization
95  /////////////////////////////////////////////////////////////////////////
96 
97  virtual const Mysql::Nullable<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 Mysql::Nullable<gis::srid_t> &organization_coordsys_id()
106  const = 0;
107  virtual void set_organization_coordsys_id(
108  gis::srid_t organization_coordsys_id) = 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 Mysql::Nullable<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 ///////////////////////////////////////////////////////////////////////////
241 
242 } // namespace dd
243 
244 #endif // DD__SPATIAL_REFERENCE_SYSTEM_INCLUDE
unsigned long long int ulonglong
Definition: my_inttypes.h:55
std::uint32_t srid_t
A spatial reference system ID (SRID).
Definition: srid.h:32
Coordinate_system
Types of coordinate systems.
Definition: geometries.h:68
Definition: object_keys.h:165
virtual bool update_aux_key(Aux_key *) const
Definition: spatial_reference_system.h:74
Some integer typedefs for easier portability.
Char_string_template< String_type_allocator > String_type
Definition: string_type.h:50
virtual ~Spatial_reference_system()
Definition: spatial_reference_system.h:77
Base class for dictionary objects which has single column integer primary key.
Definition: entity_object.h:47
Spatial_reference_system Cache_partition
Definition: spatial_reference_system.h:55
This file declares the geometry class hierarchy used by the server as the internal representation of ...
static ORDER * clone(THD *thd, ORDER *order)
Shallow clone the list of ORDER objects using mem_root and return the cloned list.
Definition: window.cc:76
virtual bool update_id_key(Id_key *key) const
Definition: spatial_reference_system.h:62
Spatial_reference_system_impl Impl
Definition: spatial_reference_system.h:54
tables::Spatial_reference_systems DD_table
Definition: spatial_reference_system.h:56
virtual bool update_name_key(Name_key *key) const
Definition: spatial_reference_system.h:68
Definition: spatial_reference_systems.h:43
Void_key Aux_key
Definition: spatial_reference_system.h:59
Definition: object_keys.h:76
Definition: spatial_reference_system.h:52
Definition: spatial_reference_system_impl.h:61
Primary_id_key Id_key
Definition: spatial_reference_system.h:57
case opt name
Definition: sslopt-case.h:32
unsigned long long Object_id
Definition: object_id.h:30
static const char * key
Definition: suite_stubs.c:14
Definition: object_keys.h:53
The version of the current data dictionary table definitions.
Definition: dictionary_client.h:39
Item_name_key Name_key
Definition: spatial_reference_system.h:58
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_class.h:799