17#include <geos/noding/BasicSegmentString.h>
18#include <geos/geom/LineSegment.h>
19#include <geos/algorithm/locate/IndexedPointInAreaLocator.h>
20#include <geos/coverage/CoveragePolygon.h>
21#include <geos/coverage/CoverageRing.h>
23#include <unordered_map>
116 CoverageRing* ringForward;
117 std::size_t indexForward;
118 CoverageRing* ringOpp;
119 std::size_t indexOpp;
123 CoverageRing* p_ring, std::size_t p_index)
125 , ringForward(
nullptr)
130 if (p_p1.compareTo(p_p0) < 0) {
136 ringForward = p_ring;
137 indexForward = p_index;
141 void match(
const CoverageRingSegment* seg) {
142 bool isInvalid = checkInvalid(seg);
147 if (ringForward ==
nullptr) {
148 ringForward = seg->ringForward;
149 indexForward = seg->indexForward;
152 ringOpp = seg->ringOpp;
153 indexOpp = seg->indexOpp;
156 ringForward->markMatched(indexForward);
157 ringOpp->markMatched(indexOpp);
160 bool checkInvalid(
const CoverageRingSegment* seg)
const {
161 if (ringForward !=
nullptr && seg->ringForward !=
nullptr) {
162 ringForward->markInvalid(indexForward);
163 seg->ringForward->markInvalid(seg->indexForward);
166 if (ringOpp !=
nullptr && seg->ringOpp !=
nullptr) {
167 ringOpp->markInvalid(indexOpp);
168 seg->ringOpp->markInvalid(seg->indexOpp);
174 struct CoverageRingSegHash {
176 operator() (CoverageRingSegment
const* s)
const {
177 std::size_t h = std::hash<double>{}(s->p0.x);
178 h ^= (std::hash<double>{}(s->p0.y) << 1);
179 h ^= (std::hash<double>{}(s->p1.x) << 1);
180 return h ^ (std::hash<double>{}(s->p1.y) << 1);
184 struct CoverageRingSegEq {
186 operator() (CoverageRingSegment
const* lhs, CoverageRingSegment
const* rhs)
const {
187 return lhs->p0.x == rhs->p0.x
188 && lhs->p0.y == rhs->p0.y
189 && lhs->p1.x == rhs->p1.x
190 && lhs->p1.y == rhs->p1.y;
198 std::vector<const Geometry*> adjGeoms;
201 double gapWidth = 0.0;
202 std::vector<std::unique_ptr<CoveragePolygon>> m_adjCovPolygons;
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<std::unique_ptr<CoveragePolygon>>
277 toCoveragePolygons(
const std::vector<const Polygon*> polygons);
278 static std::vector<const Polygon*> extractPolygons(std::vector<const Geometry*>& geoms);
281 std::unique_ptr<Geometry> createEmptyResult();
300 void markMatchedSegments(
301 std::vector<CoverageRing*>& targetRings,
302 std::vector<CoverageRing*>& adjRings,
314 void markMatchedSegments(
315 std::vector<CoverageRing*>& rings,
317 CoverageRingSegmentMap& segmentMap);
319 CoverageRingSegment* createCoverageRingSegment(
320 CoverageRing* ring, std::size_t index);
331 void markInvalidInteractingSegments(
332 std::vector<CoverageRing*>& targetRings,
333 std::vector<CoverageRing*>& adjRings,
334 double distanceTolerance);
343 void markInvalidInteriorSegments(
344 std::vector<CoverageRing*>& targetRings,
345 std::vector<std::unique_ptr<CoveragePolygon>>& adjCovPolygons);
347 void markInvalidInteriorSection(
351 std::vector<std::unique_ptr<CoveragePolygon>>& adjCovPolygons );
353 void markInvalidInteriorSegment(
354 CoverageRing& ring, std::size_t i, CoveragePolygon* adjPoly);
356 void checkTargetRings(
357 std::vector<CoverageRing*>& targetRings,
358 std::vector<CoverageRing*>& adjRngs,
361 std::unique_ptr<Geometry> createInvalidLines(std::vector<CoverageRing*>& rings);
363 std::vector<CoverageRing*> createRings(
const Geometry* geom);
365 std::vector<CoverageRing*> createRings(std::vector<const Polygon*>& polygons);
367 void createRings(
const Polygon* poly, std::vector<CoverageRing*>& rings);
372 std::vector<CoverageRing*>& rings);
374 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:98
std::unique_ptr< Geometry > validate()
static std::unique_ptr< Geometry > validate(const Geometry *targetPolygon, std::vector< const Geometry * > &adjPolygons)
void setGapWidth(double p_gapWidth)
CoveragePolygonValidator(const Geometry *targetPolygon, std::vector< const Geometry * > &adjPolygons)
static std::unique_ptr< Geometry > validate(const Geometry *targetPolygon, std::vector< const Geometry * > &adjPolygons, double gapWidth)
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: geos.h:39