MySQL 8.0.29
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, 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 buffer functor interface.
29///
30/// The functor is not intended for use directly by MySQL code. It should be
31/// used indirectly through the gis::buffer() function.
32///
33/// @see gis::buffer
34
35#include <boost/geometry/strategies/strategies.hpp> // bg::strategy::buffer::*
36#include <memory> // std::unique_ptr
37#include "sql/dd/types/spatial_reference_system.h" // dd::Spatial_reference_system
38#include "sql/gis/functor.h" // gis::Unary_functor
39#include "sql/gis/geometries.h" // gis::Geometry
40#include "sql/gis/geometries_cs.h" // gis::{Cartesian_*,Geographic_point}
41
42namespace bg = boost::geometry;
43
44namespace gis {
45
46/// Buffer functor that calls boost::geometry::buffer with correct geometry
47/// type and strategy combination.
48///
49/// The functor may throw exceptions. It is intended for implementing geographic
50/// functions. It should not be used directly by other MySQL code.
51class Buffer : public Unary_functor<std::unique_ptr<Geometry>> {
52 private:
55 bg::strategy::buffer::distance_symmetric<double> d_symmetric;
56 bg::strategy::buffer::side_straight s_straight;
57
58 bg::strategy::buffer::join_round j_round;
59 bg::strategy::buffer::join_miter j_miter;
60 bg::strategy::buffer::end_round e_round;
61 bg::strategy::buffer::end_flat e_flat;
62 bg::strategy::buffer::point_circle p_circle;
63 bg::strategy::buffer::point_square p_square;
64
65 bg::strategy::buffer::geographic_point_circle<> geo_point_circle;
66
67 public:
68 explicit Buffer(const BufferStrategies &strats);
71
72 std::unique_ptr<Geometry> operator()(const Geometry &g) const override;
73
74 std::unique_ptr<Geometry> eval(const Geometry &g) const;
75
76 std::unique_ptr<Geometry> eval(const Cartesian_point &g) const;
77 std::unique_ptr<Geometry> eval(const Cartesian_multipoint &g) const;
78 std::unique_ptr<Geometry> eval(const Cartesian_linestring &g) const;
79 std::unique_ptr<Geometry> eval(const Cartesian_multilinestring &g) const;
80 std::unique_ptr<Geometry> eval(const Cartesian_polygon &g) const;
81 std::unique_ptr<Geometry> eval(const Cartesian_multipolygon &g) const;
82 std::unique_ptr<Geometry> eval(const Cartesian_geometrycollection &g) const;
83
84 std::unique_ptr<Geometry> eval(const Geographic_point &g) const;
85
86 template <class T>
87 std::unique_ptr<Geometry> typed_buffer(T &g) const;
88};
89
90} // namespace gis
91
92#endif // SQL_GIS_BUFFER_FUNCTOR_H_INCLUDED
Definition: spatial_reference_system.h:52
Buffer functor that calls boost::geometry::buffer with correct geometry type and strategy combination...
Definition: buffer_functor.h:51
bg::strategy::buffer::point_square p_square
Definition: buffer_functor.h:63
bg::strategy::buffer::point_circle p_circle
Definition: buffer_functor.h:62
bg::strategy::buffer::join_round j_round
Definition: buffer_functor.h:58
bg::strategy::buffer::geographic_point_circle geo_point_circle
Definition: buffer_functor.h:65
bg::strategy::buffer::end_flat e_flat
Definition: buffer_functor.h:61
bg::strategy::buffer::end_round e_round
Definition: buffer_functor.h:60
std::unique_ptr< Geometry > typed_buffer(T &g) const
Templated call to bg::buffer based on geometry type.
Definition: buffer.cc:264
std::unique_ptr< Geometry > eval(const Geometry &g) const
Definition: buffer.cc:77
bg::strategy::buffer::side_straight s_straight
Definition: buffer_functor.h:56
bg::strategy::buffer::join_miter j_miter
Definition: buffer_functor.h:59
std::unique_ptr< Geometry > operator()(const Geometry &g) const override
Definition: buffer.cc:73
const BufferStrategies & strats
Definition: buffer_functor.h:54
Buffer(const BufferStrategies &strats)
Definition: buffer.cc:48
bg::strategy::buffer::distance_symmetric< double > d_symmetric
Definition: buffer_functor.h:55
const dd::Spatial_reference_system * m_srs
Definition: buffer_functor.h:53
A Cartesian 2d geometry collection.
Definition: geometries_cs.h:374
A Cartesian 2d linestring.
Definition: geometries_cs.h:70
A Cartesian 2d multilinestring.
Definition: geometries_cs.h:601
A Cartesian 2d multipoint.
Definition: geometries_cs.h:500
A Cartesian 2d multipolygon.
Definition: geometries_cs.h:719
A Cartesian 2d point.
Definition: geometries_cs.h:46
A Cartesian 2d polygon.
Definition: geometries_cs.h:268
A geographic (ellipsoidal) 2d point.
Definition: geometries_cs.h:57
Abstract superclass for all geometric objects.
Definition: geometries.h:99
The base class of all functors that take one geometry argument.
Definition: functor.h:614
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:41
Definition: area.cc:46
Definition: buffer_strategies.h:44