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>
51using namespace geos::geom;
52using geos::algorithm::BoundaryNodeRule;
53using geos::noding::SegmentString;
56class GEOS_DLL RelateGeometry {
63 bool m_isPrepared =
false;
64 const Envelope* geomEnv;
65 const BoundaryNodeRule& boundaryNodeRule;
67 bool isLineZeroLen =
false;
68 bool isGeomEmpty =
false;
70 Coordinate::ConstXYSet uniquePoints;
71 std::unique_ptr<RelatePointLocator> locator;
73 bool hasPoints =
false;
74 bool hasLines =
false;
75 bool hasAreas =
false;
80 std::vector<std::unique_ptr<const RelateSegmentString>> segStringTempStore;
81 std::vector<std::unique_ptr<const RelateSegmentString>> segStringPermStore;
82 std::vector<std::unique_ptr<CoordinateSequence>> csStore;
87 void analyzeDimensions();
96 static bool isZeroLength(
const Geometry* geom);
98 static bool isZeroLength(
const LineString* line);
100 bool isZeroLengthLine(
const Geometry* g)
const {
104 return isZeroLength(g);
107 RelatePointLocator* getLocator();
109 Coordinate::ConstXYSet createUniquePoints();
111 void extractSegmentStringsFromAtomic(
bool isA,
112 const Geometry* geom,
const MultiPolygon* parentPolygonal,
114 std::vector<const SegmentString*>& segStrings,
115 std::vector<std::unique_ptr<const RelateSegmentString>>& segStore);
117 void extractRingToSegmentString(
bool isA,
118 const LinearRing* ring,
int ringId,
const Envelope* env,
119 const Geometry* parentPoly,
120 std::vector<const SegmentString*>& segStrings,
121 std::vector<std::unique_ptr<const RelateSegmentString>>& segStore);
123 void extractSegmentStrings(
bool isA,
124 const Envelope* env,
const Geometry* geom,
125 std::vector<const SegmentString*>& segStrings,
126 std::vector<std::unique_ptr<const RelateSegmentString>>& segStore);
128 const CoordinateSequence* orientAndRemoveRepeated(
129 const CoordinateSequence* cs,
bool orientCW);
131 const CoordinateSequence* removeRepeated(
132 const CoordinateSequence* cs);
136 static constexpr bool GEOM_A =
true;
137 static constexpr bool GEOM_B =
false;
139 RelateGeometry(
const Geometry* input)
140 : RelateGeometry(input, false, BoundaryNodeRule::getBoundaryRuleMod2())
143 RelateGeometry(
const Geometry* input,
const BoundaryNodeRule& bnRule)
144 : RelateGeometry(input, false, bnRule)
147 RelateGeometry(
const Geometry* input,
bool p_isPrepared,
const BoundaryNodeRule& bnRule);
149 static std::string name(
bool isA);
151 const Geometry* getGeometry()
const {
155 bool isPrepared()
const {
159 const Envelope* getEnvelope()
const {
163 inline int getDimension()
const {
167 bool hasDimension(
int dim)
const {
176 bool hasAreaAndLine()
const {
177 return hasAreas && hasLines;
186 int getDimensionReal()
const;
188 bool hasEdges()
const;
190 bool isNodeInArea(
const CoordinateXY* nodePt,
const Geometry* parentPolygonal);
192 int locateLineEndWithDim(
const CoordinateXY* p);
204 Location locateAreaVertex(
const CoordinateXY* pt);
206 Location locateNode(
const CoordinateXY* pt,
const Geometry* parentPolygonal);
208 int locateWithDim(
const CoordinateXY* pt);
226 bool isSelfNodingRequired()
const;
238 bool isPolygonal()
const;
240 bool isEmpty()
const;
244 Coordinate::ConstXYSet& getUniquePoints();
246 std::vector<const Point*> getEffectivePoints();
257 std::vector<const SegmentString*> extractSegmentStrings(
bool isA,
const Envelope* env);
259 std::string toString()
const;
261 friend std::ostream& operator<<(std::ostream& os,
const RelateGeometry& rg);
268 RelateGeometry(
const RelateGeometry&) =
delete;
269 RelateGeometry& operator=(
const RelateGeometry&) =
delete;
@ A
Dimension value of a surface (2).
Definition Dimension.h:46
@ L
Dimension value of a curve (1).
Definition Dimension.h:43
@ False
Dimension value of the empty geometry (-1).
Definition Dimension.h:37
@ P
Dimension value of a point (0).
Definition Dimension.h:40
The internal representation of a list of coordinates inside a Geometry.
Definition CoordinateSequence.h:56
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
Classes to compute nodings for arrangements of line segments and line segment sequences.
Definition InvalidSegmentDetector.h:25
Provides classes for implementing operations on geometries.
Definition namespaces.h:179
Basic namespace for all GEOS functionalities.
Definition geos.h:39