MySQL 8.3.0
Source Code Documentation
gc_utils.h
Go to the documentation of this file.
1#ifndef SQL_GIS_GC_UTILS_H_INCLUDED
2#define SQL_GIS_GC_UTILS_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 declares the interface of various utility functions for
29/// geometrycollections. The functions may throw exceptions.
30
31#include <memory> // std::unique_ptr
32
33#include "sql/dd/types/spatial_reference_system.h" // dd::Spatial_reference_system
35#include "sql/gis/geometries.h"
37
38namespace gis {
39
40/// Invalid geometry exception.
41///
42/// Thrown when it is discovered that at an input parameter contains an invalid
43/// geometry.
44class invalid_geometry_exception : public std::exception {};
45
46/// Too large polygon exception.
47///
48/// Thrown when it is discovered that at a polygon covers half the globe or
49/// more. Boost Geometry doesn't handle such polygons.
50class too_large_polygon_exception : public std::exception {};
51
52/// Splits a geometrycollection into points, linestrings and polygons.
53///
54/// All output collections may contain overlapping geometries and
55/// duplicates. This is not a problem for the multipoint and multilinestring
56/// outputs, but the multipolygon may be geometrically invalid.
57///
58/// @param[in] gc Geometry collection.
59/// @param[out] mpt All points in the geometrycollection.
60/// @param[out] mls All linestrings in the geometrycollection.
61/// @param[out] mpy All polygons in the geometrycollection.
62void split_gc(const Geometrycollection *gc, std::unique_ptr<Multipoint> *mpt,
63 std::unique_ptr<Multilinestring> *mls,
64 std::unique_ptr<Multipolygon> *mpy);
65
66/// Cleans up overlapping geometries so that the geometrycollection is broken
67/// down into non-overlapping collections.
68///
69/// All input collections may contain overlapping geometries and
70/// duplicates, including the multipolygon. This function requires that at least
71/// one of the inputs must be non-empty.
72///
73/// May throw exceptions from BG operations.
74///
75/// @param[in] semi_major Semi-major axis of ellipsoid.
76/// @param[in] semi_minor Semi-minor axis of ellipsoid.
77/// @param[in,out] mpt All points in the geometrycollection.
78/// @param[in,out] mls All linestrings in the geometrycollection.
79/// @param[in,out] mpy All polygons in the geometrycollection.
80void gc_union(double semi_major, double semi_minor,
81 std::unique_ptr<Multipoint> *mpt,
82 std::unique_ptr<Multilinestring> *mls,
83 std::unique_ptr<Multipolygon> *mpy);
84
85/// Narrows down a geometrycollection to return a Multipoint, Multilinestring
86/// or a Multipolygon if the first level of the geometrycollection contains
87/// only points, linestrings or polygons. Otherwise, if the contents is
88/// heterogeneous or contains a geometrycollection, returns the input
89/// geometrycollection.
90///
91/// @param[in] geometrycollection Geometrycollection to be narroweed down.
92/// @return The narrowest type that can contain all the geometries in the input.
93std::unique_ptr<gis::Geometrycollection> narrowest_multigeometry(
94 std::unique_ptr<Geometrycollection> geometrycollection);
95} // namespace gis
96
97#endif // SQL_GIS_GC_UTILS_H_INCLUDED
A collection of geometries.
Definition: geometries.h:409
Invalid geometry exception.
Definition: gc_utils.h:44
Too large polygon exception.
Definition: gc_utils.h:50
This file declares the difference functor interface.
This file declares the geometry class hierarchy used by the server as the internal representation of ...
Definition: area.cc:46
std::unique_ptr< gis::Geometrycollection > narrowest_multigeometry(std::unique_ptr< gis::Geometrycollection > geometrycollection)
Narrows down a geometrycollection to return a Multipoint, Multilinestring or a Multipolygon if the fi...
Definition: gc_utils.cc:212
void gc_union(double semi_major, double semi_minor, std::unique_ptr< Multipoint > *mpt, std::unique_ptr< Multilinestring > *mls, std::unique_ptr< Multipolygon > *mpy)
Cleans up overlapping geometries so that the geometrycollection is broken down into non-overlapping c...
Definition: gc_utils.cc:177
void split_gc(const Geometrycollection *gc, std::unique_ptr< Multipoint > *mpt, std::unique_ptr< Multilinestring > *mls, std::unique_ptr< Multipolygon > *mpy)
Splits a geometrycollection into points, linestrings and polygons.
Definition: gc_utils.cc:91
This file declares the union functor interface.