GEOS  3.14.0dev
OverlayGraph.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2020 Paul Ramsey <pramsey@cleverelephant.ca>
7  *
8  * This is free software; you can redistribute and/or modify it under
9  * the terms of the GNU Lesser General Public Licence as published
10  * by the Free Software Foundation.
11  * See the COPYING file for more information.
12  *
13  **********************************************************************/
14 
15 #pragma once
16 
17 #include <geos/export.h>
18 #include <geos/geom/Coordinate.h>
19 #include <geos/operation/overlayng/OverlayEdge.h>
20 #include <geos/operation/overlayng/OverlayLabel.h>
21 #include <geos/geom/CoordinateSequence.h>
22 
23 #include <unordered_map>
24 #include <vector>
25 #include <deque>
26 
27 // Forward declarations
28 namespace geos {
29 namespace geom {
30 }
31 namespace operation {
32 namespace overlayng {
33 class Edge;
34 }
35 }
36 }
37 
38 namespace geos { // geos.
39 namespace operation { // geos.operation
40 namespace overlayng { // geos.operation.overlayng
41 
52 class GEOS_DLL OverlayGraph {
55 
56 private:
57 
58  // Members
59  std::unordered_map<Coordinate, OverlayEdge*, geom::Coordinate::HashCode> nodeMap;
60  std::vector<OverlayEdge*> edges;
61 
62  // Locally store the OverlayEdge and OverlayLabel
63  std::deque<OverlayEdge> ovEdgeQue;
64  std::deque<OverlayLabel> ovLabelQue;
65 
66  std::vector<std::unique_ptr<const geom::CoordinateSequence>> csQue;
67 
68  // Methods
69 
74  OverlayEdge* createEdgePair(const CoordinateSequence* pts, OverlayLabel* lbl);
75 
80  OverlayEdge* createOverlayEdge(const CoordinateSequence* pts, OverlayLabel* lbl, bool direction);
81 
82  void insert(OverlayEdge* e);
83 
84 
85 
86 public:
87 
92 
93  OverlayGraph(const OverlayGraph& g) = delete;
94  OverlayGraph& operator=(const OverlayGraph& g) = delete;
95 
103 
109  std::vector<OverlayEdge*>& getEdges();
110 
117  std::vector<OverlayEdge*> getNodeEdges();
118 
122  OverlayEdge* getNodeEdge(const Coordinate& nodePt) const;
123 
127  std::vector<OverlayEdge*> getResultAreaEdges();
128 
134 
135  friend std::ostream& operator<<(std::ostream& os, const OverlayGraph& og);
136 
137 };
138 
139 
140 } // namespace geos.operation.overlayng
141 } // namespace geos.operation
142 } // namespace geos
143 
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:56
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:217
Definition: operation/overlayng/Edge.h:55
Definition: OverlayEdge.h:47
Definition: OverlayGraph.h:52
std::vector< OverlayEdge * > getNodeEdges()
std::vector< OverlayEdge * > & getEdges()
std::vector< OverlayEdge * > getResultAreaEdges()
OverlayLabel * createOverlayLabel(const Edge *edge)
OverlayEdge * addEdge(Edge *edge)
OverlayEdge * getNodeEdge(const Coordinate &nodePt) const
Definition: OverlayLabel.h:86
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25