GEOS 3.14.0dev
RelateNG.h
1/**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (c) 2024 Martin Davis
7 * Copyright (C) 2024 Paul Ramsey <pramsey@cleverelephant.ca>
8 *
9 * This is free software; you can redistribute and/or modify it under
10 * the terms of the GNU Lesser General Public Licence as published
11 * by the Free Software Foundation.
12 * See the COPYING file for more information.
13 *
14 **********************************************************************/
15
16#pragma once
17
18#include <geos/export.h>
19#include <geos/geom/Coordinate.h>
20#include <geos/noding/MCIndexSegmentSetMutualIntersector.h>
21#include <geos/operation/relateng/RelateGeometry.h>
22#include <string>
23#include <sstream>
24
25
26// Forward declarations
27namespace geos {
28namespace algorithm {
29 class BoundaryNodeRule;
30
31}
32namespace geom {
33 class Geometry;
34}
35namespace noding {
36}
37namespace operation {
38namespace relateng {
39 class TopologyPredicate;
40 class TopologyComputer;
41 class EdgeSegmentIntersector;
42}
43}
44}
45
46
47namespace geos { // geos.
48namespace operation { // geos.operation
49namespace relateng { // geos.operation.relateng
50
86class GEOS_DLL RelateNG {
87 using CoordinateXY = geos::geom::CoordinateXY;
95
96private:
97
98 // Members
99 const BoundaryNodeRule& boundaryNodeRule;
100 RelateGeometry geomA;
101 std::unique_ptr<MCIndexSegmentSetMutualIntersector> edgeMutualInt = nullptr;
102
103 // Methods
104
105 RelateNG(const Geometry* inputA, bool isPrepared, const BoundaryNodeRule& bnRule)
106 : boundaryNodeRule(bnRule)
107 , geomA(inputA, isPrepared, bnRule)
108 {}
109
110 RelateNG(const Geometry* inputA, bool isPrepared)
111 : RelateNG(inputA, isPrepared, BoundaryNodeRule::getBoundaryRuleMod2())
112 {}
113
114 bool hasRequiredEnvelopeInteraction(const Geometry* b, TopologyPredicate& predicate);
115
116 bool finishValue(TopologyPredicate& predicate);
117
118 void computePP(RelateGeometry& geomB, TopologyComputer& topoComputer);
119
120 void computeAtPoints(RelateGeometry& geom, bool isA, RelateGeometry& geomTarget, TopologyComputer& topoComputer);
121
122 bool computePoints(RelateGeometry& geom, bool isA, RelateGeometry& geomTarget, TopologyComputer& topoComputer);
123
124 void computePoint(bool isA, const CoordinateXY* pt, RelateGeometry& geomTarget, TopologyComputer& topoComputer);
125
126 bool computeLineEnds(RelateGeometry& geom, bool isA, RelateGeometry& geomTarget, TopologyComputer& topoComputer);
127
128
141 bool computeLineEnd(RelateGeometry& geom, bool isA, const CoordinateXY* pt, RelateGeometry& geomTarget, TopologyComputer& topoComputer);
142
143 bool computeAreaVertex(RelateGeometry& geom, bool isA, RelateGeometry& geomTarget, TopologyComputer& topoComputer);
144
145 bool computeAreaVertex(RelateGeometry& geom, bool isA, const LinearRing* ring, RelateGeometry& geomTarget, TopologyComputer& topoComputer);
146
147 void computeAtEdges(RelateGeometry& geomB, TopologyComputer& topoComputer);
148
149 void computeEdgesAll(std::vector<const SegmentString*>& edgesB, const Envelope* envInt, EdgeSegmentIntersector& intersector);
150
151 void computeEdgesMutual(std::vector<const SegmentString*>& edgesB, const Envelope* envInt, EdgeSegmentIntersector& intersector);
152
153
154
155public:
156
166 static bool relate(const Geometry* a, const Geometry* b, TopologyPredicate& pred);
167
179 static bool relate(const Geometry* a, const Geometry* b, TopologyPredicate& pred, const BoundaryNodeRule& bnRule);
180
192 static bool relate(const Geometry* a, const Geometry* b, const std::string& imPattern);
193
202 static std::unique_ptr<IntersectionMatrix> relate(const Geometry* a, const Geometry* b);
203
213 static std::unique_ptr<IntersectionMatrix> relate(const Geometry* a, const Geometry* b, const BoundaryNodeRule& bnRule);
214
222 static std::unique_ptr<RelateNG> prepare(const Geometry* a);
223
233 static std::unique_ptr<RelateNG> prepare(const Geometry* a, const BoundaryNodeRule& bnRule);
234
235
242 std::unique_ptr<IntersectionMatrix> evaluate(const Geometry* b);
243
244
255 bool evaluate(const Geometry* b, const std::string& imPattern);
256
265 bool evaluate(const Geometry* b, TopologyPredicate& predicate);
266
267 static bool intersects(const Geometry* a, const Geometry* b);
268 static bool crosses(const Geometry* a, const Geometry* b);
269 static bool disjoint(const Geometry* a, const Geometry* b);
270 static bool touches(const Geometry* a, const Geometry* b);
271 static bool within(const Geometry* a, const Geometry* b);
272 static bool contains(const Geometry* a, const Geometry* b);
273 static bool overlaps(const Geometry* a, const Geometry* b);
274 static bool covers(const Geometry* a, const Geometry* b);
275 static bool coveredBy(const Geometry* a, const Geometry* b);
276 static bool equalsTopo(const Geometry* a, const Geometry* b);
277
278 bool intersects(const Geometry* a);
279 bool crosses(const Geometry* a);
280 bool disjoint(const Geometry* a);
281 bool touches(const Geometry* a);
282 bool within(const Geometry* a);
283 bool contains(const Geometry* a);
284 bool overlaps(const Geometry* a);
285 bool covers(const Geometry* a);
286 bool coveredBy(const Geometry* a);
287 bool equalsTopo(const Geometry* a);
288 bool relate(const Geometry* a, const std::string& pat);
289 std::unique_ptr<IntersectionMatrix> relate(const Geometry* a);
290
291};
292
293} // namespace geos.operation.relateng
294} // namespace geos.operation
295} // namespace geos
296
An interface for rules which determine whether node points which are in boundaries of lineal geometry...
Definition BoundaryNodeRule.h:52
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
Implementation of Dimensionally Extended Nine-Intersection Model (DE-9IM) matrix.
Definition IntersectionMatrix.h:51
Models an OGC SFS LinearRing. A LinearRing is a LineString which is both closed and simple.
Definition LinearRing.h:54
Intersects two sets of SegmentStrings using a index based on MonotoneChains and a SpatialIndex.
Definition MCIndexSegmentSetMutualIntersector.h:47
An interface for classes which represent a sequence of contiguous line segments.
Definition SegmentString.h:47
Definition RelateNG.h:86
static bool relate(const Geometry *a, const Geometry *b, TopologyPredicate &pred)
static bool relate(const Geometry *a, const Geometry *b, TopologyPredicate &pred, const BoundaryNodeRule &bnRule)
static std::unique_ptr< RelateNG > prepare(const Geometry *a, const BoundaryNodeRule &bnRule)
bool evaluate(const Geometry *b, const std::string &imPattern)
bool evaluate(const Geometry *b, TopologyPredicate &predicate)
static std::unique_ptr< IntersectionMatrix > relate(const Geometry *a, const Geometry *b)
static std::unique_ptr< RelateNG > prepare(const Geometry *a)
std::unique_ptr< IntersectionMatrix > evaluate(const Geometry *b)
static bool relate(const Geometry *a, const Geometry *b, const std::string &imPattern)
static std::unique_ptr< IntersectionMatrix > relate(const Geometry *a, const Geometry *b, const BoundaryNodeRule &bnRule)
Basic namespace for all GEOS functionalities.
Definition geos.h:39