00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef GEOS_GEOMGRAPH_NODEMAP_H
00019 #define GEOS_GEOMGRAPH_NODEMAP_H
00020
00021 #include <map>
00022 #include <vector>
00023 #include <string>
00024
00025 #include <geos/geom/Coordinate.h>
00026 #include <geos/geomgraph/Node.h>
00027
00028 #include <geos/inline.h>
00029
00030
00031 namespace geos {
00032 namespace geomgraph {
00033 class Node;
00034 class EdgeEnd;
00035 class NodeFactory;
00036 }
00037 }
00038
00039 namespace geos {
00040 namespace geomgraph {
00041
00042 class NodeMap{
00043 public:
00044
00045 typedef std::map<geom::Coordinate*,Node*,geom::CoordinateLessThen> container;
00046
00047 typedef container::iterator iterator;
00048
00049 typedef container::const_iterator const_iterator;
00050
00051 typedef std::pair<geom::Coordinate*,Node*> pair;
00052
00053 container nodeMap;
00054
00055 const NodeFactory &nodeFact;
00056
00060 NodeMap(const NodeFactory &newNodeFact);
00061
00062 virtual ~NodeMap();
00063
00064 Node* addNode(const geom::Coordinate& coord);
00065
00066 Node* addNode(Node *n);
00067
00068 void add(EdgeEnd *e);
00069
00070 Node *find(const geom::Coordinate& coord) const;
00071
00072 const_iterator begin() const { return nodeMap.begin(); }
00073
00074 const_iterator end() const { return nodeMap.end(); }
00075
00076 iterator begin() { return nodeMap.begin(); }
00077
00078 iterator end() { return nodeMap.end(); }
00079
00080 void getBoundaryNodes(int geomIndex,
00081 std::vector<Node*>&bdyNodes) const;
00082
00083 std::string print() const;
00084
00085 void testInvariant()
00086 {
00087 #ifndef NDEBUG
00088
00089 for (iterator it=begin(), itEnd=end(); it != itEnd; ++it)
00090 {
00091 pair p = *it;
00092 geomgraph::Node* n = p.second;
00093 geom::Coordinate* c = const_cast<geom::Coordinate*>(
00094 &(n->getCoordinate())
00095 );
00096 assert(p.first == c);
00097 }
00098 #endif
00099 }
00100 };
00101
00102 }
00103 }
00104
00105
00106
00107
00108
00109 #endif // ifndef GEOS_GEOMGRAPH_NODEMAP_H
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123