PolygonTopologyAnalyzer.h
/**********************************************************************
*
* GEOS - Geometry Engine Open Source
* http://geos.osgeo.org
*
* Copyright (C) 2021 Paul Ramsey <pramsey@cleverelephant.ca>
* Copyright (C) 2021 Martin Davis
*
* This is free software; you can redistribute and/or modify it under
* the terms of the GNU Lesser General Public Licence as published
* by the Free Software Foundation.
* See the COPYING file for more information.
*
**********************************************************************/
#pragma once
#include <geos/export.h>
#include <geos/geom/Coordinate.h>
#include <geos/operation/valid/PolygonIntersectionAnalyzer.h>
#include <geos/operation/valid/PolygonRing.h>
#include <geos/noding/BasicSegmentString.h>
#include <memory>
// Forward declarations
namespace geos {
namespace geom {
class Geometry;
}
}
namespace geos { // geos.
namespace operation { // geos.operation
namespace valid { // geos.operation.valid
class GEOS_DLL PolygonTopologyAnalyzer {
using CoordinateXY = geos::geom::CoordinateXY;
using CoordinateSequence = geos::geom::CoordinateSequence;
using Geometry = geos::geom::Geometry;
using LinearRing = geos::geom::LinearRing;
using SegmentString = geos::noding::SegmentString;
private:
// const Geometry* inputGeom;
bool isInvertedRingValid = false;
PolygonIntersectionAnalyzer segInt;
std::vector<PolygonRing*> polyRings;
geom::CoordinateXY disconnectionPt;
// holding area for PolygonRings and SegmentStrings so we
// can pass around pointers with abandon
std::deque<PolygonRing> polyRingStore;
std::deque<noding::BasicSegmentString> segStringStore;
// when building SegmentStrings we sometimes want
// to use deduped CoordinateSequences so we will
// keep the deduped ones here so they get cleaned
// up when processing is complete
std::vector<std::unique_ptr<CoordinateSequence>> coordSeqStore;
PolygonRing* createPolygonRing(const LinearRing* p_ring);
PolygonRing* createPolygonRing(const LinearRing* p_ring, int p_index, PolygonRing* p_shell);
static const CoordinateXY&
findNonEqualVertex(const LinearRing* ring, const CoordinateXY& p);
static bool isIncidentSegmentInRing(const CoordinateXY* p0, const CoordinateXY* p1,
const CoordinateSequence* ringPts);
static const CoordinateXY& findRingVertexPrev(const CoordinateSequence* ringPts,
std::size_t index, const CoordinateXY& node);
static const CoordinateXY& findRingVertexNext(const CoordinateSequence* ringPts,
std::size_t index, const CoordinateXY& node);
static std::size_t ringIndexPrev(const CoordinateSequence* ringPts, std::size_t index);
static std::size_t ringIndexNext(const CoordinateSequence* ringPts, std::size_t index);
static std::size_t intersectingSegIndex(const CoordinateSequence* ringPts, const CoordinateXY* pt);
std::vector<SegmentString*> createSegmentStrings(const Geometry* geom, bool isInvertedRingValid);
std::vector<PolygonRing*> getPolygonRings(const std::vector<SegmentString*>& segStrings);
SegmentString* createSegString(const LinearRing* ring, const PolygonRing* polyRing);
// Declare type as noncopyable
PolygonTopologyAnalyzer(const PolygonTopologyAnalyzer& other) = delete;
PolygonTopologyAnalyzer& operator=(const PolygonTopologyAnalyzer& rhs) = delete;
public:
/* public */
PolygonTopologyAnalyzer(const Geometry* geom, bool p_isInvertedRingValid);
static CoordinateXY findSelfIntersection(const LinearRing* ring);
static bool
isRingNested(const LinearRing* test,
const LinearRing* target);
bool hasInvalidIntersection() {
return segInt.isInvalid();
}
int getInvalidCode() {
return segInt.getInvalidCode();
}
const CoordinateXY& getInvalidLocation() {
return segInt.getInvalidLocation();
}
bool isInteriorDisconnected();
const CoordinateXY& getDisconnectionLocation() const
{
return disconnectionPt;
};
void checkInteriorDisconnectedByHoleCycle();
void checkInteriorDisconnectedBySelfTouch();
};
} // namespace geos.operation.valid
} // namespace geos.operation
} // namespace geos
geos::geom::Geometry
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition Geometry.h:196
geos::geom
Definition Angle.h:26
geos::operation::valid
Provides classes for testing the validity of geometries.
Definition namespaces.h:289
geos::operation
Provides classes for implementing operations on geometries.
Definition CleanCoverage.h:34
geos
Basic namespace for all GEOS functionalities.
Definition geos.h:38