MySQL 9.1.0
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, 2024, 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 designed to work 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 either included with
16 the program or referenced in the documentation.
17
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License, version 2.0, for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software
25 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. */
26
27#include <string.h>
28
29#include "map_helpers.h"
30
31namespace gis {
32enum class Unit_Type { kLinear };
33
34struct Unit {
37 std::string description;
38
39 Unit() = default;
40
43 bool operator==(const gis::Unit &rhs) const {
44 return unit_type == rhs.unit_type &&
47 }
48};
49
50/// A function to obtaint the supported units for the gis module.
51///
52/// @return Map of supported units for ST_DISTANCE
54
55/// Retrieves the length of the unit in meters.
56/// @param unit the name of the unit we want the conversion factor for.
57/// @param[out] conversion_factor A pointer to where the result should be put,
58/// not touched in case of error.
59/// @retval True if unit is not found.
60/// @retval False in case of success.
61bool get_conversion_factor(const std::string &unit, double *conversion_factor);
62
63} // namespace gis
64
65#endif // SQL_GIS_ST_UNITS_OF_MEASURE_H_INCLUDED
std::unordered_map, but with my_malloc and collation-aware comparison.
Definition: map_helpers.h:219
Definition: area.cc:47
collation_unordered_map< std::string, Unit > units()
A function to obtaint the supported units for the gis module.
Definition: st_units_of_measure.cc:29
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:118
Unit_Type
Definition: st_units_of_measure.h:32
Definition: st_units_of_measure.h:34
Unit(const Unit_Type unit_type, const double conversion_factor)
Definition: st_units_of_measure.h:41
Unit()=default
std::string description
Definition: st_units_of_measure.h:37
Unit_Type unit_type
Definition: st_units_of_measure.h:35
double conversion_factor
Definition: st_units_of_measure.h:36
bool operator==(const gis::Unit &rhs) const
Definition: st_units_of_measure.h:43