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