MySQL 9.1.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, 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/// @file
28///
29/// This file contains Boost.Geometry type traits declarations for Cartesian and
30/// geographic boxes.
31///
32/// @see box.h
33
34#include <boost/geometry/geometries/concepts/box_concept.hpp>
35
36#include "sql/gis/box.h"
37#include "sql/gis/geometries.h"
39#include "sql/gis/geometries_traits.h" // To get fully defined traits.
40
41namespace boost {
42namespace geometry {
43namespace traits {
44
45////////////////////////////////////////////////////////////////////////////////
46
47// Cartesian
48
49template <>
50struct tag<gis::Cartesian_box> {
51 typedef box_tag type;
52};
53
54template <>
55struct point_type<gis::Cartesian_box> {
57};
58
59template <std::size_t Dimension>
60struct indexed_access<gis::Cartesian_box, min_corner, Dimension> {
61 static inline double get(gis::Cartesian_box const &b) {
62 return b.min_corner().get<Dimension>();
63 }
64
65 static inline void set(gis::Cartesian_box &b, double const &value) {
66 b.min_corner().set<Dimension>(value);
67 }
68};
69
70template <std::size_t Dimension>
71struct indexed_access<gis::Cartesian_box, max_corner, Dimension> {
72 static inline double get(gis::Cartesian_box const &b) {
73 return b.max_corner().get<Dimension>();
74 }
75
76 static inline void set(gis::Cartesian_box &b, double const &value) {
77 b.max_corner().set<Dimension>(value);
78 }
79};
80
81////////////////////////////////////////////////////////////////////////////////
82
83// Geographic
84
85template <>
86struct tag<gis::Geographic_box> {
87 typedef box_tag type;
88};
89
90template <>
91struct point_type<gis::Geographic_box> {
93};
94
95template <std::size_t Dimension>
96struct indexed_access<gis::Geographic_box, min_corner, Dimension> {
97 static inline double get(gis::Geographic_box const &b) {
98 return b.min_corner().get<Dimension>();
99 }
100
101 static inline void set(gis::Geographic_box &b, double const &value) {
102 b.min_corner().set<Dimension>(value);
103 }
104};
105
106template <std::size_t Dimension>
107struct indexed_access<gis::Geographic_box, max_corner, Dimension> {
108 static inline double get(gis::Geographic_box const &b) {
109 return b.max_corner().get<Dimension>();
110 }
111
112 static inline void set(gis::Geographic_box &b, double const &value) {
113 b.max_corner().set<Dimension>(value);
114 }
115};
116
117} // namespace traits
118} // namespace geometry
119} // namespace boost
120
121#endif // SQL_GIS_BOX_H_INCLUDED
This file declares the Box class.
A Cartesian 2d box.
Definition: box.h:70
Cartesian_point const & min_corner() const override
Returns the minimum corner.
Definition: box.h:88
Cartesian_point const & max_corner() const override
Returns the maximum corner.
Definition: box.h:94
A Cartesian 2d point.
Definition: geometries_cs.h:47
A Geographic 2d box.
Definition: box.h:103
Geographic_point const & max_corner() const override
Returns the maximum corner.
Definition: box.h:127
Geographic_point const & min_corner() const override
Returns the minimum corner.
Definition: box.h:121
A geographic (ellipsoidal) 2d point.
Definition: geometries_cs.h:58
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:591
Definition: area.cc:47
static double get(gis::Cartesian_box const &b)
Definition: box_traits.h:72
static void set(gis::Cartesian_box &b, double const &value)
Definition: box_traits.h:76
static double get(gis::Cartesian_box const &b)
Definition: box_traits.h:61
static void set(gis::Cartesian_box &b, double const &value)
Definition: box_traits.h:65
static double get(gis::Geographic_box const &b)
Definition: box_traits.h:108
static void set(gis::Geographic_box &b, double const &value)
Definition: box_traits.h:112
static void set(gis::Geographic_box &b, double const &value)
Definition: box_traits.h:101
static double get(gis::Geographic_box const &b)
Definition: box_traits.h:97
gis::Cartesian_point type
Definition: box_traits.h:56
gis::Geographic_point type
Definition: box_traits.h:92
box_tag type
Definition: box_traits.h:51
box_tag type
Definition: box_traits.h:87