17 #include <geos/noding/BasicSegmentString.h>
18 #include <geos/geom/LineSegment.h>
19 #include <geos/algorithm/locate/IndexedPointInAreaLocator.h>
20 #include <geos/coverage/CoverageRing.h>
22 #include <unordered_map>
115 CoverageRing* ringForward;
116 std::size_t indexForward;
117 CoverageRing* ringOpp;
118 std::size_t indexOpp;
122 CoverageRing* p_ring, std::size_t p_index)
124 , ringForward(
nullptr)
129 if (p_p1.compareTo(p_p0) < 0) {
135 ringForward = p_ring;
136 indexForward = p_index;
140 void match(
const CoverageRingSegment* seg) {
141 bool isInvalid = checkInvalid(seg);
146 if (ringForward ==
nullptr) {
147 ringForward = seg->ringForward;
148 indexForward = seg->indexForward;
151 ringOpp = seg->ringOpp;
152 indexOpp = seg->indexOpp;
155 ringForward->markMatched(indexForward);
156 ringOpp->markMatched(indexOpp);
159 bool checkInvalid(
const CoverageRingSegment* seg)
const {
160 if (ringForward !=
nullptr && seg->ringForward !=
nullptr) {
161 ringForward->markInvalid(indexForward);
162 seg->ringForward->markInvalid(seg->indexForward);
165 if (ringOpp !=
nullptr && seg->ringOpp !=
nullptr) {
166 ringOpp->markInvalid(indexOpp);
167 seg->ringOpp->markInvalid(seg->indexOpp);
173 struct CoverageRingSegHash {
175 operator() (CoverageRingSegment
const* s)
const {
176 std::size_t h = std::hash<double>{}(s->p0.x);
177 h ^= (std::hash<double>{}(s->p0.y) << 1);
178 h ^= (std::hash<double>{}(s->p1.x) << 1);
179 return h ^ (std::hash<double>{}(s->p1.y) << 1);
183 struct CoverageRingSegEq {
185 operator() (CoverageRingSegment
const* lhs, CoverageRingSegment
const* rhs)
const {
186 return lhs->p0.x == rhs->p0.x
187 && lhs->p0.y == rhs->p0.y
188 && lhs->p1.x == rhs->p1.x
189 && lhs->p1.y == rhs->p1.y;
197 std::vector<const Geometry*> adjGeoms;
198 std::vector<const Polygon*> m_adjPolygons;
200 double gapWidth = 0.0;
201 std::map<std::size_t, std::unique_ptr<IndexedPointInAreaLocator>> adjPolygonLocators;
203 std::deque<CoverageRing> coverageRingStore;
204 std::vector<std::unique_ptr<CoordinateSequence>> localCoordinateSequences;
205 std::deque<CoverageRingSegment> coverageRingSegmentStore;
207 typedef std::unordered_map<CoverageRingSegment*, CoverageRingSegment*, CoverageRingSegment::CoverageRingSegHash, CoverageRingSegment::CoverageRingSegEq> CoverageRingSegmentMap;
225 std::vector<const Geometry*>& adjPolygons);
242 std::vector<const Geometry*>& adjPolygons,
257 std::vector<const Geometry*>& adjPolygons);
276 static std::vector<const Polygon*> extractPolygons(std::vector<const Geometry*>& geoms);
279 std::unique_ptr<Geometry> createEmptyResult();
298 void markMatchedSegments(
299 std::vector<CoverageRing*>& targetRings,
300 std::vector<CoverageRing*>& adjRings,
312 void markMatchedSegments(
313 std::vector<CoverageRing*>& rings,
315 CoverageRingSegmentMap& segmentMap);
317 CoverageRingSegment* createCoverageRingSegment(
318 CoverageRing* ring, std::size_t index);
329 void markInvalidInteractingSegments(
330 std::vector<CoverageRing*>& targetRings,
331 std::vector<CoverageRing*>& adjRings,
332 double distanceTolerance);
341 void markInvalidInteriorSegments(
342 std::vector<CoverageRing*>& targetRings,
343 std::vector<const Polygon*>& adjPolygons);
345 void checkTargetRings(
346 std::vector<CoverageRing*>& targetRings,
347 std::vector<CoverageRing*>& adjRngs,
359 std::vector<const Polygon*>& adjPolygons);
362 bool polygonContainsPoint(std::size_t index,
367 std::unique_ptr<Geometry> createInvalidLines(std::vector<CoverageRing*>& rings);
369 std::vector<CoverageRing*> createRings(
const Geometry* geom);
371 std::vector<CoverageRing*> createRings(std::vector<const Polygon*>& polygons);
373 void createRings(
const Polygon* poly, std::vector<CoverageRing*>& rings);
378 std::vector<CoverageRing*>& rings);
380 CoverageRing* createRing(
const LinearRing* ring,
bool isShell);
Determines the location of Coordinates relative to an areal geometry, using indexing for efficiency.
Definition: IndexedPointInAreaLocator.h:54
Definition: CoveragePolygonValidator.h:97
std::unique_ptr< Geometry > validate()
static std::unique_ptr< Geometry > validate(const Geometry *targetPolygon, std::vector< const Geometry * > &adjPolygons, double gapWidth)
void setGapWidth(double p_gapWidth)
static std::unique_ptr< Geometry > validate(const Geometry *targetPolygon, std::vector< const Geometry * > &adjPolygons)
CoveragePolygonValidator(const Geometry *targetPolygon, std::vector< const Geometry * > &adjPolygons)
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:216
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:65
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:186
Definition: LineSegment.h:61
Models an OGC SFS LinearRing. A LinearRing is a LineString which is both closed and simple.
Definition: LinearRing.h:54
Represents a linear polygon, which may include holes.
Definition: Polygon.h:60
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25