GEOS 3.13.1
CoverageRingEdges.h
1/**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2023 Paul Ramsey <pramsey@cleverelephant.ca>
7 * Copyright (c) 2023 Martin Davis.
8 *
9 * This is free software; you can redistribute and/or modify it under
10 * the terms of the GNU Lesser General Public Licence as published
11 * by the Free Software Foundation.
12 * See the COPYING file for more information.
13 *
14 **********************************************************************/
15
16#pragma once
17
18#include <geos/geom/Coordinate.h>
19#include <geos/geom/LineSegment.h>
20#include <geos/coverage/CoverageEdge.h> // to materialize CoverageEdge
21
22#include <set>
23#include <map>
24
25// Forward declarations
26namespace geos {
27namespace geom {
29class Geometry;
30class LinearRing;
31class MultiPolygon;
32class Polygon;
33}
34namespace coverage {
35class CoverageEdge;
36}
37}
38
46
47namespace geos { // geos
48namespace coverage { // geos.coverage
49
60class GEOS_DLL CoverageRingEdges {
61
62private:
63
64 // Members
65 const std::vector<const Geometry*>& m_coverage;
66 std::map<const LinearRing*, std::vector<CoverageEdge*>> m_ringEdgesMap;
67 std::vector<CoverageEdge*> m_edges;
68 std::vector<std::unique_ptr<CoverageEdge>> m_edgeStore;
69
70 /* Turn off copy constructors for MSVC */
71 CoverageRingEdges(const CoverageRingEdges&) = delete;
72 CoverageRingEdges& operator=(const CoverageRingEdges&) = delete;
73
74public:
75
76 CoverageRingEdges(const std::vector<const Geometry*>& coverage)
77 : m_coverage(coverage)
78 {
79 build();
80 };
81
82
83 std::vector<CoverageEdge*>& getEdges()
84 {
85 return m_edges;
86 };
87
94 std::vector<CoverageEdge*> selectEdges(
95 std::size_t ringCount) const;
96
102 std::vector<std::unique_ptr<Geometry>> buildCoverage() const;
103
104
105private:
106
107 void build();
108
109 void addRingEdges(
110 const LinearRing* ring,
111 Coordinate::UnorderedSet& nodes,
112 LineSegment::UnorderedSet& boundarySegs,
113 std::map<LineSegment, CoverageEdge*>& uniqueEdgeMap);
114
115 void addBoundaryInnerNodes(
116 const LinearRing* ring,
117 LineSegment::UnorderedSet& boundarySegs,
118 Coordinate::UnorderedSet& nodes);
119
120 std::vector<CoverageEdge*> extractRingEdges(
121 const LinearRing* ring,
122 std::map<LineSegment, CoverageEdge*>& uniqueEdgeMap,
123 Coordinate::UnorderedSet& nodes);
124
125 CoverageEdge* createEdge(
126 const CoordinateSequence& ring,
127 std::map<LineSegment, CoverageEdge*>& uniqueEdgeMap);
128
129 CoverageEdge* createEdge(
130 const CoordinateSequence& ring,
131 std::size_t start, std::size_t end,
132 std::map<LineSegment, CoverageEdge*>& uniqueEdgeMap);
133
134 std::size_t findNextNodeIndex(
135 const CoordinateSequence& ring,
136 std::size_t start,
137 Coordinate::UnorderedSet& nodes) const;
138
139 static std::size_t next(
140 std::size_t index,
141 const CoordinateSequence& ring);
142
143 Coordinate::UnorderedSet findMultiRingNodes(
144 const std::vector<const Geometry*>& coverage);
145
146 Coordinate::UnorderedSet findBoundaryNodes(
147 LineSegment::UnorderedSet& lineSegments);
148
149 std::unique_ptr<Geometry> buildPolygonal(
150 const Geometry* geom) const;
151
152 std::unique_ptr<Geometry> buildMultiPolygon(
153 const MultiPolygon* geom) const;
154
155 std::unique_ptr<Polygon> buildPolygon(
156 const Polygon* polygon) const;
157
158 std::unique_ptr<LinearRing> buildRing(
159 const LinearRing* ring) const;
160
161 bool isEdgeDirForward(
162 const std::vector<CoverageEdge*>& ringEdges,
163 std::size_t index,
164 const Coordinate& prevPt) const;
165
166
167};
168
169} // namespace geos.coverage
170} // namespace geos
Definition CoverageEdge.h:54
Definition CoverageRingEdges.h:60
std::vector< std::unique_ptr< Geometry > > buildCoverage() const
std::vector< CoverageEdge * > selectEdges(std::size_t ringCount) const
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
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition Geometry.h:197
Definition LineSegment.h:61
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
Basic namespace for all GEOS functionalities.
Definition geos.h:39