GEOS  3.13.0dev
planargraph/NodeMap.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2001-2002 Vivid Solutions Inc.
7  * Copyright (C) 2005-2006 Refractions Research Inc.
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/export.h>
19 #include <geos/geom/Coordinate.h> // for use in container
20 
21 #include <map>
22 #include <vector>
23 
24 #ifdef _MSC_VER
25 #pragma warning(push)
26 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
27 #endif
28 
29 // Forward declarations
30 namespace geos {
31 namespace planargraph {
32 class DirectedEdgeStar;
33 class DirectedEdge;
34 class Edge;
35 class Node;
36 }
37 }
38 
39 namespace geos {
40 namespace planargraph { // geos.planargraph
41 
47 class GEOS_DLL NodeMap {
48 public:
49  typedef std::map<geom::Coordinate, Node*, geom::CoordinateLessThan> container;
50 private:
51  container nodeMap;
52 public:
57 
58  container& getNodeMap();
59 
60  virtual ~NodeMap() = default;
61 
68  Node* add(Node* n);
69 
76 
82  Node* find(const geom::Coordinate& coord);
83 
90  container::iterator
92  {
93  return nodeMap.begin();
94  }
95 
96  container::iterator
97  begin()
98  {
99  return nodeMap.begin();
100  }
101  container::const_iterator
102  begin() const
103  {
104  return nodeMap.begin();
105  }
106 
107  container::iterator
108  end()
109  {
110  return nodeMap.end();
111  }
112  container::const_iterator
113  end() const
114  {
115  return nodeMap.end();
116  }
117 
125  void getNodes(std::vector<Node*>& nodes);
126 };
127 
128 
129 } // namespace geos::planargraph
130 } // namespace geos
131 
132 #ifdef _MSC_VER
133 #pragma warning(pop)
134 #endif
135 
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:216
A map of Node, indexed by the coordinate of the node.
Definition: planargraph/NodeMap.h:47
Node * add(Node *n)
Adds a node to the std::map, replacing any that is already at that location.
void getNodes(std::vector< Node * > &nodes)
Returns the Nodes in this NodeMap, sorted in ascending order by angle with the positive x-axis.
Node * remove(geom::Coordinate &pt)
Removes the Node at the given location, and returns it (or null if no Node was there).
NodeMap()
Constructs a NodeMap without any Nodes.
Node * find(const geom::Coordinate &coord)
Returns the Node at the given location, or null if no Node was there.
container::iterator iterator()
Returns an Iterator over the Nodes in this NodeMap, sorted in ascending order by angle with the posit...
Definition: planargraph/NodeMap.h:91
A node in a PlanarGraph is a location where 0 or more Edge meet.
Definition: planargraph/Node.h:44
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25