MySQL  8.0.19
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 
106  const = 0;
107  virtual void set_organization_coordsys_id(
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
dd::Spatial_reference_system::created
virtual ulonglong created(bool convert_time) const =0
THD
Definition: sql_class.h:764
dd::Spatial_reference_system::from_normalized_longitude
virtual double from_normalized_longitude(double d) const =0
Converts a longitude value from the in-memory representation of longitude (radians,...
dd::Spatial_reference_system::is_lat_long
virtual bool is_lat_long() const =0
Check whether an SRS has latitude-longitude axis ordering.
dd::Entity_object
Base class for dictionary objects which has single column integer primary key.
Definition: entity_object.h:47
dd::String_type
Char_string_template< String_type_allocator > String_type
Definition: string_type.h:50
dd::Spatial_reference_system::organization
virtual const Mysql::Nullable< String_type > & organization() const =0
dd::Spatial_reference_system::Name_key
Item_name_key Name_key
Definition: spatial_reference_system.h:58
dd::Spatial_reference_system::Id_key
Primary_id_key Id_key
Definition: spatial_reference_system.h:57
dd::Spatial_reference_system::prime_meridian
virtual double prime_meridian() const =0
dd::Spatial_reference_system::update_name_key
virtual bool update_name_key(Name_key *key) const
Definition: spatial_reference_system.h:68
dd::Spatial_reference_system::set_description
virtual void set_description(const String_type &description)=0
dd::Spatial_reference_system::DD_table
tables::Spatial_reference_systems DD_table
Definition: spatial_reference_system.h:56
dd::tables::Spatial_reference_systems
Definition: spatial_reference_systems.h:43
dd::Spatial_reference_system::to_radians
virtual double to_radians(double d) const =0
Converts a coordinate value from the SRS unit to radians.
dd::Spatial_reference_system::update_id_key
virtual bool update_id_key(Id_key *key) const
Definition: spatial_reference_system.h:62
object_keys.h
dd
The version of the current data dictionary table definitions.
Definition: dictionary_client.h:39
dd::Spatial_reference_system::set_last_altered
virtual void set_last_altered(ulonglong last_altered)=0
dd::Spatial_reference_system::is_geographic
virtual bool is_geographic() const =0
key
static const char * key
Definition: suite_stubs.c:14
dd::Spatial_reference_system::clone
virtual Spatial_reference_system * clone() const =0
Allocate a new object and invoke the copy constructor.
dd::Spatial_reference_system::to_normalized_longitude
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 ...
Mysql::Nullable< String_type >
gis::Coordinate_system
Coordinate_system
Types of coordinate systems.
Definition: geometries.h:68
my_inttypes.h
dd::Spatial_reference_system::from_radians
virtual double from_radians(double d) const =0
Converts a coordinate value from radians to the SRS unit.
dd::Spatial_reference_system::last_altered
virtual ulonglong last_altered(bool convert_time) const =0
dd::Spatial_reference_system::~Spatial_reference_system
virtual ~Spatial_reference_system()
Definition: spatial_reference_system.h:77
dd::Spatial_reference_system::missing_towgs84
virtual bool missing_towgs84() const =0
Checks whether the SRS definition is missing a TOWGS84 clause.
dd::Spatial_reference_system::set_created
virtual void set_created(ulonglong created)=0
dd::Spatial_reference_system::angular_unit
virtual double angular_unit() const =0
dd::Entity_object::name
virtual const String_type & name() const =0
dd::Spatial_reference_system::Cache_partition
Spatial_reference_system Cache_partition
Definition: spatial_reference_system.h:55
dd::Spatial_reference_system::is_projected
virtual bool is_projected() const =0
dd::Primary_id_key
Definition: object_keys.h:76
nullable.h
dd::Spatial_reference_system::Impl
Spatial_reference_system_impl Impl
Definition: spatial_reference_system.h:54
dd::Spatial_reference_system::is_cartesian
virtual bool is_cartesian() const =0
gis::srid_t
std::uint32_t srid_t
A spatial reference system ID (SRID).
Definition: srid.h:32
dd::Spatial_reference_system::from_normalized_latitude
virtual double from_normalized_latitude(double d) const =0
Converts a latitude value from the in-memory representation of latitude (radians, positive North) to ...
dd::Object_id
unsigned long long Object_id
Definition: object_id.h:30
geometries.h
dd::Spatial_reference_system::linear_unit
virtual double linear_unit() const =0
dd::Spatial_reference_system::set_definition
virtual void set_definition(const String_type &definition)=0
dd::Spatial_reference_system::Aux_key
Void_key Aux_key
Definition: spatial_reference_system.h:59
dd::Spatial_reference_system::set_organization
virtual void set_organization(const String_type &organization)=0
dd::Spatial_reference_system::definition
virtual const String_type & definition() const =0
srid.h
dd::Spatial_reference_system::positive_north
virtual bool positive_north() const =0
dd::Spatial_reference_system_impl
Definition: spatial_reference_system_impl.h:61
dd::Spatial_reference_system::cs_type
virtual gis::Coordinate_system cs_type() const =0
dd::Spatial_reference_system::semi_minor_axis
virtual double semi_minor_axis() const =0
dd::Void_key
Definition: object_keys.h:53
dd::Spatial_reference_system::description
virtual const Mysql::Nullable< String_type > & description() const =0
dd::Spatial_reference_system::positive_east
virtual bool positive_east() const =0
ulonglong
unsigned long long int ulonglong
Definition: my_inttypes.h:55
entity_object.h
dd::Spatial_reference_system::organization_coordsys_id
virtual const Mysql::Nullable< gis::srid_t > & organization_coordsys_id() const =0
dd::Spatial_reference_system::update_aux_key
virtual bool update_aux_key(Aux_key *) const
Definition: spatial_reference_system.h:74
dd::Spatial_reference_system::set_organization_coordsys_id
virtual void set_organization_coordsys_id(gis::srid_t organization_coordsys_id)=0
dd::Spatial_reference_system::semi_major_axis
virtual double semi_major_axis() const =0
dd::Spatial_reference_system::to_normalized_latitude
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...
dd::Spatial_reference_system::proj4_parameters
virtual String_type proj4_parameters() const =0
Gets the proj4 parameters for this SRS.
dd::Item_name_key
Definition: object_keys.h:165
dd::Spatial_reference_system
Definition: spatial_reference_system.h:52
dd::Spatial_reference_system::can_be_modified_to
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.