GEOS 3.11.1
GeometryFixer.h
1/**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2021 Paul Ramsey <pramsey@cleverelephant.ca>
7 *
8 * This is free software; you can redistribute and/or modify it under
9 * the terms of the GNU Lesser General Public Licence as published
10 * by the Free Software Foundation.
11 * See the COPYING file for more information.
12 *
13 **********************************************************************/
14
15#pragma once
16
17#include <memory>
18#include <vector>
19
20#include <geos/geom/Geometry.h>
21#include <geos/export.h>
22
23// Forward declarations
24namespace geos {
25namespace geom {
26class GeometryFactory;
27class Point;
28class Polygon;
29class LineString;
30class LinearRing;
31class MultiPoint;
32class MultiPolygon;
33class MultiLineString;
34class GeometryCollection;
35}
36}
37
38namespace geos {
39namespace geom { // geos.geom
40namespace util { // geos.geom.util
41
74class GEOS_DLL GeometryFixer {
75
76private:
77
78 const geom::Geometry* geom;
79 const geom::GeometryFactory* factory;
80 bool isKeepCollapsed; // false
81
82public:
83
84 GeometryFixer(const geom::Geometry* p_geom)
85 : geom(p_geom)
86 , factory(p_geom->getFactory())
87 , isKeepCollapsed(false)
88 {};
89
90 static std::unique_ptr<geom::Geometry> fix(const geom::Geometry* geom);
91
100 void setKeepCollapsed(bool p_isKeepCollapsed);
101
107 std::unique_ptr<geom::Geometry> getResult() const;
108
109private:
110
111 std::unique_ptr<geom::Point> fixPoint(const geom::Point* geom) const;
112 std::unique_ptr<geom::Point> fixPointElement(const geom::Point* geom) const;
113 bool isValidPoint(const geom::Point* pt) const;
114 std::unique_ptr<geom::Geometry> fixMultiPoint(const geom::MultiPoint* geom) const;
115 std::unique_ptr<geom::Geometry> fixLinearRing(const geom::LinearRing* geom) const;
116 std::unique_ptr<geom::Geometry> fixLinearRingElement(const geom::LinearRing* geom) const;
117 std::unique_ptr<geom::Geometry> fixLineString(const geom::LineString* geom) const;
118 std::unique_ptr<geom::Geometry> fixLineStringElement(const geom::LineString* geom) const;
119
126 std::unique_ptr<geom::Geometry> fixMultiLineString(const MultiLineString* geom) const;
127 std::unique_ptr<geom::Geometry> fixPolygon(const geom::Polygon* geom) const;
128 std::unique_ptr<geom::Geometry> fixPolygonElement(const geom::Polygon* geom) const;
129 std::vector<std::unique_ptr<Geometry>> fixHoles(const geom::Polygon* geom) const;
130 std::unique_ptr<geom::Geometry> removeHoles(const geom::Geometry* shell, const geom::Geometry* holes) const;
131 std::unique_ptr<geom::Geometry> fixRing(const geom::LinearRing* ring) const;
132 std::unique_ptr<geom::Geometry> fixMultiPolygon(const geom::MultiPolygon* geom) const;
133 std::unique_ptr<geom::Geometry> fixCollection(const geom::GeometryCollection* geom) const;
134
135 void classifyHoles(
136 const Geometry* shell,
137 std::vector<std::unique_ptr<Geometry>>& holesFixed,
138 std::vector<const Geometry*>& holes,
139 std::vector<const Geometry*>& shells) const;
140
148 std::unique_ptr<Geometry> difference(
149 const Geometry* shell,
150 std::vector<const Geometry*>& holes) const;
151
160 std::unique_ptr<Geometry> unionGeometry(
161 std::vector<const Geometry*>& polys) const;
162
163};
164
165} // namespace geos.geom.util
166} // namespace geos.geom
167} // namespace geos
168
169
Represents a collection of heterogeneous Geometry objects.
Definition: GeometryCollection.h:52
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition: GeometryFactory.h:66
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:186
const GeometryFactory * getFactory() const
Gets the factory which contains the context in which this geometry was created.
Definition: Geometry.h:216
Definition: LineString.h:66
Models an OGC SFS LinearRing. A LinearRing is a LineString which is both closed and simple.
Definition: LinearRing.h:55
Models a collection of LineStrings.
Definition: MultiLineString.h:50
Definition: MultiPoint.h:51
Definition: MultiPolygon.h:59
Definition: Point.h:63
Represents a linear polygon, which may include holes.
Definition: Polygon.h:61
Definition: GeometryFixer.h:74
std::unique_ptr< geom::Geometry > getResult() const
void setKeepCollapsed(bool p_isKeepCollapsed)
Basic namespace for all GEOS functionalities.
Definition: geos.h:39