From 13f5baf6087439af4cd1d247d75a948eb5ec3aee Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Mon, 5 Aug 2013 19:35:47 +0200 Subject: [PATCH] Moving node data structure into more meaningful class name --- Algorithms/StronglyConnectedComponents.h | 2 +- DataStructures/ImportNode.h | 4 +- DataStructures/NodeInformationHelpDesk.h | 2 +- DataStructures/{NodeCoords.h => QueryNode.h} | 41 ++++++++++++-------- Extractor/ExtractorStructs.h | 2 +- Util/GraphLoader.h | 2 +- 6 files changed, 30 insertions(+), 23 deletions(-) rename DataStructures/{NodeCoords.h => QueryNode.h} (63%) diff --git a/Algorithms/StronglyConnectedComponents.h b/Algorithms/StronglyConnectedComponents.h index c688a050b..b7d288714 100644 --- a/Algorithms/StronglyConnectedComponents.h +++ b/Algorithms/StronglyConnectedComponents.h @@ -28,7 +28,7 @@ Strongly connected components using Tarjan's Algorithm #include "../DataStructures/DeallocatingVector.h" #include "../DataStructures/DynamicGraph.h" #include "../DataStructures/ImportEdge.h" -#include "../DataStructures/NodeCoords.h" +#include "../DataStructures/QueryNode.h" #include "../DataStructures/Percent.h" #include "../DataStructures/Restriction.h" #include "../DataStructures/TurnInstructions.h" diff --git a/DataStructures/ImportNode.h b/DataStructures/ImportNode.h index b9c27beff..28c9341c1 100644 --- a/DataStructures/ImportNode.h +++ b/DataStructures/ImportNode.h @@ -21,7 +21,7 @@ or see http://www.gnu.org/licenses/agpl.txt. #ifndef IMPORTNODE_H_ #define IMPORTNODE_H_ -#include "NodeCoords.h" +#include "QueryNode.h" #include "../DataStructures/HashTable.h" @@ -44,7 +44,7 @@ struct _Node : NodeInfo{ struct ImportNode : public _Node { HashTable keyVals; - + inline void Clear() { keyVals.EraseAll(); lat = 0; lon = 0; id = 0; bollard = false; trafficLight = false; diff --git a/DataStructures/NodeInformationHelpDesk.h b/DataStructures/NodeInformationHelpDesk.h index 4ec7ac1f3..773a29e51 100644 --- a/DataStructures/NodeInformationHelpDesk.h +++ b/DataStructures/NodeInformationHelpDesk.h @@ -21,7 +21,7 @@ or see http://www.gnu.org/licenses/agpl.txt. #ifndef NODEINFORMATIONHELPDESK_H_ #define NODEINFORMATIONHELPDESK_H_ -#include "NodeCoords.h" +#include "QueryNode.h" #include "PhantomNodes.h" #include "StaticRTree.h" #include "../Contractor/EdgeBasedGraphFactory.h" diff --git a/DataStructures/NodeCoords.h b/DataStructures/QueryNode.h similarity index 63% rename from DataStructures/NodeCoords.h rename to DataStructures/QueryNode.h index c2f62430b..6e9386efb 100644 --- a/DataStructures/NodeCoords.h +++ b/DataStructures/QueryNode.h @@ -24,31 +24,40 @@ or see http://www.gnu.org/licenses/agpl.txt. #include "Coordinate.h" #include "../typedefs.h" -#include +#include + #include #include #include -template -struct NodeCoords { - typedef unsigned key_type; //type of NodeID +struct NodeInfo { + typedef NodeID key_type; //type of NodeID typedef int value_type; //type of lat,lons - NodeCoords(int _lat, int _lon, NodeT _id) : lat(_lat), lon(_lon), id(_id) {} - NodeCoords() : lat(INT_MAX), lon(INT_MAX), id(UINT_MAX) {} + NodeInfo(int _lat, int _lon, NodeID _id) : lat(_lat), lon(_lon), id(_id) {} + NodeInfo() : lat(INT_MAX), lon(INT_MAX), id(UINT_MAX) {} int lat; int lon; - NodeT id; + NodeID id; - static NodeCoords min_value() { - return NodeCoords(-90*COORDINATE_PRECISION,-180*COORDINATE_PRECISION,std::numeric_limits::min()); - } - static NodeCoords max_value() { - return NodeCoords(90*COORDINATE_PRECISION, 180*COORDINATE_PRECISION, std::numeric_limits::max()); + static NodeInfo min_value() { + return NodeInfo( + -90*COORDINATE_PRECISION, + -180*COORDINATE_PRECISION, + std::numeric_limits::min() + ); } - value_type operator[](std::size_t n) const { + static NodeInfo max_value() { + return NodeInfo( + 90*COORDINATE_PRECISION, + 180*COORDINATE_PRECISION, + std::numeric_limits::max() + ); + } + + value_type operator[](const std::size_t n) const { switch(n) { case 1: return lat; @@ -57,15 +66,13 @@ struct NodeCoords { return lon; break; default: - assert(false); + BOOST_ASSERT_MSG(false, "should not happen"); return UINT_MAX; break; } - assert(false); + BOOST_ASSERT_MSG(false, "should not happen"); return UINT_MAX; } }; -typedef NodeCoords NodeInfo; - #endif //_NODE_COORDS_H diff --git a/Extractor/ExtractorStructs.h b/Extractor/ExtractorStructs.h index b481469f6..2d8134264 100644 --- a/Extractor/ExtractorStructs.h +++ b/Extractor/ExtractorStructs.h @@ -25,7 +25,7 @@ or see http://www.gnu.org/licenses/agpl.txt. #include "../DataStructures/Coordinate.h" #include "../DataStructures/HashTable.h" #include "../DataStructures/ImportNode.h" -#include "../DataStructures/NodeCoords.h" +#include "../DataStructures/QueryNode.h" #include "../DataStructures/Restriction.h" #include "../DataStructures/TimingUtil.h" #include "../typedefs.h" diff --git a/Util/GraphLoader.h b/Util/GraphLoader.h index 0e46db304..7069e64da 100644 --- a/Util/GraphLoader.h +++ b/Util/GraphLoader.h @@ -24,7 +24,7 @@ or see http://www.gnu.org/licenses/agpl.txt. #include "OSRMException.h" #include "../DataStructures/ImportNode.h" #include "../DataStructures/ImportEdge.h" -#include "../DataStructures/NodeCoords.h" +#include "../DataStructures/QueryNode.h" #include "../DataStructures/Restriction.h" #include "../Util/UUID.h" #include "../typedefs.h"