18#include <geos/algorithm/BoundaryNodeRule.h>
19#include <geos/geom/Coordinate.h>
20#include <geos/geom/Dimension.h>
21#include <geos/geom/Location.h>
22#include <geos/operation/relateng/RelatePointLocator.h>
23#include <geos/operation/relateng/RelateSegmentString.h>
24#include <geos/export.h>
33 class CoordinateSequence;
51class GEOS_DLL RelateGeometry {
58 using CoordinateXY = geos::geom::CoordinateXY;
71 bool m_isPrepared =
false;
72 const Envelope* geomEnv;
73 const BoundaryNodeRule& boundaryNodeRule;
74 int geomDim = Dimension::False;
75 bool isLineZeroLen =
false;
76 bool isGeomEmpty =
false;
78 Coordinate::ConstXYSet uniquePoints;
79 std::unique_ptr<RelatePointLocator> locator;
81 bool hasPoints =
false;
82 bool hasLines =
false;
83 bool hasAreas =
false;
88 std::vector<std::unique_ptr<const RelateSegmentString>> segStringTempStore;
89 std::vector<std::unique_ptr<const RelateSegmentString>> segStringPermStore;
90 std::vector<std::unique_ptr<CoordinateSequence>> csStore;
95 void analyzeDimensions();
104 static bool isZeroLength(
const Geometry* geom);
106 static bool isZeroLength(
const LineString* line);
108 bool isZeroLengthLine(
const Geometry* g)
const {
110 if (getDimension() != Dimension::L)
112 return isZeroLength(g);
115 RelatePointLocator* getLocator();
117 Coordinate::ConstXYSet createUniquePoints();
119 void extractSegmentStringsFromAtomic(
bool isA,
120 const Geometry* geom,
const MultiPolygon* parentPolygonal,
122 std::vector<const SegmentString*>& segStrings,
123 std::vector<std::unique_ptr<const RelateSegmentString>>& segStore);
125 void extractRingToSegmentString(
bool isA,
126 const LinearRing* ring,
int ringId,
const Envelope* env,
127 const Geometry* parentPoly,
128 std::vector<const SegmentString*>& segStrings,
129 std::vector<std::unique_ptr<const RelateSegmentString>>& segStore);
131 void extractSegmentStrings(
bool isA,
132 const Envelope* env,
const Geometry* geom,
133 std::vector<const SegmentString*>& segStrings,
134 std::vector<std::unique_ptr<const RelateSegmentString>>& segStore);
136 const CoordinateSequence* orientAndRemoveRepeated(
137 const CoordinateSequence* cs,
bool orientCW);
139 const CoordinateSequence* removeRepeated(
140 const CoordinateSequence* cs);
144 static constexpr bool GEOM_A =
true;
145 static constexpr bool GEOM_B =
false;
147 RelateGeometry(
const Geometry* input)
148 : RelateGeometry(input, false, BoundaryNodeRule::getBoundaryRuleMod2())
151 RelateGeometry(
const Geometry* input,
const BoundaryNodeRule& bnRule)
152 : RelateGeometry(input, false, bnRule)
155 RelateGeometry(
const Geometry* input,
bool p_isPrepared,
const BoundaryNodeRule& bnRule);
157 static std::string name(
bool isA);
159 const Geometry* getGeometry()
const {
163 bool isPrepared()
const {
167 const Envelope* getEnvelope()
const {
171 inline int getDimension()
const {
175 bool hasDimension(
int dim)
const {
177 case Dimension::P:
return hasPoints;
178 case Dimension::L:
return hasLines;
179 case Dimension::A:
return hasAreas;
184 bool hasAreaAndLine()
const {
185 return hasAreas && hasLines;
194 int getDimensionReal()
const;
196 bool hasEdges()
const;
198 bool isNodeInArea(
const CoordinateXY* nodePt,
const Geometry* parentPolygonal);
200 int locateLineEndWithDim(
const CoordinateXY* p);
212 Location locateAreaVertex(
const CoordinateXY* pt);
214 Location locateNode(
const CoordinateXY* pt,
const Geometry* parentPolygonal);
216 int locateWithDim(
const CoordinateXY* pt);
234 bool isSelfNodingRequired()
const;
246 bool isPolygonal()
const;
248 bool isEmpty()
const;
252 Coordinate::ConstXYSet& getUniquePoints();
254 std::vector<const Point*> getEffectivePoints();
265 std::vector<const SegmentString*> extractSegmentStrings(
bool isA,
const Envelope* env);
267 std::string toString()
const;
269 friend std::ostream& operator<<(std::ostream& os,
const RelateGeometry& rg);
276 RelateGeometry(
const RelateGeometry&) =
delete;
277 RelateGeometry& operator=(
const RelateGeometry&) =
delete;
An interface for rules which determine whether node points which are in boundaries of lineal geometry...
Definition BoundaryNodeRule.h:52
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
Definition Dimension.h:27
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition Envelope.h:59
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition Geometry.h:197
Definition LineString.h:66
Models an OGC SFS LinearRing. A LinearRing is a LineString which is both closed and simple.
Definition LinearRing.h:54
Definition MultiPolygon.h:58
An interface for classes which represent a sequence of contiguous line segments.
Definition SegmentString.h:47
Location
Constants representing the location of a point relative to a geometry.
Definition Location.h:32
Basic namespace for all GEOS functionalities.
Definition geos.h:39