GEOS 3.13.0beta1
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
51
52using geos::geom::CoordinateXY;
56
57
93class GEOS_DLL RelateNG {
94
95private:
96
97 // Members
98 const BoundaryNodeRule& boundaryNodeRule;
99 RelateGeometry geomA;
100 std::unique_ptr<MCIndexSegmentSetMutualIntersector> edgeMutualInt = nullptr;
101
102 // Methods
103
104 RelateNG(const Geometry* inputA, bool isPrepared, const BoundaryNodeRule& bnRule)
105 : boundaryNodeRule(bnRule)
106 , geomA(inputA, isPrepared, bnRule)
107 {}
108
109 RelateNG(const Geometry* inputA, bool isPrepared)
110 : RelateNG(inputA, isPrepared, BoundaryNodeRule::getBoundaryRuleMod2())
111 {}
112
113 bool hasRequiredEnvelopeInteraction(const Geometry* b, TopologyPredicate& predicate);
114
115 bool finishValue(TopologyPredicate& predicate);
116
117 void computePP(RelateGeometry& geomB, TopologyComputer& topoComputer);
118
119 void computeAtPoints(RelateGeometry& geom, bool isA, RelateGeometry& geomTarget, TopologyComputer& topoComputer);
120
121 bool computePoints(RelateGeometry& geom, bool isA, RelateGeometry& geomTarget, TopologyComputer& topoComputer);
122
123 void computePoint(bool isA, const CoordinateXY* pt, RelateGeometry& geomTarget, TopologyComputer& topoComputer);
124
125 bool computeLineEnds(RelateGeometry& geom, bool isA, RelateGeometry& geomTarget, TopologyComputer& topoComputer);
126
127 bool computeLineEnd(RelateGeometry& geom, bool isA, const CoordinateXY* pt, RelateGeometry& geomTarget, TopologyComputer& topoComputer);
128
129 bool computeAreaVertex(RelateGeometry& geom, bool isA, RelateGeometry& geomTarget, TopologyComputer& topoComputer);
130
131 bool computeAreaVertex(RelateGeometry& geom, bool isA, const LinearRing* ring, RelateGeometry& geomTarget, TopologyComputer& topoComputer);
132
133 void computeAtEdges(RelateGeometry& geomB, TopologyComputer& topoComputer);
134
135 void computeEdgesAll(std::vector<const SegmentString*>& edgesB, const Envelope* envInt, EdgeSegmentIntersector& intersector);
136
137 void computeEdgesMutual(std::vector<const SegmentString*>& edgesB, const Envelope* envInt, EdgeSegmentIntersector& intersector);
138
139
140
141public:
142
152 static bool relate(const Geometry* a, const Geometry* b, TopologyPredicate& pred);
153
165 static bool relate(const Geometry* a, const Geometry* b, TopologyPredicate& pred, const BoundaryNodeRule& bnRule);
166
178 static bool relate(const Geometry* a, const Geometry* b, const std::string& imPattern);
179
188 static std::unique_ptr<IntersectionMatrix> relate(const Geometry* a, const Geometry* b);
189
199 static std::unique_ptr<IntersectionMatrix> relate(const Geometry* a, const Geometry* b, const BoundaryNodeRule& bnRule);
200
208 static std::unique_ptr<RelateNG> prepare(const Geometry* a);
209
219 static std::unique_ptr<RelateNG> prepare(const Geometry* a, const BoundaryNodeRule& bnRule);
220
221
228 std::unique_ptr<IntersectionMatrix> evaluate(const Geometry* b);
229
230
241 bool evaluate(const Geometry* b, const std::string& imPattern);
242
251 bool evaluate(const Geometry* b, TopologyPredicate& predicate);
252
253 static bool intersects(const Geometry* a, const Geometry* b);
254 static bool crosses(const Geometry* a, const Geometry* b);
255 static bool disjoint(const Geometry* a, const Geometry* b);
256 static bool touches(const Geometry* a, const Geometry* b);
257 static bool within(const Geometry* a, const Geometry* b);
258 static bool contains(const Geometry* a, const Geometry* b);
259 static bool overlaps(const Geometry* a, const Geometry* b);
260 static bool covers(const Geometry* a, const Geometry* b);
261 static bool coveredBy(const Geometry* a, const Geometry* b);
262 static bool equalsTopo(const Geometry* a, const Geometry* b);
263
264 bool intersects(const Geometry* a);
265 bool crosses(const Geometry* a);
266 bool disjoint(const Geometry* a);
267 bool touches(const Geometry* a);
268 bool within(const Geometry* a);
269 bool contains(const Geometry* a);
270 bool overlaps(const Geometry* a);
271 bool covers(const Geometry* a);
272 bool coveredBy(const Geometry* a);
273 bool equalsTopo(const Geometry* a);
274 bool relate(const Geometry* a, const std::string& pat);
275 std::unique_ptr<IntersectionMatrix> relate(const Geometry* a);
276
277};
278
279} // namespace geos.operation.relateng
280} // namespace geos.operation
281} // namespace geos
282
An interface for rules which determine whether node points which are in boundaries of lineal geometry...
Definition BoundaryNodeRule.h:50
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
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
Definition RelateNG.h:93
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