MySQL 8.3.0
Source Code Documentation
box_traits.h
Go to the documentation of this file.
1#ifndef SQL_GIS_BOX_TRAITS_H_INCLUDED
2#define SQL_GIS_BOX_TRAITS_H_INCLUDED
3
4// Copyright (c) 2017, 2023, 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 boxes.
30///
31/// @see box.h
32
33#include <boost/geometry/geometries/concepts/box_concept.hpp>
34
35#include "sql/gis/box.h"
36#include "sql/gis/geometries.h"
38#include "sql/gis/geometries_traits.h" // To get fully defined traits.
39
40namespace boost {
41namespace geometry {
42namespace traits {
43
44////////////////////////////////////////////////////////////////////////////////
45
46// Cartesian
47
48template <>
49struct tag<gis::Cartesian_box> {
50 typedef box_tag type;
51};
52
53template <>
54struct point_type<gis::Cartesian_box> {
56};
57
58template <std::size_t Dimension>
59struct indexed_access<gis::Cartesian_box, min_corner, Dimension> {
60 static inline double get(gis::Cartesian_box const &b) {
61 return b.min_corner().get<Dimension>();
62 }
63
64 static inline void set(gis::Cartesian_box &b, double const &value) {
65 b.min_corner().set<Dimension>(value);
66 }
67};
68
69template <std::size_t Dimension>
70struct indexed_access<gis::Cartesian_box, max_corner, Dimension> {
71 static inline double get(gis::Cartesian_box const &b) {
72 return b.max_corner().get<Dimension>();
73 }
74
75 static inline void set(gis::Cartesian_box &b, double const &value) {
76 b.max_corner().set<Dimension>(value);
77 }
78};
79
80////////////////////////////////////////////////////////////////////////////////
81
82// Geographic
83
84template <>
85struct tag<gis::Geographic_box> {
86 typedef box_tag type;
87};
88
89template <>
90struct point_type<gis::Geographic_box> {
92};
93
94template <std::size_t Dimension>
95struct indexed_access<gis::Geographic_box, min_corner, Dimension> {
96 static inline double get(gis::Geographic_box const &b) {
97 return b.min_corner().get<Dimension>();
98 }
99
100 static inline void set(gis::Geographic_box &b, double const &value) {
101 b.min_corner().set<Dimension>(value);
102 }
103};
104
105template <std::size_t Dimension>
106struct indexed_access<gis::Geographic_box, max_corner, Dimension> {
107 static inline double get(gis::Geographic_box const &b) {
108 return b.max_corner().get<Dimension>();
109 }
110
111 static inline void set(gis::Geographic_box &b, double const &value) {
112 b.max_corner().set<Dimension>(value);
113 }
114};
115
116} // namespace traits
117} // namespace geometry
118} // namespace boost
119
120#endif // SQL_GIS_BOX_H_INCLUDED
This file declares the Box class.
A Cartesian 2d box.
Definition: box.h:69
Cartesian_point const & min_corner() const override
Returns the minimum corner.
Definition: box.h:87
Cartesian_point const & max_corner() const override
Returns the maximum corner.
Definition: box.h:93
A Cartesian 2d point.
Definition: geometries_cs.h:46
A Geographic 2d box.
Definition: box.h:102
Geographic_point const & max_corner() const override
Returns the maximum corner.
Definition: box.h:126
Geographic_point const & min_corner() const override
Returns the minimum corner.
Definition: box.h:120
A geographic (ellipsoidal) 2d point.
Definition: geometries_cs.h:57
void set(double d)
Sets a coordinate.
double get() const
Gets a coordinate value.
This file declares the geometry class hierarchy used by the server as the internal representation of ...
This file declares the coordinate system specific subclasses of the geometry class hierarchy.
This file contains Boost.Geometry type traits declarations for Cartesian and geographic geometries.
Tag dispatch for custom Role_properties.
Definition: sql_auth_cache.h:587
Definition: area.cc:46
static double get(gis::Cartesian_box const &b)
Definition: box_traits.h:71
static void set(gis::Cartesian_box &b, double const &value)
Definition: box_traits.h:75
static double get(gis::Cartesian_box const &b)
Definition: box_traits.h:60
static void set(gis::Cartesian_box &b, double const &value)
Definition: box_traits.h:64
static double get(gis::Geographic_box const &b)
Definition: box_traits.h:107
static void set(gis::Geographic_box &b, double const &value)
Definition: box_traits.h:111
static void set(gis::Geographic_box &b, double const &value)
Definition: box_traits.h:100
static double get(gis::Geographic_box const &b)
Definition: box_traits.h:96
gis::Cartesian_point type
Definition: box_traits.h:55
gis::Geographic_point type
Definition: box_traits.h:91
box_tag type
Definition: box_traits.h:50
box_tag type
Definition: box_traits.h:86