MySQL 8.0.39
Source Code Documentation
mbr_utils.h
Go to the documentation of this file.
1#ifndef SQL_GIS_MBR_UTILS_H_INCLUDED
2#define SQL_GIS_MBR_UTILS_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 interface of various utility functions for
30/// geometrycollections. The functions may throw exceptions.
31
32#include <boost/geometry.hpp>
33
34#include "sql/gis/box.h"
35#include "sql/gis/geometries.h"
37
38namespace dd {
39class Spatial_reference_system;
40} // namespace dd
41
42namespace gis {
43
44/// Checks if two MBRs are equal.
45///
46/// Empty boxes are considered equal.
47///
48/// @param[in] mbr1 First MBR.
49/// @param[in] mbr2 Second MBR.
50/// @retval true The MBRs are equal.
51/// @retval false The MBRs are not equal.
52bool mbrs_are_equal(Box const &mbr1, Box const &mbr2);
53
54/// Checks if an MBR is empty.
55///
56/// By default, BG box coordinates are NaN. If a geometry is empty, its box will
57/// have all NaN coordinates.
58///
59/// @param[in] mbr MBR to check.
60/// @retval true The MBR is empty.
61/// @retval false The MBR is not empty.
62bool mbr_is_empty(Box const &mbr);
63
64/// Checks if an MBR represents a point.
65///
66/// Boxes around points collapse so that min_corner == max_corner.
67///
68/// @param[in] mbr MBR to check.
69/// @retval true The MBR is a point.
70/// @retval false The MBR is not a point.
71bool mbr_is_point(Box const &mbr);
72
73/// Checks if an MBR represents a line.
74///
75/// Boxes around vertical and horizontal lines collapse so that either the
76/// minimum and maximum X coordinate or Y coordinate are equal.
77///
78/// @param[in] mbr MBR to check.
79/// @retval true The MBR is a line.
80/// @retval false The MBR is not a line.
81bool mbr_is_line(Box const &mbr);
82
83/// Computes the envelope of a geometry.
84///
85/// The result may be a collapsed MBR.
86///
87/// @param[in] g The geometry.
88/// @param[in] srs The spatial reference system of the geometry.
89/// @param[out] mbr The envelope.
90void box_envelope(const Geometry *g, const dd::Spatial_reference_system *srs,
91 Box *mbr);
92
93} // namespace gis
94
95#endif // SQL_GIS_MBR_UTILS_H_INCLUDED
This file declares the Box class.
Definition: spatial.h:213
Definition: spatial_reference_system.h:53
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.
The version of the current data dictionary table definitions.
Definition: dictionary_client.h:43
Definition: area.cc:47
bool mbr_is_line(Box const &mbr)
Checks if an MBR represents a line.
Definition: mbr_utils.cc:71
bool mbr_is_point(Box const &mbr)
Checks if an MBR represents a point.
Definition: mbr_utils.cc:66
bool mbrs_are_equal(Box const &mbr1, Box const &mbr2)
Checks if two MBRs are equal.
Definition: mbr_utils.cc:47
bool mbr_is_empty(Box const &mbr)
Checks if an MBR is empty.
Definition: mbr_utils.cc:61
void box_envelope(const Geometry *g, const dd::Spatial_reference_system *srs, Box *mbr)
Computes the envelope of a geometry.
Definition: mbr_utils.cc:268