GEOS  3.9.1dev
geomgraph/NodeMap.h
Go to the documentation of this file.
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2005-2006 Refractions Research Inc.
7  * Copyright (C) 2001-2002 Vivid Solutions 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  * Last port: geomgraph/NodeMap.java rev. 1.3 (JTS-1.10)
17  *
18  **********************************************************************/
19 
20 
21 #ifndef GEOS_GEOMGRAPH_NODEMAP_H
22 #define GEOS_GEOMGRAPH_NODEMAP_H
23 
24 #include <geos/export.h>
25 #include <map>
26 #include <vector>
27 #include <string>
28 
29 #include <geos/geom/Coordinate.h> // for CoordinateLessThen
30 #include <geos/geomgraph/Node.h> // for testInvariant
31 
32 #include <geos/inline.h>
33 
34 #ifdef _MSC_VER
35 #pragma warning(push)
36 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
37 #endif
38 
39 // Forward declarations
40 namespace geos {
41 namespace geomgraph {
42 class Node;
43 class EdgeEnd;
44 class NodeFactory;
45 }
46 }
47 
48 namespace geos {
49 namespace geomgraph { // geos.geomgraph
50 
52 public:
53 
54  typedef std::map<geom::Coordinate*, Node*, geom::CoordinateLessThen> container;
55 
56  typedef container::iterator iterator;
57 
58  typedef container::const_iterator const_iterator;
59 
60  typedef std::pair<geom::Coordinate*, Node*> pair;
61 
62  container nodeMap;
63 
65 
69  NodeMap(const NodeFactory& newNodeFact);
70 
71  virtual ~NodeMap();
72 
73  Node* addNode(const geom::Coordinate& coord);
74 
75  Node* addNode(Node* n);
76 
77  void add(EdgeEnd* e);
78 
79  Node* find(const geom::Coordinate& coord) const;
80 
81  const_iterator
82  begin() const
83  {
84  return nodeMap.begin();
85  }
86 
87  const_iterator
88  end() const
89  {
90  return nodeMap.end();
91  }
92 
93  iterator
95  {
96  return nodeMap.begin();
97  }
98 
99  iterator
100  end()
101  {
102  return nodeMap.end();
103  }
104 
105  void getBoundaryNodes(int geomIndex,
106  std::vector<Node*>& bdyNodes) const;
107 
108  std::string print() const;
109 
110  void
112  {
113 #ifndef NDEBUG
114  // Each Coordinate key is a pointer inside the Node value
115  for(iterator it = begin(), itEnd = end(); it != itEnd; ++it) {
116  pair p = *it;
117  geomgraph::Node* n = p.second;
118  geom::Coordinate* c = const_cast<geom::Coordinate*>(
119  &(n->getCoordinate())
120  );
121  assert(p.first == c);
122  }
123 #endif
124  }
125 
126 private:
127 
128  // Declare type as noncopyable
129  NodeMap(const NodeMap& other) = delete;
130  NodeMap& operator=(const NodeMap& rhs) = delete;
131 };
132 
133 } // namespace geos.geomgraph
134 } // namespace geos
135 
136 #ifdef _MSC_VER
137 #pragma warning(pop)
138 #endif
139 
140 #endif // ifndef GEOS_GEOMGRAPH_NODEMAP_H
#define GEOS_DLL
Definition: export.h:28
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
std::map< geom::Coordinate *, Node *, geom::CoordinateLessThen > container
virtual const geom::Coordinate & getCoordinate() const
Models the end of an edge incident on a node.
Definition: EdgeEnd.h:56
Basic namespace for all GEOS functionalities.
container::const_iterator const_iterator
const NodeFactory & nodeFact
The node component of a geometry graph.
const_iterator begin() const
const_iterator end() const
std::pair< geom::Coordinate *, Node * > pair
container::iterator iterator