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;
94 void analyzeDimensions();
103 static bool isZeroLength(
const Geometry* geom);
105 static bool isZeroLength(
const LineString* line);
107 bool isZeroLengthLine(
const Geometry* g)
const {
109 if (getDimension() != Dimension::L)
111 return isZeroLength(g);
114 RelatePointLocator* getLocator();
116 Coordinate::ConstXYSet createUniquePoints();
118 void extractSegmentStringsFromAtomic(
bool isA,
119 const Geometry* geom,
const MultiPolygon* parentPolygonal,
121 std::vector<const SegmentString*>& segStrings,
122 std::vector<std::unique_ptr<const RelateSegmentString>>& segStore);
124 void extractRingToSegmentString(
bool isA,
125 const LinearRing* ring,
int ringId,
const Envelope* env,
126 const Geometry* parentPoly,
127 std::vector<const SegmentString*>& segStrings,
128 std::vector<std::unique_ptr<const RelateSegmentString>>& segStore);
130 void extractSegmentStrings(
bool isA,
131 const Envelope* env,
const Geometry* geom,
132 std::vector<const SegmentString*>& segStrings,
133 std::vector<std::unique_ptr<const RelateSegmentString>>& segStore);
135 static std::shared_ptr<const CoordinateSequence> orientAndRemoveRepeated(
136 const std::shared_ptr<const CoordinateSequence>& cs,
bool orientCW);
138 static std::shared_ptr<const CoordinateSequence> removeRepeated(
139 const std::shared_ptr<const CoordinateSequence>& cs);
143 static constexpr bool GEOM_A =
true;
144 static constexpr bool GEOM_B =
false;
146 RelateGeometry(
const Geometry* input)
147 : RelateGeometry(input, false, BoundaryNodeRule::getBoundaryRuleMod2())
150 RelateGeometry(
const Geometry* input,
const BoundaryNodeRule& bnRule)
151 : RelateGeometry(input, false, bnRule)
154 RelateGeometry(
const Geometry* input,
bool p_isPrepared,
const BoundaryNodeRule& bnRule);
156 static std::string name(
bool isA);
158 const Geometry* getGeometry()
const {
162 bool isPrepared()
const {
166 const Envelope* getEnvelope()
const {
170 inline int getDimension()
const {
174 bool hasDimension(
int dim)
const {
176 case Dimension::P:
return hasPoints;
177 case Dimension::L:
return hasLines;
178 case Dimension::A:
return hasAreas;
183 bool hasAreaAndLine()
const {
184 return hasAreas && hasLines;
193 int getDimensionReal()
const;
195 bool hasEdges()
const;
197 bool isNodeInArea(
const CoordinateXY* nodePt,
const Geometry* parentPolygonal);
199 int locateLineEndWithDim(
const CoordinateXY* p);
211 Location locateAreaVertex(
const CoordinateXY* pt);
213 Location locateNode(
const CoordinateXY* pt,
const Geometry* parentPolygonal);
215 int locateWithDim(
const CoordinateXY* pt);
233 bool isSelfNodingRequired()
const;
245 bool isPolygonal()
const;
247 bool isEmpty()
const;
251 Coordinate::ConstXYSet& getUniquePoints();
253 std::vector<const Point*> getEffectivePoints();
264 std::vector<const SegmentString*> extractSegmentStrings(
bool isA,
const Envelope* env);
266 std::string toString()
const;
268 friend std::ostream& operator<<(std::ostream& os,
const RelateGeometry& rg);
275 RelateGeometry(
const RelateGeometry&) =
delete;
276 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:196
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:38