GEOS 3.13.0beta1
TopologyComputer.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/operation/relateng/NodeSections.h>
19#include <geos/geom/Coordinate.h>
20#include <geos/geom/Location.h>
21#include <geos/export.h>
22
23// Forward declarations
24namespace geos {
25namespace operation {
26namespace relateng {
27 class NodeSection;
28 class RelateGeometry;
29 class RelateNode;
30 class TopologyPredicate;
31}
32}
33}
34
35
36using geos::geom::CoordinateXY;
39using geos::operation::relateng::NodeSections;
40using geos::operation::relateng::RelateGeometry;
41using geos::operation::relateng::RelateNode;
42using geos::operation::relateng::TopologyPredicate;
43
44
45namespace geos { // geos.
46namespace operation { // geos.operation
47namespace relateng { // geos.operation.relateng
48
49
50class GEOS_DLL TopologyComputer {
51
52private:
53
54 // Members
55 TopologyPredicate& predicate;
56 RelateGeometry& geomA;
57 RelateGeometry& geomB;
58 std::map<CoordinateXY, NodeSections*> nodeMap;
59 std::deque<std::unique_ptr<NodeSections>> nodeSectionsStore;
60
61 // Methods
62
66 void initExteriorDims();
67
68 void initExteriorEmpty(bool geomNonEmpty);
69
70 inline RelateGeometry& getGeometry(bool isA) const {
71 return isA ? geomA : geomB;
72 };
73
74 void updateDim(Location locA, Location locB, int dimension);
75
76 void updateDim(bool isAB, Location loc1, Location loc2, int dimension);
77
84 void updateIntersectionAB(const NodeSection* a, const NodeSection* b);
85
97 void updateAreaAreaCross(const NodeSection* a, const NodeSection* b);
98
105 void updateNodeLocation(const NodeSection* a, const NodeSection* b);
106
107 void addNodeSections(NodeSection* ns0, NodeSection* ns1);
108
109 void addLineEndOnPoint(bool isLineA, Location locLineEnd, Location locPoint, const CoordinateXY* pt);
110
111 void addLineEndOnLine(bool isLineA, Location locLineEnd, Location locLine, const CoordinateXY* pt);
112
113 void addLineEndOnArea(bool isLineA, Location locLineEnd, Location locArea, const CoordinateXY* pt);
114
126 void addAreaVertexOnPoint(bool isAreaA, Location locArea, const CoordinateXY* pt);
127
128 void addAreaVertexOnLine(bool isAreaA, Location locArea, Location locTarget, const CoordinateXY* pt);
129
130 void evaluateNode(NodeSections* nodeSections);
131
132 void evaluateNodeEdges(const RelateNode* node);
133
134 NodeSections* getNodeSections(const CoordinateXY& nodePt);
135
136
137
138public:
139
140 TopologyComputer(
141 TopologyPredicate& p_predicate,
142 RelateGeometry& p_geomA,
143 RelateGeometry& p_geomB)
144 : predicate(p_predicate)
145 , geomA(p_geomA)
146 , geomB(p_geomB)
147 {
148 initExteriorDims();
149 };
150
151 int getDimension(bool isA) const;
152
153 bool isAreaArea() const;
154
170 bool isSelfNodingRequired() const;
171
172 bool isExteriorCheckRequired(bool isA) const;
173
174 bool isResultKnown() const;
175
176 bool getResult() const;
177
181 void finish();
182
183 void addIntersection(NodeSection* a, NodeSection* b);
184
185 void addPointOnPointInterior(const CoordinateXY* pt);
186
187 void addPointOnPointExterior(bool isGeomA, const CoordinateXY* pt);
188
189 void addPointOnGeometry(bool isA, Location locTarget, int dimTarget, const CoordinateXY* pt);
190
191 void addLineEndOnGeometry(bool isLineA, Location locLineEnd, Location locTarget, int dimTarget, const CoordinateXY* pt);
192
209 void addAreaVertex(bool isAreaA, Location locArea, Location locTarget, int dimTarget, const CoordinateXY* pt);
210
211 void addAreaVertexOnArea(bool isAreaA, Location locArea, Location locTarget, const CoordinateXY* pt);
212
213 void evaluateNodes();
214
219 TopologyComputer(const TopologyComputer&) = delete;
220 TopologyComputer& operator=(const TopologyComputer&) = delete;
221
222
223};
224
225} // namespace geos.operation.relateng
226} // namespace geos.operation
227} // namespace geos
228
Definition NodeSection.h:55
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:39