MySQL 8.0.29
Source Code Documentation
transform_functor.h
Go to the documentation of this file.
1#ifndef SQL_GIS_TRANSFORM_FUNCTOR_H_INCLUDED
2#define SQL_GIS_TRANSFORM_FUNCTOR_H_INCLUDED
3
4// Copyright (c) 2018, 2022, 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/// @file
27///
28/// This file declares the transform functor interface.
29///
30/// The functor is not intended for use directly by MySQL code. It should be
31/// used indirectly through the gis::transform() function.
32///
33/// @see gis::transform
34
35#include <memory> // std::unique_ptr
36#include <string>
37
38#include "my_compiler.h"
39
41MY_COMPILER_GCC_DIAGNOSTIC_IGNORE("-Wmaybe-uninitialized")
42#include <boost/geometry.hpp>
43#include <boost/geometry/srs/transformation.hpp>
45
46#include "sql/gis/functor.h"
47#include "sql/gis/geometries.h"
49
50namespace gis {
51
52/// Transform functor that calls Boost.Geometry with the correct parameter
53/// types.
54///
55/// The functor throws exceptions and is therefore only intended used to
56/// implement transform or other geographic functions. It should not be used
57/// directly by other MySQL code.
58class Transform : public Unary_functor<std::unique_ptr<Geometry>> {
59 private:
60 /// The transformation object that holds information about input and output
61 /// definitions.
62 boost::geometry::srs::transformation<> m_transformation;
63 /// Coordinate system of the output SRS.
65
66 public:
67 /// Create a new transform functor.
68 ///
69 /// Theoretically, we could deduce the coordinate system of the output SRS
70 /// from the old_srs_param proj4 string, but it's easier to get it from the DD
71 /// SRS object on the caller side.
72 ///
73 /// @param[in] old_srs_params The proj4 parameters of the input SRS.
74 /// @param[in] new_srs_params The proj4 parameters of the output SRS.
75 /// @param[in] output_cs The coordinate system of the output SRS.
76 Transform(const std::string &old_srs_params,
77 const std::string &new_srs_params, Coordinate_system output_cs);
78
79 std::unique_ptr<Geometry> operator()(const Geometry &g) const override;
80 std::unique_ptr<Geometry> eval(const Geometry &g) const;
81 std::unique_ptr<Geometry> eval(const Geographic_point &g) const;
82 std::unique_ptr<Geometry> eval(const Geographic_linestring &g) const;
83 std::unique_ptr<Geometry> eval(const Geographic_polygon &g) const;
84 std::unique_ptr<Geometry> eval(const Geographic_geometrycollection &g) const;
85 std::unique_ptr<Geometry> eval(const Geographic_multipoint &g) const;
86 std::unique_ptr<Geometry> eval(const Geographic_multilinestring &g) const;
87 std::unique_ptr<Geometry> eval(const Geographic_multipolygon &g) const;
88};
89
90} // namespace gis
91
92#endif // SQL_GIS_TRANSFORM_FUNCTOR_H_INCLUDED
A geographic (ellipsoidal) 2d geometry collection.
Definition: geometries_cs.h:437
A geographic (ellipsoidal) 2d linestring.
Definition: geometries_cs.h:124
A geographic (ellipsoidal) 2d multilinestring.
Definition: geometries_cs.h:660
A geographic (ellipsoidal) 2d multipoint.
Definition: geometries_cs.h:551
A geographic (ellipsoidal) 2d multipolygon.
Definition: geometries_cs.h:773
A geographic (ellipsoidal) 2d point.
Definition: geometries_cs.h:57
A geographic (ellipsoidal) 2d polygon.
Definition: geometries_cs.h:321
Abstract superclass for all geometric objects.
Definition: geometries.h:99
Transform functor that calls Boost.Geometry with the correct parameter types.
Definition: transform_functor.h:58
boost::geometry::srs::transformation m_transformation
The transformation object that holds information about input and output definitions.
Definition: transform_functor.h:62
std::unique_ptr< Geometry > eval(const Geometry &g) const
Definition: transform.cc:65
Coordinate_system m_output_cs
Coordinate system of the output SRS.
Definition: transform_functor.h:64
Transform(const std::string &old_srs_params, const std::string &new_srs_params, Coordinate_system output_cs)
Create a new transform functor.
Definition: transform.cc:54
std::unique_ptr< Geometry > operator()(const Geometry &g) const override
Definition: transform.cc:61
The base class of all functors that take one geometry argument.
Definition: functor.h:614
This file declares the geometry class hierarchy used by the server as the internal representation of ...
This file contains Boost.Geometry type traits declarations for Cartesian and geographic geometries.
Header for compiler-dependent features.
#define MY_COMPILER_GCC_DIAGNOSTIC_IGNORE(X)
Definition: my_compiler.h:260
#define MY_COMPILER_DIAGNOSTIC_PUSH()
save the compiler's diagnostic (enabled warnings, errors, ...) state
Definition: my_compiler.h:295
#define MY_COMPILER_DIAGNOSTIC_POP()
restore the compiler's diagnostic (enabled warnings, errors, ...) state
Definition: my_compiler.h:296
Definition: area.cc:46
Coordinate_system
Types of coordinate systems.
Definition: geometries.h:68