MySQL 8.4.0
Source Code Documentation
gis_bg_traits.h
Go to the documentation of this file.
1#ifndef GIS_BG_TRAITS_INCLUDED
2#define GIS_BG_TRAITS_INCLUDED
3
4/* Copyright (c) 2014, 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
28/* This file defines all boost geometry traits. */
29
30#include <boost/concept/requires.hpp>
31#include <boost/geometry/core/access.hpp>
32#include <boost/geometry/core/closure.hpp>
33#include <boost/geometry/core/coordinate_dimension.hpp>
34#include <boost/geometry/core/coordinate_system.hpp>
35#include <boost/geometry/core/coordinate_type.hpp>
36#include <boost/geometry/core/cs.hpp>
37#include <boost/geometry/core/exterior_ring.hpp>
38#include <boost/geometry/core/interior_rings.hpp>
39#include <boost/geometry/core/interior_type.hpp>
40#include <boost/geometry/core/point_order.hpp>
41#include <boost/geometry/core/ring_type.hpp>
42#include <boost/geometry/core/tags.hpp>
43#include <boost/geometry/geometries/concepts/linestring_concept.hpp>
44#include <boost/geometry/geometries/concepts/point_concept.hpp>
45#include <boost/geometry/geometries/concepts/polygon_concept.hpp>
46#include <boost/geometry/multi/core/tags.hpp>
47#include <boost/geometry/util/math.hpp>
48#include <boost/static_assert.hpp>
49
50#include "sql/spatial.h"
51
52// Boost Geometry traits.
53namespace boost {
54namespace geometry {
55namespace traits {
56template <>
57struct tag<Gis_point> {
58 typedef boost::geometry::point_tag type;
59};
60
61template <>
62struct coordinate_type<Gis_point> {
63 typedef double type;
64};
65
66template <>
67struct coordinate_system<Gis_point> {
68 typedef boost::geometry::cs::cartesian type;
69};
70
71template <>
72struct dimension<Gis_point> : boost::mpl::int_<GEOM_DIM> {};
73
74template <std::size_t Dimension>
75struct access<Gis_point, Dimension> {
76 static inline double get(Gis_point const &p) { return p.get<Dimension>(); }
77
78 static inline void set(Gis_point &p, double const &value) {
79 p.set<Dimension>(value);
80 }
81};
82
83////////////////////////////////// LINESTRING ////////////////////////////
84template <>
85struct tag<Gis_line_string> {
86 typedef boost::geometry::linestring_tag type;
87};
88
89////////////////////////////////// POLYGON //////////////////////////////////
90
91template <>
92struct tag<Gis_polygon> {
93 typedef boost::geometry::polygon_tag type;
94};
95
96template <>
97struct ring_const_type<Gis_polygon> {
99};
100
101template <>
102struct ring_mutable_type<Gis_polygon> {
104};
105
106template <>
107struct interior_const_type<Gis_polygon> {
109};
110
111template <>
112struct interior_mutable_type<Gis_polygon> {
114};
115
116template <>
117struct exterior_ring<Gis_polygon> {
119
121 return p.outer();
122 }
123
124 static inline polygon_type::ring_type const &get(polygon_type const &p) {
125 return p.outer();
126 }
127};
128
129template <>
130struct interior_rings<Gis_polygon> {
132
134 return p.inners();
135 }
136
138 polygon_type const &p) {
139 return p.inners();
140 }
141};
142
143////////////////////////////////// RING //////////////////////////////////
144template <>
145struct point_order<Gis_polygon_ring> {
146 static const order_selector value = counterclockwise;
147};
148
149template <>
150struct closure<Gis_polygon_ring> {
151 static const closure_selector value = closed;
152};
153
154template <>
155struct tag<Gis_polygon_ring> {
156 typedef boost::geometry::ring_tag type;
157};
158
159////////////////////////////////// MULTI GEOMETRIES /////////////////////////
160
161/////////////////////////////////// multi linestring types /////////////////////
162template <>
164 typedef boost::geometry::multi_linestring_tag type;
165};
166
167/////////////////////////////////// multi point types /////////////////////
168
169template <>
170struct tag<Gis_multi_point> {
171 typedef boost::geometry::multi_point_tag type;
172};
173
174/////////////////////////////////// multi polygon types /////////////////////
175template <>
176struct tag<Gis_multi_polygon> {
177 typedef boost::geometry::multi_polygon_tag type;
178};
179
180} // namespace traits
181
182} // namespace geometry
183} // namespace boost
184
185#endif // !GIS_BG_TRAITS_INCLUDED
Definition: spatial.h:2099
Definition: spatial.h:2333
Definition: spatial.h:2290
Definition: spatial.h:2373
Definition: spatial.h:1152
Definition: spatial.h:2152
Definition: spatial.h:2187
Gis_wkb_vector class template definition.
Definition: spatial.h:1902
const char * p
Definition: ctype-mb.cc:1235
Tag dispatch for custom Role_properties.
Definition: sql_auth_cache.h:588
static void set(Gis_point &p, double const &value)
Definition: gis_bg_traits.h:78
static double get(Gis_point const &p)
Definition: gis_bg_traits.h:76
boost::geometry::cs::cartesian type
Definition: gis_bg_traits.h:68
double type
Definition: gis_bg_traits.h:63
static polygon_type::ring_type & get(polygon_type &p)
Definition: gis_bg_traits.h:120
static polygon_type::ring_type const & get(polygon_type const &p)
Definition: gis_bg_traits.h:124
Gis_polygon polygon_type
Definition: gis_bg_traits.h:118
Gis_polygon::inner_container_type const & type
Definition: gis_bg_traits.h:108
Gis_polygon::inner_container_type & type
Definition: gis_bg_traits.h:113
static polygon_type::inner_container_type const & get(polygon_type const &p)
Definition: gis_bg_traits.h:137
static polygon_type::inner_container_type & get(polygon_type &p)
Definition: gis_bg_traits.h:133
Gis_polygon polygon_type
Definition: gis_bg_traits.h:131
Gis_polygon::ring_type const & type
Definition: gis_bg_traits.h:98
Gis_polygon::ring_type & type
Definition: gis_bg_traits.h:103
boost::geometry::linestring_tag type
Definition: gis_bg_traits.h:86
boost::geometry::multi_linestring_tag type
Definition: gis_bg_traits.h:164
boost::geometry::multi_point_tag type
Definition: gis_bg_traits.h:171
boost::geometry::multi_polygon_tag type
Definition: gis_bg_traits.h:177
boost::geometry::point_tag type
Definition: gis_bg_traits.h:58
boost::geometry::polygon_tag type
Definition: gis_bg_traits.h:93
boost::geometry::ring_tag type
Definition: gis_bg_traits.h:156