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 #ifdef _MSC_VER
00036 #pragma warning(push)
00037 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
00038 #endif
00039
00040
00041 namespace geos {
00042 namespace geomgraph {
00043 class Node;
00044 class EdgeEnd;
00045 class NodeFactory;
00046 }
00047 }
00048
00049 namespace geos {
00050 namespace geomgraph {
00051
00052 class GEOS_DLL NodeMap{
00053 public:
00054
00055 typedef std::map<geom::Coordinate*,Node*,geom::CoordinateLessThen> container;
00056
00057 typedef container::iterator iterator;
00058
00059 typedef container::const_iterator const_iterator;
00060
00061 typedef std::pair<geom::Coordinate*,Node*> pair;
00062
00063 container nodeMap;
00064
00065 const NodeFactory &nodeFact;
00066
00070 NodeMap(const NodeFactory &newNodeFact);
00071
00072 virtual ~NodeMap();
00073
00074 Node* addNode(const geom::Coordinate& coord);
00075
00076 Node* addNode(Node *n);
00077
00078 void add(EdgeEnd *e);
00079
00080 Node *find(const geom::Coordinate& coord) const;
00081
00082 const_iterator begin() const { return nodeMap.begin(); }
00083
00084 const_iterator end() const { return nodeMap.end(); }
00085
00086 iterator begin() { return nodeMap.begin(); }
00087
00088 iterator end() { return nodeMap.end(); }
00089
00090 void getBoundaryNodes(int geomIndex,
00091 std::vector<Node*>&bdyNodes) const;
00092
00093 std::string print() const;
00094
00095 void testInvariant()
00096 {
00097 #ifndef NDEBUG
00098
00099 for (iterator it=begin(), itEnd=end(); it != itEnd; ++it)
00100 {
00101 pair p = *it;
00102 geomgraph::Node* n = p.second;
00103 geom::Coordinate* c = const_cast<geom::Coordinate*>(
00104 &(n->getCoordinate())
00105 );
00106 assert(p.first == c);
00107 }
00108 #endif
00109 }
00110
00111 private:
00112
00113
00114 NodeMap(const NodeMap& other);
00115 NodeMap& operator=(const NodeMap& rhs);
00116 };
00117
00118 }
00119 }
00120
00121
00122
00123
00124
00125 #ifdef _MSC_VER
00126 #pragma warning(pop)
00127 #endif
00128
00129 #endif // ifndef GEOS_GEOMGRAPH_NODEMAP_H
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143