GEOS  3.13.1
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
24 namespace geos {
25 namespace operation {
26 namespace relateng {
27  class NodeSection;
28  class RelateGeometry;
29  class RelateNode;
30  class TopologyPredicate;
31 }
32 }
33 }
34 
35 
36 using geos::geom::CoordinateXY;
39 using geos::operation::relateng::NodeSections;
40 using geos::operation::relateng::RelateGeometry;
41 using geos::operation::relateng::RelateNode;
42 using geos::operation::relateng::TopologyPredicate;
43 
44 
45 namespace geos { // geos.
46 namespace operation { // geos.operation
47 namespace relateng { // geos.operation.relateng
48 
49 
50 class GEOS_DLL TopologyComputer {
51 
52 private:
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 addLineEndOnLine(bool isLineA, Location locLineEnd, Location locLine, const CoordinateXY* pt);
110 
111  void addLineEndOnArea(bool isLineA, Location locLineEnd, Location locArea, const CoordinateXY* pt);
112 
124  void addAreaVertexOnPoint(bool isAreaA, Location locArea, const CoordinateXY* pt);
125 
126  void addAreaVertexOnLine(bool isAreaA, Location locArea, Location locTarget, const CoordinateXY* pt);
127 
128  void evaluateNode(NodeSections* nodeSections);
129 
130  void evaluateNodeEdges(const RelateNode* node);
131 
132  NodeSections* getNodeSections(const CoordinateXY& nodePt);
133 
134 
135 
136 public:
137 
138  TopologyComputer(
139  TopologyPredicate& p_predicate,
140  RelateGeometry& p_geomA,
141  RelateGeometry& p_geomB)
142  : predicate(p_predicate)
143  , geomA(p_geomA)
144  , geomB(p_geomB)
145  {
146  initExteriorDims();
147  };
148 
149  int getDimension(bool isA) const;
150 
151  bool isAreaArea() const;
152 
166  bool isSelfNodingRequired() const;
167 
168  bool isExteriorCheckRequired(bool isA) const;
169 
170  bool isResultKnown() const;
171 
172  bool getResult() const;
173 
177  void finish();
178 
179  void addIntersection(NodeSection* a, NodeSection* b);
180 
181  void addPointOnPointInterior(const CoordinateXY* pt);
182 
183  void addPointOnPointExterior(bool isGeomA, const CoordinateXY* pt);
184 
185  void addPointOnGeometry(bool isA, Location locTarget, int dimTarget, const CoordinateXY* pt);
186 
199  void addLineEndOnGeometry(bool isLineA, Location locLineEnd, Location locTarget, int dimTarget, const CoordinateXY* pt);
200 
217  void addAreaVertex(bool isAreaA, Location locArea, Location locTarget, int dimTarget, const CoordinateXY* pt);
218 
219  void addAreaVertexOnArea(bool isAreaA, Location locArea, Location locTarget, const CoordinateXY* pt);
220 
221  void evaluateNodes();
222 
227  TopologyComputer(const TopologyComputer&) = delete;
228  TopologyComputer& operator=(const TopologyComputer&) = delete;
229 
230 
231 };
232 
233 } // namespace geos.operation.relateng
234 } // namespace geos.operation
235 } // namespace geos
236 
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: Angle.h:25