GEOS 3.15.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
28namespace geos {
29namespace geom {
30}
31namespace operation {
32namespace overlayng {
33class Edge;
34}
35}
36}
37
38namespace geos { // geos.
39namespace operation { // geos.operation
40namespace overlayng { // geos.operation.overlayng
41
52class GEOS_DLL OverlayGraph {
54 using CoordinateXY = geos::geom::CoordinateXY;
56
57private:
58
59 // Members
60 std::unordered_map<CoordinateXY, OverlayEdge*, geom::Coordinate::HashCode> nodeMap;
61 std::vector<OverlayEdge*> edges;
62
63 // Locally store the OverlayEdge and OverlayLabel
64 std::deque<OverlayEdge> ovEdgeQue;
65 std::deque<OverlayLabel> ovLabelQue;
66
67 // Methods
68
73 OverlayEdge* createEdgePair(const std::shared_ptr<const CoordinateSequence> &pts, OverlayLabel *lbl);
74
79 OverlayEdge* createOverlayEdge(const std::shared_ptr<const CoordinateSequence> &pts, OverlayLabel *lbl, bool direction);
80
81 void insert(OverlayEdge* e);
82
83
84
85public:
86
91
92 OverlayGraph(const OverlayGraph& g) = delete;
93 OverlayGraph& operator=(const OverlayGraph& g) = delete;
94
102
108 std::vector<OverlayEdge*>& getEdges();
109
116 std::vector<OverlayEdge*> getNodeEdges();
117
121 OverlayEdge* getNodeEdge(const Coordinate& nodePt) const;
122
126 std::vector<OverlayEdge*> getResultAreaEdges();
127
133
134 friend std::ostream& operator<<(std::ostream& os, const OverlayGraph& og);
135
136};
137
138
139} // namespace geos.operation.overlayng
140} // namespace geos.operation
141} // namespace geos
142
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:220
Definition operation/overlayng/Edge.h:54
Definition OverlayEdge.h:47
Definition OverlayGraph.h:52
OverlayEdge * addEdge(Edge *edge)
std::vector< OverlayEdge * > & getEdges()
std::vector< OverlayEdge * > getResultAreaEdges()
OverlayEdge * getNodeEdge(const Coordinate &nodePt) const
OverlayLabel * createOverlayLabel(const Edge *edge)
std::vector< OverlayEdge * > getNodeEdges()
Definition OverlayLabel.h:86
Basic namespace for all GEOS functionalities.
Definition geos.h:38