MySQL 8.0.39
Source Code Documentation
buffer_functor.h
Go to the documentation of this file.
1#ifndef SQL_GIS_BUFFER_FUNCTOR_H_INCLUDED
2#define SQL_GIS_BUFFER_FUNCTOR_H_INCLUDED
3
4// Copyright (c) 2021, 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 buffer functor interface.
30///
31/// The functor is not intended for use directly by MySQL code. It should be
32/// used indirectly through the gis::buffer() function.
33///
34/// @see gis::buffer
35
36#include <boost/geometry/strategies/strategies.hpp> // bg::strategy::buffer::*
37#include <memory> // std::unique_ptr
38#include "sql/dd/types/spatial_reference_system.h" // dd::Spatial_reference_system
39#include "sql/gis/functor.h" // gis::Unary_functor
40#include "sql/gis/geometries.h" // gis::Geometry
41#include "sql/gis/geometries_cs.h" // gis::{Cartesian_*,Geographic_point}
42
43namespace bg = boost::geometry;
44
45namespace gis {
46
47/// Buffer functor that calls boost::geometry::buffer with correct geometry
48/// type and strategy combination.
49///
50/// The functor may throw exceptions. It is intended for implementing geographic
51/// functions. It should not be used directly by other MySQL code.
52class Buffer : public Unary_functor<std::unique_ptr<Geometry>> {
53 private:
56 bg::strategy::buffer::distance_symmetric<double> d_symmetric;
57 bg::strategy::buffer::side_straight s_straight;
58
59 bg::strategy::buffer::join_round j_round;
60 bg::strategy::buffer::join_miter j_miter;
61 bg::strategy::buffer::end_round e_round;
62 bg::strategy::buffer::end_flat e_flat;
63 bg::strategy::buffer::point_circle p_circle;
64 bg::strategy::buffer::point_square p_square;
65
66 bg::strategy::buffer::geographic_point_circle<> geo_point_circle;
67
68 public:
69 explicit Buffer(const BufferStrategies &strats);
72
73 std::unique_ptr<Geometry> operator()(const Geometry &g) const override;
74
75 std::unique_ptr<Geometry> eval(const Geometry &g) const;
76
77 std::unique_ptr<Geometry> eval(const Cartesian_point &g) const;
78 std::unique_ptr<Geometry> eval(const Cartesian_multipoint &g) const;
79 std::unique_ptr<Geometry> eval(const Cartesian_linestring &g) const;
80 std::unique_ptr<Geometry> eval(const Cartesian_multilinestring &g) const;
81 std::unique_ptr<Geometry> eval(const Cartesian_polygon &g) const;
82 std::unique_ptr<Geometry> eval(const Cartesian_multipolygon &g) const;
83 std::unique_ptr<Geometry> eval(const Cartesian_geometrycollection &g) const;
84
85 std::unique_ptr<Geometry> eval(const Geographic_point &g) const;
86
87 template <class T>
88 std::unique_ptr<Geometry> typed_buffer(T &g) const;
89};
90
91} // namespace gis
92
93#endif // SQL_GIS_BUFFER_FUNCTOR_H_INCLUDED
Definition: spatial_reference_system.h:53
Buffer functor that calls boost::geometry::buffer with correct geometry type and strategy combination...
Definition: buffer_functor.h:52
bg::strategy::buffer::point_square p_square
Definition: buffer_functor.h:64
bg::strategy::buffer::point_circle p_circle
Definition: buffer_functor.h:63
bg::strategy::buffer::join_round j_round
Definition: buffer_functor.h:59
bg::strategy::buffer::geographic_point_circle geo_point_circle
Definition: buffer_functor.h:66
bg::strategy::buffer::end_flat e_flat
Definition: buffer_functor.h:62
bg::strategy::buffer::end_round e_round
Definition: buffer_functor.h:61
std::unique_ptr< Geometry > typed_buffer(T &g) const
Templated call to bg::buffer based on geometry type.
Definition: buffer.cc:265
std::unique_ptr< Geometry > eval(const Geometry &g) const
Definition: buffer.cc:78
bg::strategy::buffer::side_straight s_straight
Definition: buffer_functor.h:57
bg::strategy::buffer::join_miter j_miter
Definition: buffer_functor.h:60
std::unique_ptr< Geometry > operator()(const Geometry &g) const override
Definition: buffer.cc:74
const BufferStrategies & strats
Definition: buffer_functor.h:55
Buffer(const BufferStrategies &strats)
Definition: buffer.cc:49
bg::strategy::buffer::distance_symmetric< double > d_symmetric
Definition: buffer_functor.h:56
const dd::Spatial_reference_system * m_srs
Definition: buffer_functor.h:54
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 point.
Definition: geometries_cs.h:58
Abstract superclass for all geometric objects.
Definition: geometries.h:100
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 declares the coordinate system specific subclasses of the geometry class hierarchy.
Definition: box_traits.h:42
Definition: area.cc:47
Definition: buffer_strategies.h:45