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