GEOS 3.13.1
TPVWSimplifier.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 <queue>
18
19#include <geos/index/strtree/TemplateSTRtree.h>
20#include <geos/index/VertexSequencePackedRtree.h>
21#include <geos/simplify/LinkedLine.h>
22#include <geos/coverage/Corner.h>
23#include <geos/export.h>
24
25
26namespace geos {
27namespace geom {
28class Coordinate;
30class Envelope;
31class Geometry;
32class GeometryFactory;
33class LineString;
34class MultiLineString;
35}
36}
37
38
39using geos::coverage::Corner;
48using geos::index::strtree::TemplateSTRtree;
49using geos::simplify::LinkedLine;
50
51
52namespace geos {
53namespace coverage { // geos::coverage
54
55
74class GEOS_DLL TPVWSimplifier
75{
76
77public:
78
79 // Prototype
80 class EdgeIndex;
81
82 /* private static */
83 class Edge {
84
85 public:
86
87 // Members
88 double areaTolerance;
89 bool isFreeRing;
90 const Envelope* envelope;
91 std::size_t nbPts;
92 LinkedLine linkedLine;
93 VertexSequencePackedRtree vertexIndex;
94 std::size_t minEdgeSize;
95
105 Edge(const LineString* p_inputLine, bool p_isFreeRing, double p_areaTolerance);
106
107 const Coordinate& getCoordinate(std::size_t index) const;
108
109 const Envelope* getEnvelopeInternal() const;
110
111 std::size_t size() const;
112
113 std::unique_ptr<CoordinateSequence> simplify(EdgeIndex& edgeIndex);
114
115 void createQueue(Corner::PriorityQueue& pq);
116
117 void addCorner(std::size_t i, Corner::PriorityQueue& cornerQueue);
118
119 bool isRemovable(Corner& corner, EdgeIndex& edgeIndex) const;
120
130 bool hasIntersectingVertex(const Corner& corner,
131 const Envelope& cornerEnv,
132 const Edge& edge) const;
133
134 std::vector<std::size_t> query(const Envelope& cornerEnv) const;
135
145 void removeCorner(
146 Corner& corner,
147 Corner::PriorityQueue& cornerQueue);
148
149 }; // Edge
150
151 class EdgeIndex
152 {
153 public:
154
155 TemplateSTRtree<const Edge*> index;
156
157 void add(std::vector<Edge>& edges);
158
159 std::vector<const Edge*> query(const Envelope& queryEnv);
160
161 }; // EdgeIndex
162
163
171 static std::unique_ptr<MultiLineString> simplify(
172 const MultiLineString* lines,
173 double distanceTolerance);
174
188 static std::unique_ptr<MultiLineString> simplify(
189 const MultiLineString* lines,
190 std::vector<bool>& freeRings,
191 const MultiLineString* constraintLines,
192 double distanceTolerance);
193
194 // Constructor
195 TPVWSimplifier(const MultiLineString* lines,
196 double distanceTolerance);
197
198
199private:
200
201 // Members
202 const MultiLineString* inputLines;
203 std::vector<bool> isFreeRing;
204 double areaTolerance;
205 const GeometryFactory* geomFactory;
206 const MultiLineString* constraintLines;
207
208
209 // Methods
210 void setFreeRingIndices(std::vector<bool>& freeRing);
211
212 void setConstraints(const MultiLineString* constraints);
213
214 std::unique_ptr<MultiLineString> simplify();
215
216 std::vector<Edge> createEdges(
217 const MultiLineString* lines,
218 std::vector<bool>& freeRing);
219
220
221}; // TPVWSimplifier
222
223
224} // geos::coverage
225} // geos
Definition TPVWSimplifier.h:75
static std::unique_ptr< MultiLineString > simplify(const MultiLineString *lines, double distanceTolerance)
static std::unique_ptr< MultiLineString > simplify(const MultiLineString *lines, std::vector< bool > &freeRings, const MultiLineString *constraintLines, double distanceTolerance)
The internal representation of a list of coordinates inside a Geometry.
Definition CoordinateSequence.h:56
Coordinate is the lightweight class used to store coordinates.
Definition Coordinate.h:217
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
Definition LineString.h:66
Models a collection of LineStrings.
Definition MultiLineString.h:49
Definition VertexSequencePackedRtree.h:54
Basic namespace for all GEOS functionalities.
Definition geos.h:39