GEOS 3.11.1
PolygonHullSimplifier.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 <geos/geom/Geometry.h>
18#include <geos/util/IllegalArgumentException.h>
19#include <geos/simplify/RingHull.h>
20
21
22namespace geos {
23namespace geom {
24class GeometryFactory;
25class LinearRing;
26class MultiPolygon;
27class Polygon;
28}
29namespace algorithm {
30namespace hull {
31class RingHullIndex;
32}
33}
34}
35
36
43
44
45namespace geos {
46namespace simplify { // geos::simplify
47
86{
87
88public:
89
99 PolygonHullSimplifier(const Geometry* geom, bool bOuter)
100 : inputGeom(geom)
101 , geomFactory(geom->getFactory())
102 , isOuter(bOuter)
103 , vertexNumFraction(-1.0)
104 , areaDeltaRatio(-1.0)
105 {
106 if (!geom->isPolygonal()) {
107 throw util::IllegalArgumentException("Input geometry must be polygonal");
108 }
109 };
110
124 static std::unique_ptr<Geometry> hull(
125 const Geometry* geom,
126 bool isOuter,
127 double vertexNumFraction);
128
142 static std::unique_ptr<Geometry> hullByAreaDelta(
143 const Geometry* geom,
144 bool isOuter,
145 double areaDeltaRatio);
146
147
155 void setVertexNumFraction(double p_vertexNumFraction);
162 void setAreaDeltaRatio(double p_areaDeltaRatio);
163
169 std::unique_ptr<Geometry> getResult();
170
171
172
173private:
174
175 // Members
176 const Geometry* inputGeom;
177 const GeometryFactory* geomFactory;
178 bool isOuter;
179 double vertexNumFraction;
180 double areaDeltaRatio;
181 // Allocate the RingHull* in here so they are cleaned
182 // up with PolygonHullSimplifier
183 std::vector<std::unique_ptr<RingHull>> ringStore;
184
192 std::unique_ptr<Geometry> computeMultiPolygonAll(const MultiPolygon* multiPoly);
193 std::unique_ptr<Geometry> computeMultiPolygonEach(const MultiPolygon* multiPoly);
194 std::unique_ptr<Polygon> computePolygon(const Polygon* poly);
195
204 std::vector<RingHull*> initPolygon(const Polygon* poly,
205 RingHullIndex& hullIndex);
206
207 double ringArea(const Polygon* poly) const;
208
209 RingHull* createRingHull(
210 const LinearRing* ring,
211 bool isOuter,
212 double areaTotal,
213 RingHullIndex& hullIndex);
214
215 std::unique_ptr<Polygon> polygonHull(
216 const Polygon* poly,
217 std::vector<RingHull*>& ringHulls,
218 RingHullIndex& hullIndex) const;
219
225 PolygonHullSimplifier& operator=(const PolygonHullSimplifier&) = delete;
226
227}; // PolygonHullSimplifier
228
229
230} // geos::simplify
231} // geos
232
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition: Envelope.h:58
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
Models an OGC SFS LinearRing. A LinearRing is a LineString which is both closed and simple.
Definition: LinearRing.h:55
Definition: MultiPolygon.h:59
Represents a linear polygon, which may include holes.
Definition: Polygon.h:61
Definition: PolygonHullSimplifier.h:86
static std::unique_ptr< Geometry > hull(const Geometry *geom, bool isOuter, double vertexNumFraction)
void setAreaDeltaRatio(double p_areaDeltaRatio)
std::unique_ptr< Geometry > getResult()
PolygonHullSimplifier(const Geometry *geom, bool bOuter)
Definition: PolygonHullSimplifier.h:99
void setVertexNumFraction(double p_vertexNumFraction)
static std::unique_ptr< Geometry > hullByAreaDelta(const Geometry *geom, bool isOuter, double areaDeltaRatio)
Indicates one or more illegal arguments.
Definition: IllegalArgumentException.h:33
Basic namespace for all GEOS functionalities.
Definition: geos.h:39