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>
119 CoverageRing* ringForward;
120 std::size_t indexForward;
121 CoverageRing* ringOpp;
122 std::size_t indexOpp;
126 CoverageRing* p_ring, std::size_t p_index)
128 , ringForward(
nullptr)
133 if (p_p1.compareTo(p_p0) < 0) {
139 ringForward = p_ring;
140 indexForward = p_index;
144 void match(
const CoverageRingSegment* seg) {
145 bool isInvalid = checkInvalid(seg);
150 if (ringForward ==
nullptr) {
151 ringForward = seg->ringForward;
152 indexForward = seg->indexForward;
155 ringOpp = seg->ringOpp;
156 indexOpp = seg->indexOpp;
159 ringForward->markMatched(indexForward);
160 ringOpp->markMatched(indexOpp);
163 bool checkInvalid(
const CoverageRingSegment* seg)
const {
164 if (ringForward !=
nullptr && seg->ringForward !=
nullptr) {
165 ringForward->markInvalid(indexForward);
166 seg->ringForward->markInvalid(seg->indexForward);
169 if (ringOpp !=
nullptr && seg->ringOpp !=
nullptr) {
170 ringOpp->markInvalid(indexOpp);
171 seg->ringOpp->markInvalid(seg->indexOpp);
177 struct CoverageRingSegHash {
179 operator() (CoverageRingSegment
const* s)
const {
180 std::size_t h = std::hash<double>{}(s->p0.x);
181 h ^= (std::hash<double>{}(s->p0.y) << 1);
182 h ^= (std::hash<double>{}(s->p1.x) << 1);
183 return h ^ (std::hash<double>{}(s->p1.y) << 1);
187 struct CoverageRingSegEq {
189 operator() (CoverageRingSegment
const* lhs, CoverageRingSegment
const* rhs)
const {
190 return lhs->p0.x == rhs->p0.x
191 && lhs->p0.y == rhs->p0.y
192 && lhs->p1.x == rhs->p1.x
193 && lhs->p1.y == rhs->p1.y;
201 std::vector<const Geometry*> adjGeoms;
204 double gapWidth = 0.0;
205 std::vector<std::unique_ptr<CoveragePolygon>> m_adjCovPolygons;
206 std::deque<CoverageRing> coverageRingStore;
207 std::vector<std::unique_ptr<CoordinateSequence>> localCoordinateSequences;
208 std::deque<CoverageRingSegment> coverageRingSegmentStore;
210 typedef std::unordered_map<CoverageRingSegment*, CoverageRingSegment*, CoverageRingSegment::CoverageRingSegHash, CoverageRingSegment::CoverageRingSegEq> CoverageRingSegmentMap;
228 std::vector<const Geometry*>& adjPolygons);
245 std::vector<const Geometry*>& adjPolygons,
260 std::vector<const Geometry*>& adjPolygons);
279 static std::vector<std::unique_ptr<CoveragePolygon>>
280 toCoveragePolygons(
const std::vector<const Polygon*> polygons);
281 static std::vector<const Polygon*> extractPolygons(std::vector<const Geometry*>& geoms);
284 std::unique_ptr<Geometry> createEmptyResult();
303 void markMatchedSegments(
304 std::vector<CoverageRing*>& targetRings,
305 std::vector<CoverageRing*>& adjRings,
317 void markMatchedSegments(
318 std::vector<CoverageRing*>& rings,
320 CoverageRingSegmentMap& segmentMap);
322 CoverageRingSegment* createCoverageRingSegment(
323 CoverageRing* ring, std::size_t index);
334 void markInvalidInteractingSegments(
335 std::vector<CoverageRing*>& targetRings,
336 std::vector<CoverageRing*>& adjRings,
337 double distanceTolerance);
346 void markInvalidInteriorSegments(
347 std::vector<CoverageRing*>& targetRings,
348 std::vector<std::unique_ptr<CoveragePolygon>>& adjCovPolygons);
350 void markInvalidInteriorSection(
354 std::vector<std::unique_ptr<CoveragePolygon>>& adjCovPolygons );
356 void markInvalidInteriorSegment(
357 CoverageRing& ring, std::size_t i, CoveragePolygon* adjPoly);
359 void checkTargetRings(
360 std::vector<CoverageRing*>& targetRings,
361 std::vector<CoverageRing*>& adjRngs,
364 std::unique_ptr<Geometry> createInvalidLines(std::vector<CoverageRing*>& rings);
366 std::vector<CoverageRing*> createRings(
const Geometry* geom);
368 std::vector<CoverageRing*> createRings(std::vector<const Polygon*>& polygons);
370 void createRings(
const Polygon* poly, std::vector<CoverageRing*>& rings);
375 std::vector<CoverageRing*>& rings);
377 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:92
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)
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:196
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:61
Basic namespace for all GEOS functionalities.
Definition: geos.h:38