MySQL 8.0.39
Source Code Documentation
geometries_traits.h
Go to the documentation of this file.
1#ifndef SQL_GIS_GEOMETRIES_TRAITS_H_INCLUDED
2#define SQL_GIS_GEOMETRIES_TRAITS_H_INCLUDED
3
4// Copyright (c) 2017, 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 contains Boost.Geometry type traits declarations for Cartesian and
30/// geographic geometries.
31///
32/// @see geometries_cs.h
33
34#include <boost/geometry/core/access.hpp>
35#include <boost/geometry/core/closure.hpp>
36#include <boost/geometry/core/coordinate_dimension.hpp>
37#include <boost/geometry/core/coordinate_system.hpp>
38#include <boost/geometry/core/coordinate_type.hpp>
39#include <boost/geometry/core/cs.hpp>
40#include <boost/geometry/core/exterior_ring.hpp>
41#include <boost/geometry/core/interior_rings.hpp>
42#include <boost/geometry/core/interior_type.hpp>
43#include <boost/geometry/core/point_order.hpp>
44#include <boost/geometry/core/ring_type.hpp>
45#include <boost/geometry/core/tags.hpp>
46#include <boost/geometry/geometries/concepts/linestring_concept.hpp>
47#include <boost/geometry/geometries/concepts/point_concept.hpp>
48#include <boost/geometry/geometries/concepts/polygon_concept.hpp>
49#include <boost/geometry/multi/core/tags.hpp>
50
53
54namespace boost {
55namespace geometry {
56namespace traits {
57
58////////////////////////////////////////////////////////////////////////////////
59
60// Cartesian
61
62// Point
63
64template <>
65struct tag<gis::Cartesian_point> {
66 typedef boost::geometry::point_tag type;
67};
68
69template <>
70struct coordinate_type<gis::Cartesian_point> {
71 typedef double type;
72};
73
74template <>
75struct coordinate_system<gis::Cartesian_point> {
76 typedef boost::geometry::cs::cartesian type;
77};
78
79template <>
80struct dimension<gis::Cartesian_point> : boost::mpl::int_<2> {};
81
82template <std::size_t Dimension>
83struct access<gis::Cartesian_point, Dimension> {
84 static inline double get(gis::Cartesian_point const &p) {
85 return p.get<Dimension>();
86 }
87
88 static inline void set(gis::Cartesian_point &p, double const &value) {
89 p.set<Dimension>(value);
90 }
91};
92
93// Linestring
94
95template <>
96struct tag<gis::Cartesian_linestring> {
97 typedef boost::geometry::linestring_tag type;
98};
99
100// Linearring
101
102template <>
103struct tag<gis::Cartesian_linearring> {
104 typedef boost::geometry::ring_tag type;
105};
106
107template <>
108struct point_order<gis::Cartesian_linearring> {
109 static const order_selector value = counterclockwise;
110};
111
112template <>
113struct closure<gis::Cartesian_linearring> {
114 static const closure_selector value = closed;
115};
116
117// Polygon
118
119template <>
120struct tag<gis::Cartesian_polygon> {
121 typedef boost::geometry::polygon_tag type;
122};
123
124template <>
125struct ring_const_type<gis::Cartesian_polygon> {
127};
128
129template <>
130struct ring_mutable_type<gis::Cartesian_polygon> {
132};
133
134template <>
135struct interior_const_type<gis::Cartesian_polygon> {
138};
139
140template <>
141struct interior_mutable_type<gis::Cartesian_polygon> {
144};
145
146template <>
147struct exterior_ring<gis::Cartesian_polygon> {
149 return py.cartesian_exterior_ring();
150 }
151
152 static inline gis::Cartesian_linearring const &get(
153 gis::Cartesian_polygon const &py) {
154 return py.cartesian_exterior_ring();
155 }
156};
157
158template <>
159struct interior_rings<gis::Cartesian_polygon> {
163 return py.interior_rings();
164 }
165
169 return py.const_interior_rings();
170 }
171};
172
173// Multipoint
174
175template <>
176struct tag<gis::Cartesian_multipoint> {
177 typedef boost::geometry::multi_point_tag type;
178};
179
180// Multilinestring
181
182template <>
183struct tag<gis::Cartesian_multilinestring> {
184 typedef boost::geometry::multi_linestring_tag type;
185};
186
187// Multipolygon
188
189template <>
190struct tag<gis::Cartesian_multipolygon> {
191 typedef boost::geometry::multi_polygon_tag type;
192};
193
194////////////////////////////////////////////////////////////////////////////////
195
196// Geographic
197
198// Point
199
200template <>
201struct tag<gis::Geographic_point> {
202 typedef boost::geometry::point_tag type;
203};
204
205template <>
206struct coordinate_type<gis::Geographic_point> {
207 typedef double type;
208};
209
210template <>
211struct coordinate_system<gis::Geographic_point> {
212 typedef boost::geometry::cs::geographic<radian> type;
213};
214
215template <>
216struct dimension<gis::Geographic_point> : boost::mpl::int_<2> {};
217
218template <std::size_t Dimension>
219struct access<gis::Geographic_point, Dimension> {
220 static inline double get(gis::Geographic_point const &p) {
221 return p.get<Dimension>();
222 }
223
224 static inline void set(gis::Geographic_point &p, double const &value) {
225 p.set<Dimension>(value);
226 }
227};
228
229// Linestring
230
231template <>
232struct tag<gis::Geographic_linestring> {
233 typedef boost::geometry::linestring_tag type;
234};
235
236// Linearring
237
238template <>
239struct tag<gis::Geographic_linearring> {
240 typedef boost::geometry::ring_tag type;
241};
242
243template <>
244struct point_order<gis::Geographic_linearring> {
245 static const order_selector value = counterclockwise;
246};
247
248template <>
249struct closure<gis::Geographic_linearring> {
250 static const closure_selector value = closed;
251};
252
253// Polygon
254
255template <>
256struct tag<gis::Geographic_polygon> {
257 typedef boost::geometry::polygon_tag type;
258};
259
260template <>
261struct ring_const_type<gis::Geographic_polygon> {
263};
264
265template <>
266struct ring_mutable_type<gis::Geographic_polygon> {
268};
269
270template <>
271struct interior_const_type<gis::Geographic_polygon> {
274};
275
276template <>
277struct interior_mutable_type<gis::Geographic_polygon> {
280};
281
282template <>
283struct exterior_ring<gis::Geographic_polygon> {
285 return py.geographic_exterior_ring();
286 }
287
288 static inline gis::Geographic_linearring const &get(
289 gis::Geographic_polygon const &py) {
290 return py.geographic_exterior_ring();
291 }
292};
293
294template <>
295struct interior_rings<gis::Geographic_polygon> {
299 return py.interior_rings();
300 }
301
304 &
306 return py.const_interior_rings();
307 }
308};
309
310// Multipoint
311
312template <>
313struct tag<gis::Geographic_multipoint> {
314 typedef boost::geometry::multi_point_tag type;
315};
316
317// Multilinestring
318
319template <>
320struct tag<gis::Geographic_multilinestring> {
321 typedef boost::geometry::multi_linestring_tag type;
322};
323
324// Multipolygon
325
326template <>
327struct tag<gis::Geographic_multipolygon> {
328 typedef boost::geometry::multi_polygon_tag type;
329};
330
331} // namespace traits
332} // namespace geometry
333} // namespace boost
334
335#endif // SQL_GIS_GEOMETRIES_TRAITS_H_INCLUDED
Malloc_allocator is a C++ STL memory allocator based on my_malloc/my_free.
Definition: malloc_allocator.h:63
A Cartesian 2d linear ring.
Definition: geometries_cs.h:177
A Cartesian 2d point.
Definition: geometries_cs.h:47
A Cartesian 2d polygon.
Definition: geometries_cs.h:269
decltype(m_interior_rings) & interior_rings()
Get list of interior rings.
Cartesian_linearring & cartesian_exterior_ring() const
Get the exterior ring.
Definition: geometries.cc:210
decltype(m_interior_rings) const & const_interior_rings() const
Get list of interior rings.
A geographic (ellipsoidal) 2d linear ring.
Definition: geometries_cs.h:223
A geographic (ellipsoidal) 2d point.
Definition: geometries_cs.h:58
A geographic (ellipsoidal) 2d polygon.
Definition: geometries_cs.h:322
decltype(m_interior_rings) & interior_rings()
Get list of interior rings.
decltype(m_interior_rings) const & const_interior_rings() const
Get list of interior rings.
Geographic_linearring & geographic_exterior_ring() const
Get the exterior ring.
Definition: geometries.cc:255
const char * p
Definition: ctype-mb.cc:1237
This file declares the coordinate system specific subclasses of the geometry class hierarchy.
Tag dispatch for custom Role_properties.
Definition: sql_auth_cache.h:588
Definition: area.cc:47
std::vector< T, ut::allocator< T > > vector
Specialization of vector which uses allocator.
Definition: ut0new.h:2874
static double get(gis::Cartesian_point const &p)
Definition: geometries_traits.h:84
static void set(gis::Cartesian_point &p, double const &value)
Definition: geometries_traits.h:88
static void set(gis::Geographic_point &p, double const &value)
Definition: geometries_traits.h:224
static double get(gis::Geographic_point const &p)
Definition: geometries_traits.h:220
boost::geometry::cs::cartesian type
Definition: geometries_traits.h:76
boost::geometry::cs::geographic< radian > type
Definition: geometries_traits.h:212
static gis::Cartesian_linearring & get(gis::Cartesian_polygon &py)
Definition: geometries_traits.h:148
static gis::Cartesian_linearring const & get(gis::Cartesian_polygon const &py)
Definition: geometries_traits.h:152
static gis::Geographic_linearring const & get(gis::Geographic_polygon const &py)
Definition: geometries_traits.h:288
static gis::Geographic_linearring & get(gis::Geographic_polygon &py)
Definition: geometries_traits.h:284
std::vector< gis::Cartesian_linearring, Malloc_allocator< gis::Cartesian_linearring > > const & type
Definition: geometries_traits.h:137
std::vector< gis::Geographic_linearring, Malloc_allocator< gis::Geographic_linearring > > const & type
Definition: geometries_traits.h:273
std::vector< gis::Cartesian_linearring, Malloc_allocator< gis::Cartesian_linearring > > & type
Definition: geometries_traits.h:143
std::vector< gis::Geographic_linearring, Malloc_allocator< gis::Geographic_linearring > > & type
Definition: geometries_traits.h:279
static std::vector< gis::Cartesian_linearring, Malloc_allocator< gis::Cartesian_linearring > > & get(gis::Cartesian_polygon &py)
Definition: geometries_traits.h:162
static std::vector< gis::Cartesian_linearring, Malloc_allocator< gis::Cartesian_linearring > > const & get(gis::Cartesian_polygon const &py)
Definition: geometries_traits.h:168
static std::vector< gis::Geographic_linearring, Malloc_allocator< gis::Geographic_linearring > > const & get(gis::Geographic_polygon const &py)
Definition: geometries_traits.h:305
static std::vector< gis::Geographic_linearring, Malloc_allocator< gis::Geographic_linearring > > & get(gis::Geographic_polygon &py)
Definition: geometries_traits.h:298
gis::Cartesian_linearring const & type
Definition: geometries_traits.h:126
gis::Geographic_linearring const & type
Definition: geometries_traits.h:262
gis::Cartesian_linearring & type
Definition: geometries_traits.h:131
gis::Geographic_linearring & type
Definition: geometries_traits.h:267
boost::geometry::ring_tag type
Definition: geometries_traits.h:104
boost::geometry::linestring_tag type
Definition: geometries_traits.h:97
boost::geometry::multi_linestring_tag type
Definition: geometries_traits.h:184
boost::geometry::multi_point_tag type
Definition: geometries_traits.h:177
boost::geometry::multi_polygon_tag type
Definition: geometries_traits.h:191
boost::geometry::point_tag type
Definition: geometries_traits.h:66
boost::geometry::polygon_tag type
Definition: geometries_traits.h:121
boost::geometry::ring_tag type
Definition: geometries_traits.h:240
boost::geometry::linestring_tag type
Definition: geometries_traits.h:233
boost::geometry::multi_linestring_tag type
Definition: geometries_traits.h:321
boost::geometry::multi_point_tag type
Definition: geometries_traits.h:314
boost::geometry::multi_polygon_tag type
Definition: geometries_traits.h:328
boost::geometry::point_tag type
Definition: geometries_traits.h:202
boost::geometry::polygon_tag type
Definition: geometries_traits.h:257