GEOS 3.13.1
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
140 bool computeLineEnd(RelateGeometry& geom, bool isA, const CoordinateXY* pt, RelateGeometry& geomTarget, TopologyComputer& topoComputer);
141
142 bool computeAreaVertex(RelateGeometry& geom, bool isA, RelateGeometry& geomTarget, TopologyComputer& topoComputer);
143
144 bool computeAreaVertex(RelateGeometry& geom, bool isA, const LinearRing* ring, RelateGeometry& geomTarget, TopologyComputer& topoComputer);
145
146 void computeAtEdges(RelateGeometry& geomB, TopologyComputer& topoComputer);
147
148 void computeEdgesAll(std::vector<const SegmentString*>& edgesB, const Envelope* envInt, EdgeSegmentIntersector& intersector);
149
150 void computeEdgesMutual(std::vector<const SegmentString*>& edgesB, const Envelope* envInt, EdgeSegmentIntersector& intersector);
151
152
153
154public:
155
165 static bool relate(const Geometry* a, const Geometry* b, TopologyPredicate& pred);
166
178 static bool relate(const Geometry* a, const Geometry* b, TopologyPredicate& pred, const BoundaryNodeRule& bnRule);
179
191 static bool relate(const Geometry* a, const Geometry* b, const std::string& imPattern);
192
201 static std::unique_ptr<IntersectionMatrix> relate(const Geometry* a, const Geometry* b);
202
212 static std::unique_ptr<IntersectionMatrix> relate(const Geometry* a, const Geometry* b, const BoundaryNodeRule& bnRule);
213
221 static std::unique_ptr<RelateNG> prepare(const Geometry* a);
222
232 static std::unique_ptr<RelateNG> prepare(const Geometry* a, const BoundaryNodeRule& bnRule);
233
234
241 std::unique_ptr<IntersectionMatrix> evaluate(const Geometry* b);
242
243
254 bool evaluate(const Geometry* b, const std::string& imPattern);
255
264 bool evaluate(const Geometry* b, TopologyPredicate& predicate);
265
266 static bool intersects(const Geometry* a, const Geometry* b);
267 static bool crosses(const Geometry* a, const Geometry* b);
268 static bool disjoint(const Geometry* a, const Geometry* b);
269 static bool touches(const Geometry* a, const Geometry* b);
270 static bool within(const Geometry* a, const Geometry* b);
271 static bool contains(const Geometry* a, const Geometry* b);
272 static bool overlaps(const Geometry* a, const Geometry* b);
273 static bool covers(const Geometry* a, const Geometry* b);
274 static bool coveredBy(const Geometry* a, const Geometry* b);
275 static bool equalsTopo(const Geometry* a, const Geometry* b);
276
277 bool intersects(const Geometry* a);
278 bool crosses(const Geometry* a);
279 bool disjoint(const Geometry* a);
280 bool touches(const Geometry* a);
281 bool within(const Geometry* a);
282 bool contains(const Geometry* a);
283 bool overlaps(const Geometry* a);
284 bool covers(const Geometry* a);
285 bool coveredBy(const Geometry* a);
286 bool equalsTopo(const Geometry* a);
287 bool relate(const Geometry* a, const std::string& pat);
288 std::unique_ptr<IntersectionMatrix> relate(const Geometry* a);
289
290};
291
292} // namespace geos.operation.relateng
293} // namespace geos.operation
294} // namespace geos
295
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
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