diff --git a/DataStructures/NodeCoords.h b/DataStructures/NodeCoords.h index 06710fd2f..f0bed1c3a 100644 --- a/DataStructures/NodeCoords.h +++ b/DataStructures/NodeCoords.h @@ -21,13 +21,16 @@ or see http://www.gnu.org/licenses/agpl.txt. #ifndef _NODE_COORDS_H #define _NODE_COORDS_H +#include #include +#include "../typedefs.h" + template struct NodeCoords { typedef unsigned key_type; - + typedef int value_type; NodeCoords(int _lat, int _lon, NodeT _id) : lat(_lat), lon(_lon), id(_id) {} NodeCoords() : lat(UINT_MAX), lon(UINT_MAX), id(UINT_MAX) {} int lat; @@ -51,36 +54,21 @@ bool operator < (const NodeCoords & a, const NodeCoords & b) return a.id < b.id; } -struct duplet +inline int return_dup( NodeCoords n, int k ) { - typedef int value_type; - - inline value_type operator[](int const N) const { return d[N]; } - - inline bool operator==(duplet const& other) const - { - return this->d[0] == other.d[0] && this->d[1] == other.d[1]; - } - - inline bool operator!=(duplet const& other) const - { - return this->d[0] != other.d[0] || this->d[1] != other.d[1]; - } - - friend std::ostream & operator<<(std::ostream & o, duplet const& d) + switch(k) { - return o << "(" << d[0] << "," << d[1] << ")"; + case 0: + return n.lat; + break; + case 1: + return n.lon; + break; + default: + assert(false); + return UINT_MAX; + break; } - duplet(unsigned _id, int x, int y) - { - id = _id; - d[0] = x; - d[1] = y; - } - unsigned int id; - value_type d[2]; -}; - -inline double return_dup( duplet d, int k ) { return d[k]; } +} #endif //_NODE_COORDS_H diff --git a/DataStructures/NodeInformationHelpDesk.h b/DataStructures/NodeInformationHelpDesk.h index f3250dd60..ed0466cf4 100644 --- a/DataStructures/NodeInformationHelpDesk.h +++ b/DataStructures/NodeInformationHelpDesk.h @@ -40,13 +40,13 @@ or see http://www.gnu.org/licenses/agpl.txt. #include -typedef KDTree::KDTree<2, duplet, std::pointer_to_binary_function > duplet_tree_type; +typedef KDTree::KDTree<2, NodeInfo, std::pointer_to_binary_function > KDTreeType; class NodeInformationHelpDesk{ public: ~NodeInformationHelpDesk(); NodeInformationHelpDesk() { int2ExtNodeMap = new vector();} - duplet_tree_type * initKDTree(ifstream& input); + KDTreeType * initKDTree(ifstream& input); NodeID getExternalNodeID(const NodeID node); NodeInfo& getExternalNodeInfo(const NodeID node); @@ -58,15 +58,15 @@ public: inline NodeID findNearestNodeIDForLatLon(const int lat, const int lon, NodeCoords * data) const { - duplet dup = *(kdtree->find_nearest(duplet(0, lat, lon)).first); - data->id = dup.id; - data->lat = dup.d[1]; - data->lon = dup.d[0]; + NodeInfo nearestNeighbor = *(kdtree->find_nearest(NodeInfo(lat, lon, 0)).first); + data->id = nearestNeighbor.id; + data->lat = nearestNeighbor.lat; + data->lon = nearestNeighbor.lon; return data->id; } private: vector * int2ExtNodeMap; - duplet_tree_type * kdtree; + KDTreeType * kdtree; }; ////////////////// @@ -82,24 +82,22 @@ NodeInformationHelpDesk::~NodeInformationHelpDesk(){ /* @brief: initialize kd-tree and internal->external node id map * */ -duplet_tree_type * NodeInformationHelpDesk::initKDTree(ifstream& in) +KDTreeType * NodeInformationHelpDesk::initKDTree(ifstream& in) { -// NodeID i = 0; while(!in.eof()) { NodeInfo b; in.read((char *)&b, sizeof(b)); int2ExtNodeMap->push_back(b); - // i++; } in.close(); - duplet_tree_type * tree = new duplet_tree_type(std::ptr_fun(return_dup)); + KDTreeType * tree = new KDTreeType(std::ptr_fun(return_dup)); NodeID id = 0; for(vector::iterator it = int2ExtNodeMap->begin(); it != int2ExtNodeMap->end(); it++) { - duplet super_dupre(id, it->lat, it->lon); - tree->insert(super_dupre); + it->id = id; + tree->insert(*it); id++; } kdtree = tree; diff --git a/DataStructures/StaticGraph.h b/DataStructures/StaticGraph.h index 848f68a0f..32c66763b 100644 --- a/DataStructures/StaticGraph.h +++ b/DataStructures/StaticGraph.h @@ -58,8 +58,6 @@ public: ++edge; } _nodes[node].firstEdge = position; //=edge - // _nodes[node].edges = edge - lastEdge; - // _nodes[node].size = edge - lastEdge; position += edge - lastEdge; //remove } _edges.resize( position ); //(edge) @@ -125,15 +123,11 @@ public: return smallestEdge; } - private: struct _StrNode { //index of the first edge EdgeIterator firstEdge; - //amount of edges - // unsigned edges; - // unsigned size; }; struct _StrEdge {