MySQL  8.0.28
Source Code Documentation
st_units_of_measure.h
Go to the documentation of this file.
1 #ifndef SQL_GIS_ST_UNITS_OF_MEASURE_H_INCLUDED
2 #define SQL_GIS_ST_UNITS_OF_MEASURE_H_INCLUDED
3 
4 /* Copyright (c) 2018, 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.h>
27 
28 #include "map_helpers.h"
29 
30 namespace gis {
31 enum class Unit_Type { kLinear };
32 
33 struct Unit {
36  std::string description;
37 
38  Unit() = default;
39 
42  bool operator==(const gis::Unit &rhs) const {
43  return unit_type == rhs.unit_type &&
45  description == rhs.description;
46  }
47 };
48 
49 /// A function to obtaint the supported units for the gis module.
50 ///
51 /// @return Map of supported units for ST_DISTANCE
53 
54 /// Retrieves the length of the unit in meters.
55 /// @param unit the name of the unit we want the conversion factor for.
56 /// @param[out] conversion_factor A pointer to where the result should be put,
57 /// not touched in case of error.
58 /// @retval True if unit is not found.
59 /// @retval False in case of success.
60 bool get_conversion_factor(const std::string &unit, double *conversion_factor);
61 
62 } // namespace gis
63 
64 #endif // SQL_GIS_ST_UNITS_OF_MEASURE_H_INCLUDED
std::unordered_map, but with my_malloc and collation-aware comparison.
Definition: map_helpers.h:209
Definition: area.cc:46
collation_unordered_map< std::string, Unit > units()
A function to obtaint the supported units for the gis module.
Definition: st_units_of_measure.cc:28
bool get_conversion_factor(const std::string &unit, double *conversion_factor)
Retrieves the length of the unit in meters.
Definition: st_units_of_measure.cc:117
Unit_Type
Definition: st_units_of_measure.h:31
Definition: st_units_of_measure.h:33
Unit(const Unit_Type unit_type, const double conversion_factor)
Definition: st_units_of_measure.h:40
Unit()=default
std::string description
Definition: st_units_of_measure.h:36
Unit_Type unit_type
Definition: st_units_of_measure.h:34
double conversion_factor
Definition: st_units_of_measure.h:35
bool operator==(const gis::Unit &rhs) const
Definition: st_units_of_measure.h:42