MySQL  8.0.26
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, 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 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 
50 #include "sql/gis/geometries_cs.h"
51 #include "sql/malloc_allocator.h"
52 
53 namespace boost {
54 namespace geometry {
55 namespace traits {
56 
57 ////////////////////////////////////////////////////////////////////////////////
58 
59 // Cartesian
60 
61 // Point
62 
63 template <>
64 struct tag<gis::Cartesian_point> {
65  typedef boost::geometry::point_tag type;
66 };
67 
68 template <>
69 struct coordinate_type<gis::Cartesian_point> {
70  typedef double type;
71 };
72 
73 template <>
74 struct coordinate_system<gis::Cartesian_point> {
75  typedef boost::geometry::cs::cartesian type;
76 };
77 
78 template <>
79 struct dimension<gis::Cartesian_point> : boost::mpl::int_<2> {};
80 
81 template <std::size_t Dimension>
82 struct 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 
94 template <>
95 struct tag<gis::Cartesian_linestring> {
96  typedef boost::geometry::linestring_tag type;
97 };
98 
99 // Linearring
100 
101 template <>
102 struct tag<gis::Cartesian_linearring> {
103  typedef boost::geometry::ring_tag type;
104 };
105 
106 template <>
107 struct point_order<gis::Cartesian_linearring> {
108  static const order_selector value = counterclockwise;
109 };
110 
111 template <>
112 struct closure<gis::Cartesian_linearring> {
113  static const closure_selector value = closed;
114 };
115 
116 // Polygon
117 
118 template <>
119 struct tag<gis::Cartesian_polygon> {
120  typedef boost::geometry::polygon_tag type;
121 };
122 
123 template <>
124 struct ring_const_type<gis::Cartesian_polygon> {
126 };
127 
128 template <>
129 struct ring_mutable_type<gis::Cartesian_polygon> {
131 };
132 
133 template <>
134 struct interior_const_type<gis::Cartesian_polygon> {
137 };
138 
139 template <>
140 struct interior_mutable_type<gis::Cartesian_polygon> {
143 };
144 
145 template <>
146 struct 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 
157 template <>
158 struct interior_rings<gis::Cartesian_polygon> {
162  return py.interior_rings();
163  }
164 
168  return py.const_interior_rings();
169  }
170 };
171 
172 // Multipoint
173 
174 template <>
175 struct tag<gis::Cartesian_multipoint> {
176  typedef boost::geometry::multi_point_tag type;
177 };
178 
179 // Multilinestring
180 
181 template <>
182 struct tag<gis::Cartesian_multilinestring> {
183  typedef boost::geometry::multi_linestring_tag type;
184 };
185 
186 // Multipolygon
187 
188 template <>
189 struct tag<gis::Cartesian_multipolygon> {
190  typedef boost::geometry::multi_polygon_tag type;
191 };
192 
193 ////////////////////////////////////////////////////////////////////////////////
194 
195 // Geographic
196 
197 // Point
198 
199 template <>
200 struct tag<gis::Geographic_point> {
201  typedef boost::geometry::point_tag type;
202 };
203 
204 template <>
205 struct coordinate_type<gis::Geographic_point> {
206  typedef double type;
207 };
208 
209 template <>
210 struct coordinate_system<gis::Geographic_point> {
211  typedef boost::geometry::cs::geographic<radian> type;
212 };
213 
214 template <>
215 struct dimension<gis::Geographic_point> : boost::mpl::int_<2> {};
216 
217 template <std::size_t Dimension>
218 struct 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 
230 template <>
231 struct tag<gis::Geographic_linestring> {
232  typedef boost::geometry::linestring_tag type;
233 };
234 
235 // Linearring
236 
237 template <>
238 struct tag<gis::Geographic_linearring> {
239  typedef boost::geometry::ring_tag type;
240 };
241 
242 template <>
243 struct point_order<gis::Geographic_linearring> {
244  static const order_selector value = counterclockwise;
245 };
246 
247 template <>
248 struct closure<gis::Geographic_linearring> {
249  static const closure_selector value = closed;
250 };
251 
252 // Polygon
253 
254 template <>
255 struct tag<gis::Geographic_polygon> {
256  typedef boost::geometry::polygon_tag type;
257 };
258 
259 template <>
260 struct ring_const_type<gis::Geographic_polygon> {
262 };
263 
264 template <>
265 struct ring_mutable_type<gis::Geographic_polygon> {
267 };
268 
269 template <>
270 struct interior_const_type<gis::Geographic_polygon> {
273 };
274 
275 template <>
276 struct interior_mutable_type<gis::Geographic_polygon> {
279 };
280 
281 template <>
282 struct 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 
293 template <>
294 struct 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 
311 template <>
312 struct tag<gis::Geographic_multipoint> {
313  typedef boost::geometry::multi_point_tag type;
314 };
315 
316 // Multilinestring
317 
318 template <>
319 struct tag<gis::Geographic_multilinestring> {
320  typedef boost::geometry::multi_linestring_tag type;
321 };
322 
323 // Multipolygon
324 
325 template <>
326 struct 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:274
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.
Cartesian_linearring & cartesian_exterior_ring() const
Get the exterior ring.
Definition: geometries.cc:209
A geographic (ellipsoidal) 2d linear ring.
Definition: geometries_cs.h:225
A geographic (ellipsoidal) 2d point.
Definition: geometries_cs.h:57
A geographic (ellipsoidal) 2d polygon.
Definition: geometries_cs.h:327
decltype(m_interior_rings) & interior_rings()
Get list of interior rings.
Geographic_linearring & geographic_exterior_ring() const
Get the exterior ring.
Definition: geometries.cc:254
decltype(m_interior_rings) const & const_interior_rings() const
Get list of interior rings.
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:583
Definition: area.cc:46
std::vector< T, ut_allocator< T > > vector
Specialization of vector which uses ut_allocator.
Definition: ut0new.h:1740
const string value("\"Value\"")
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 > > const & get(gis::Cartesian_polygon const &py)
Definition: geometries_traits.h:167
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::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