GEOS 3.14.0dev
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
35namespace geos { // geos.
36namespace operation { // geos.operation
37namespace relateng { // geos.operation.relateng
38
39
40class GEOS_DLL TopologyComputer {
41 using CoordinateXY = geos::geom::CoordinateXY;
44 using NodeSections = geos::operation::relateng::NodeSections;
45 using RelateGeometry = geos::operation::relateng::RelateGeometry;
46 using RelateNode = geos::operation::relateng::RelateNode;
47 using TopologyPredicate = geos::operation::relateng::TopologyPredicate;
48
49private:
50
51 // Members
52 TopologyPredicate& predicate;
53 RelateGeometry& geomA;
54 RelateGeometry& geomB;
55 std::map<CoordinateXY, NodeSections*> nodeMap;
56 std::deque<std::unique_ptr<NodeSections>> nodeSectionsStore;
57
58 // Methods
59
63 void initExteriorDims();
64
65 void initExteriorEmpty(bool geomNonEmpty);
66
67 inline RelateGeometry& getGeometry(bool isA) const {
68 return isA ? geomA : geomB;
69 };
70
71 void updateDim(Location locA, Location locB, int dimension);
72
73 void updateDim(bool isAB, Location loc1, Location loc2, int dimension);
74
81 void updateIntersectionAB(const NodeSection* a, const NodeSection* b);
82
94 void updateAreaAreaCross(const NodeSection* a, const NodeSection* b);
95
102 void updateNodeLocation(const NodeSection* a, const NodeSection* b);
103
104 void addNodeSections(NodeSection* ns0, NodeSection* ns1);
105
106 void addLineEndOnLine(bool isLineA, Location locLineEnd, Location locLine, const CoordinateXY* pt);
107
108 void addLineEndOnArea(bool isLineA, Location locLineEnd, Location locArea, const CoordinateXY* pt);
109
121 void addAreaVertexOnPoint(bool isAreaA, Location locArea, const CoordinateXY* pt);
122
123 void addAreaVertexOnLine(bool isAreaA, Location locArea, Location locTarget, const CoordinateXY* pt);
124
125 void evaluateNode(NodeSections* nodeSections);
126
127 void evaluateNodeEdges(const RelateNode* node);
128
129 NodeSections* getNodeSections(const CoordinateXY& nodePt);
130
131
132
133public:
134
135 TopologyComputer(
136 TopologyPredicate& p_predicate,
137 RelateGeometry& p_geomA,
138 RelateGeometry& p_geomB)
139 : predicate(p_predicate)
140 , geomA(p_geomA)
141 , geomB(p_geomB)
142 {
143 initExteriorDims();
144 };
145
146 int getDimension(bool isA) const;
147
148 bool isAreaArea() const;
149
163 bool isSelfNodingRequired() const;
164
165 bool isExteriorCheckRequired(bool isA) const;
166
167 bool isResultKnown() const;
168
169 bool getResult() const;
170
174 void finish();
175
176 void addIntersection(NodeSection* a, NodeSection* b);
177
178 void addPointOnPointInterior(const CoordinateXY* pt);
179
180 void addPointOnPointExterior(bool isGeomA, const CoordinateXY* pt);
181
182 void addPointOnGeometry(bool isA, Location locTarget, int dimTarget, const CoordinateXY* pt);
183
196 void addLineEndOnGeometry(bool isLineA, Location locLineEnd, Location locTarget, int dimTarget, const CoordinateXY* pt);
197
214 void addAreaVertex(bool isAreaA, Location locArea, Location locTarget, int dimTarget, const CoordinateXY* pt);
215
216 void addAreaVertexOnArea(bool isAreaA, Location locArea, Location locTarget, const CoordinateXY* pt);
217
218 void evaluateNodes();
219
224 TopologyComputer(const TopologyComputer&) = delete;
225 TopologyComputer& operator=(const TopologyComputer&) = delete;
226
227
228};
229
230} // namespace geos.operation.relateng
231} // namespace geos.operation
232} // namespace geos
233
Definition NodeSection.h:50
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