GEOS 3.14.0dev
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
36namespace geos {
37namespace simplify { // geos::simplify
38
77{
84
85public:
86
96 PolygonHullSimplifier(const Geometry* geom, bool bOuter)
97 : inputGeom(geom)
98 , geomFactory(geom->getFactory())
99 , isOuter(bOuter)
100 , vertexNumFraction(-1.0)
101 , areaDeltaRatio(-1.0)
102 {
103 if (!geom->isPolygonal()) {
104 throw util::IllegalArgumentException("Input geometry must be polygonal");
105 }
106 };
107
121 static std::unique_ptr<Geometry> hull(
122 const Geometry* geom,
123 bool isOuter,
124 double vertexNumFraction);
125
139 static std::unique_ptr<Geometry> hullByAreaDelta(
140 const Geometry* geom,
141 bool isOuter,
142 double areaDeltaRatio);
143
144
152 void setVertexNumFraction(double p_vertexNumFraction);
159 void setAreaDeltaRatio(double p_areaDeltaRatio);
160
166 std::unique_ptr<Geometry> getResult();
167
168
169
170private:
171
172 // Members
173 const Geometry* inputGeom;
174 const GeometryFactory* geomFactory;
175 bool isOuter;
176 double vertexNumFraction;
177 double areaDeltaRatio;
178 // Allocate the RingHull* in here so they are cleaned
179 // up with PolygonHullSimplifier
180 std::vector<std::unique_ptr<RingHull>> ringStore;
181
189 std::unique_ptr<Geometry> computeMultiPolygonAll(const MultiPolygon* multiPoly);
190 std::unique_ptr<Geometry> computeMultiPolygonEach(const MultiPolygon* multiPoly);
191 std::unique_ptr<Polygon> computePolygon(const Polygon* poly);
192
201 std::vector<RingHull*> initPolygon(const Polygon* poly,
202 RingHullIndex& hullIndex);
203
204 double ringArea(const Polygon* poly) const;
205
206 RingHull* createRingHull(
207 const LinearRing* ring,
208 bool isOuter,
209 double areaTotal,
210 RingHullIndex& hullIndex);
211
212 std::unique_ptr<Polygon> polygonHull(
213 const Polygon* poly,
214 std::vector<RingHull*>& ringHulls,
215 RingHullIndex& hullIndex) const;
216
222 PolygonHullSimplifier& operator=(const PolygonHullSimplifier&) = delete;
223
224}; // PolygonHullSimplifier
225
226
227} // geos::simplify
228} // geos
229
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition Envelope.h:59
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition GeometryFactory.h:70
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition Geometry.h:197
Models an OGC SFS LinearRing. A LinearRing is a LineString which is both closed and simple.
Definition LinearRing.h:54
Definition MultiPolygon.h:58
Represents a linear polygon, which may include holes.
Definition Polygon.h:61
Definition PolygonHullSimplifier.h:77
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:96
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