MySQL 9.1.0
Source Code Documentation
box.h
Go to the documentation of this file.
1#ifndef SQL_GIS_BOX_H_INCLUDED
2#define SQL_GIS_BOX_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 declares the Box class.
30///
31/// @see box_cs.h
32
33#include "sql/gis/geometries.h"
35
36namespace gis {
37
38/// A 2d box with sides parallel to the coordinate system grid.
39///
40/// Used by computations on minimum bounding boxes (MBRs).
41class Box {
42 public:
43 Box() = default;
44 Box(const Box &) = default;
45 Box(Box &&) = default;
46 Box &operator=(const Box &) = default;
47 Box &operator=(Box &&) = default;
48
49 virtual ~Box() = default;
50
51 /// Gets the coordinate system.
52 ///
53 /// @return The coordinate system type.
55
56 /// Returns the minimum corner.
57 ///
58 /// @return The minimum corner.
59 virtual Point const &min_corner() const = 0;
60 virtual Point &min_corner() = 0;
61
62 /// Returns the maximum corner.
63 ///
64 /// @return The maximum corner.
65 virtual Point const &max_corner() const = 0;
66 virtual Point &max_corner() = 0;
67};
68
69/// A Cartesian 2d box.
70class Cartesian_box : public Box {
71 private:
72 /// The corner with minimum X and Y values.
74 /// The corner with maximum X and Y values.
76
77 public:
78 Cartesian_box() = default;
83 }
84
85 /// Returns the minimum corner.
86 ///
87 /// @return The minimum corner.
88 Cartesian_point const &min_corner() const override { return m_min_corner; }
89 Cartesian_point &min_corner() override { return m_min_corner; }
90
91 /// Returns the maximum corner.
92 ///
93 /// @return The maximum corner.
94 Cartesian_point const &max_corner() const override { return m_max_corner; }
95 Cartesian_point &max_corner() override { return m_max_corner; }
96};
97
98/// A Geographic 2d box.
99///
100/// Unlike polygons, the sides of the box are not the shortest distance between
101/// the endpoints. A box side will follow the latitude line, while a linestring
102/// (or polygon segment) between the same points won't.
103class Geographic_box : public Box {
104 private:
105 /// The corner with minimum X and Y values.
107 /// The corner with maximum X and Y values.
109
110 public:
111 Geographic_box() = default;
116 }
117
118 /// Returns the minimum corner.
119 ///
120 /// @return The minimum corner.
121 Geographic_point const &min_corner() const override { return m_min_corner; }
123
124 /// Returns the maximum corner.
125 ///
126 /// @return The maximum corner.
127 Geographic_point const &max_corner() const override { return m_max_corner; }
129};
130
131} // namespace gis
132
133#endif // SQL_GIS_BOX_H_INCLUDED
A 2d box with sides parallel to the coordinate system grid.
Definition: box.h:41
virtual ~Box()=default
virtual Point const & max_corner() const =0
Returns the maximum corner.
Box(const Box &)=default
Box(Box &&)=default
virtual Point & min_corner()=0
Box & operator=(const Box &)=default
virtual Point const & min_corner() const =0
Returns the minimum corner.
virtual Coordinate_system coordinate_system() const =0
Gets the coordinate system.
virtual Point & max_corner()=0
Box & operator=(Box &&)=default
Box()=default
A Cartesian 2d box.
Definition: box.h:70
Cartesian_point const & min_corner() const override
Returns the minimum corner.
Definition: box.h:88
Cartesian_box(Cartesian_point &&min_corner, Cartesian_point &&max_corner)
Definition: box.h:79
Cartesian_point const & max_corner() const override
Returns the maximum corner.
Definition: box.h:94
Cartesian_point & min_corner() override
Definition: box.h:89
Cartesian_point m_max_corner
The corner with maximum X and Y values.
Definition: box.h:75
Coordinate_system coordinate_system() const override
Gets the coordinate system.
Definition: box.h:81
Cartesian_box()=default
Cartesian_point & max_corner() override
Definition: box.h:95
Cartesian_point m_min_corner
The corner with minimum X and Y values.
Definition: box.h:73
A Cartesian 2d point.
Definition: geometries_cs.h:47
A Geographic 2d box.
Definition: box.h:103
Geographic_box(Geographic_point &&min_corner, Geographic_point &&max_corner)
Definition: box.h:112
Geographic_point & max_corner() override
Definition: box.h:128
Geographic_point & min_corner() override
Definition: box.h:122
Geographic_point const & max_corner() const override
Returns the maximum corner.
Definition: box.h:127
Geographic_point m_min_corner
The corner with minimum X and Y values.
Definition: box.h:106
Geographic_box()=default
Geographic_point const & min_corner() const override
Returns the minimum corner.
Definition: box.h:121
Coordinate_system coordinate_system() const override
Gets the coordinate system.
Definition: box.h:114
Geographic_point m_max_corner
The corner with maximum X and Y values.
Definition: box.h:108
A geographic (ellipsoidal) 2d point.
Definition: geometries_cs.h:58
A 2d point.
Definition: geometries.h:150
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.
Definition: area.cc:47
Coordinate_system
Types of coordinate systems.
Definition: geometries.h:69
@ kCartesian
A Cartesian plane with the same unit in both directions.
@ kGeographic
An ellipsoidal system with longitude and latitude coordinates, both in the same unit.