MySQL 9.1.0
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, 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/// @file
28///
29/// This file declares the transform functor interface.
30///
31/// The functor is not intended for use directly by MySQL code. It should be
32/// used indirectly through the gis::transform() function.
33///
34/// @see gis::transform
35
36#include <memory> // std::unique_ptr
37#include <string>
38
39#include "my_compiler.h"
40
41// Clang 16 on windows gives warning:
42// pragma diagnostic pop could not pop, no matching push [-Wunknown-pragmas]
43// So there must be some mismatching push/pop in boost
44#if !defined(__clang__) || !defined(_WIN32)
46MY_COMPILER_GCC_DIAGNOSTIC_IGNORE("-Wmaybe-uninitialized")
47#endif
48
49#include <boost/geometry.hpp>
50#include <boost/geometry/srs/transformation.hpp>
51
52#if !defined(__clang__) || !defined(_WIN32)
54#endif
55
56#include "sql/gis/functor.h"
57#include "sql/gis/geometries.h"
59
60namespace gis {
61
62/// Transform functor that calls Boost.Geometry with the correct parameter
63/// types.
64///
65/// The functor throws exceptions and is therefore only intended used to
66/// implement transform or other geographic functions. It should not be used
67/// directly by other MySQL code.
68class Transform : public Unary_functor<std::unique_ptr<Geometry>> {
69 private:
70 /// The transformation object that holds information about input and output
71 /// definitions.
72 boost::geometry::srs::transformation<> m_transformation;
73 /// Coordinate system of the output SRS.
75
76 public:
77 /// Create a new transform functor.
78 ///
79 /// Theoretically, we could deduce the coordinate system of the output SRS
80 /// from the old_srs_param proj4 string, but it's easier to get it from the DD
81 /// SRS object on the caller side.
82 ///
83 /// @param[in] old_srs_params The proj4 parameters of the input SRS.
84 /// @param[in] new_srs_params The proj4 parameters of the output SRS.
85 /// @param[in] output_cs The coordinate system of the output SRS.
86 Transform(const std::string &old_srs_params,
87 const std::string &new_srs_params, Coordinate_system output_cs);
88
89 std::unique_ptr<Geometry> operator()(const Geometry &g) const override;
90 std::unique_ptr<Geometry> eval(const Geometry &g) const;
91 std::unique_ptr<Geometry> eval(const Cartesian_point &g) const;
92 std::unique_ptr<Geometry> eval(const Geographic_point &g) const;
93 std::unique_ptr<Geometry> eval(const Cartesian_linestring &g) const;
94 std::unique_ptr<Geometry> eval(const Geographic_linestring &g) const;
95 std::unique_ptr<Geometry> eval(const Cartesian_polygon &g) const;
96 std::unique_ptr<Geometry> eval(const Geographic_polygon &g) const;
97 std::unique_ptr<Geometry> eval(const Cartesian_geometrycollection &g) const;
98 std::unique_ptr<Geometry> eval(const Geographic_geometrycollection &g) const;
99 std::unique_ptr<Geometry> eval(const Cartesian_multipoint &g) const;
100 std::unique_ptr<Geometry> eval(const Geographic_multipoint &g) const;
101 std::unique_ptr<Geometry> eval(const Cartesian_multilinestring &g) const;
102 std::unique_ptr<Geometry> eval(const Geographic_multilinestring &g) const;
103 std::unique_ptr<Geometry> eval(const Cartesian_multipolygon &g) const;
104 std::unique_ptr<Geometry> eval(const Geographic_multipolygon &g) const;
105};
106
107} // namespace gis
108
109#endif // SQL_GIS_TRANSFORM_FUNCTOR_H_INCLUDED
A Cartesian 2d geometry collection.
Definition: geometries_cs.h:375
A Cartesian 2d linestring.
Definition: geometries_cs.h:71
A Cartesian 2d multilinestring.
Definition: geometries_cs.h:602
A Cartesian 2d multipoint.
Definition: geometries_cs.h:501
A Cartesian 2d multipolygon.
Definition: geometries_cs.h:720
A Cartesian 2d point.
Definition: geometries_cs.h:47
A Cartesian 2d polygon.
Definition: geometries_cs.h:269
A geographic (ellipsoidal) 2d geometry collection.
Definition: geometries_cs.h:438
A geographic (ellipsoidal) 2d linestring.
Definition: geometries_cs.h:125
A geographic (ellipsoidal) 2d multilinestring.
Definition: geometries_cs.h:661
A geographic (ellipsoidal) 2d multipoint.
Definition: geometries_cs.h:552
A geographic (ellipsoidal) 2d multipolygon.
Definition: geometries_cs.h:774
A geographic (ellipsoidal) 2d point.
Definition: geometries_cs.h:58
A geographic (ellipsoidal) 2d polygon.
Definition: geometries_cs.h:322
Abstract superclass for all geometric objects.
Definition: geometries.h:100
Transform functor that calls Boost.Geometry with the correct parameter types.
Definition: transform_functor.h:68
boost::geometry::srs::transformation m_transformation
The transformation object that holds information about input and output definitions.
Definition: transform_functor.h:72
std::unique_ptr< Geometry > eval(const Geometry &g) const
Definition: transform.cc:131
Coordinate_system m_output_cs
Coordinate system of the output SRS.
Definition: transform_functor.h:74
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:120
std::unique_ptr< Geometry > operator()(const Geometry &g) const override
Definition: transform.cc:127
The base class of all functors that take one geometry argument.
Definition: functor.h:615
This file contains the superclasses for GIS functors.
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:242
#define MY_COMPILER_DIAGNOSTIC_PUSH()
save the compiler's diagnostic (enabled warnings, errors, ...) state
Definition: my_compiler.h:277
#define MY_COMPILER_DIAGNOSTIC_POP()
restore the compiler's diagnostic (enabled warnings, errors, ...) state
Definition: my_compiler.h:278
Definition: area.cc:47
Coordinate_system
Types of coordinate systems.
Definition: geometries.h:69