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