From 1db1b4e5ae3bd075f705c26bfdc23a3861f84629 Mon Sep 17 00:00:00 2001 From: DennisOSRM Date: Tue, 4 Oct 2011 16:27:32 +0200 Subject: [PATCH 1/6] Removed commented speed profile --- DataStructures/ExtractorStructs.h | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/DataStructures/ExtractorStructs.h b/DataStructures/ExtractorStructs.h index 3fd5804c4..8ae7fa4f3 100644 --- a/DataStructures/ExtractorStructs.h +++ b/DataStructures/ExtractorStructs.h @@ -31,23 +31,6 @@ struct _PathData { NodeID node; }; -/* Default Speed Profile: - motorway 110 - motorway_link 90 - trunk 90 - trunk_link 70 - primary 70 - primary_link 60 - secondary 60 - secondary_link 50 - tertiary 55 - unclassified 25 - residential 40 - living_street 10 - service 30 - ferry 5 - */ - typedef google::dense_hash_map StringMap; struct _Node : NodeInfo{ @@ -174,7 +157,6 @@ struct _Restriction { char unused7:1; } flags; - _Restriction(NodeID vn) : viaNode(vn), fromNode(UINT_MAX), toNode(UINT_MAX) { } _Restriction(bool isOnly = false) : viaNode(UINT_MAX), fromNode(UINT_MAX), toNode(UINT_MAX) { flags.isOnly = isOnly; @@ -198,7 +180,6 @@ struct _RawRestrictionContainer { } }; - struct CmpRestrictionByFrom: public std::binary_function<_RawRestrictionContainer, _RawRestrictionContainer, bool> { typedef _RawRestrictionContainer value_type; bool operator () (const _RawRestrictionContainer & a, const _RawRestrictionContainer & b) const { From b1f2f2786c254ed7216a820ca7ec1de5ba727f1d Mon Sep 17 00:00:00 2001 From: DennisOSRM Date: Tue, 4 Oct 2011 17:32:33 +0200 Subject: [PATCH 2/6] speedprofile is now represented as hash table and operator[] const() has been defined. --- DataStructures/ExtractorStructs.h | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/DataStructures/ExtractorStructs.h b/DataStructures/ExtractorStructs.h index 8ae7fa4f3..69916976d 100644 --- a/DataStructures/ExtractorStructs.h +++ b/DataStructures/ExtractorStructs.h @@ -23,7 +23,7 @@ or see http://www.gnu.org/licenses/agpl.txt. #include #include -#include "HashTable.h" +#include #include "Util.h" struct _PathData { @@ -31,7 +31,7 @@ struct _PathData { NodeID node; }; -typedef google::dense_hash_map StringMap; +typedef boost::unordered_map StringMap; struct _Node : NodeInfo{ _Node(int _lat, int _lon, unsigned int _id) : NodeInfo(_lat, _lon, _id) {} @@ -237,16 +237,12 @@ struct CmpWayStartAndEnd : public std::binary_function<_WayIDStartAndEndEdge, _W }; struct Settings { - struct SpeedProfile { - vector< double > speed; - vector< string > names; - } speedProfile; - int indexInAccessListOf( const string & key) { - for(unsigned i = 0; i< speedProfile.names.size(); i++) { - if(speedProfile.names[i] == key) - return i; - } - return -1; + StringMap speedProfile; + int operator[](const string & param) const { + if(speedProfile.find(param) == speedProfile.end()) + return 0; + else + return speedProfile.at(param); } }; From cd03ad92078318dad583142875e40a7b871fea55 Mon Sep 17 00:00:00 2001 From: DennisOSRM Date: Tue, 4 Oct 2011 18:33:40 +0200 Subject: [PATCH 3/6] struct _Egde now has constructor to also set nameid --- DataStructures/ExtractorStructs.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/DataStructures/ExtractorStructs.h b/DataStructures/ExtractorStructs.h index 69916976d..6121cf108 100644 --- a/DataStructures/ExtractorStructs.h +++ b/DataStructures/ExtractorStructs.h @@ -71,7 +71,7 @@ struct _Way { _Way() : id(UINT_MAX), nameID(UINT_MAX) { direction = _Way::notSure; - maximumSpeed = -1; + speed = -1; type = -1; useful = false; access = true; @@ -83,7 +83,7 @@ struct _Way { unsigned id; unsigned nameID; std::string name; - double maximumSpeed; + double speed; short type; bool useful:1; bool access:1; @@ -123,6 +123,7 @@ struct _Edge { _Edge() : start(0), target(0), type(0), direction(0), speed(0), nameID(0) {}; _Edge(NodeID s, NodeID t) : start(s), target(t), type(0), direction(0), speed(0), nameID(0) { } _Edge(NodeID s, NodeID t, short tp, short d, double sp): start(s), target(t), type(tp), direction(d), speed(sp), nameID(0) { } + _Edge(NodeID s, NodeID t, short tp, short d, double sp, unsigned nid): start(s), target(t), type(tp), direction(d), speed(sp), nameID(nid) { } NodeID start; NodeID target; short type; @@ -237,6 +238,7 @@ struct CmpWayStartAndEnd : public std::binary_function<_WayIDStartAndEndEdge, _W }; struct Settings { + Settings() : obeyPollards(false), obeyOneways(false), useRestrictions(false), accessTag("motorcar") {} StringMap speedProfile; int operator[](const string & param) const { if(speedProfile.find(param) == speedProfile.end()) @@ -244,6 +246,11 @@ struct Settings { else return speedProfile.at(param); } + bool obeyPollards; + bool obeyOneways; + bool useRestrictions; + string accessTag; + }; struct Cmp : public std::binary_function { From cf8de234be4dd2d177a9e9c20807397321d5ca68 Mon Sep 17 00:00:00 2001 From: DennisOSRM Date: Tue, 4 Oct 2011 18:38:18 +0200 Subject: [PATCH 4/6] reflects change of _Way member name --- DataStructures/XMLParser.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DataStructures/XMLParser.h b/DataStructures/XMLParser.h index a0f3b3df9..e50b4233f 100644 --- a/DataStructures/XMLParser.h +++ b/DataStructures/XMLParser.h @@ -92,7 +92,7 @@ private: _Way _ReadXMLWay( ) { _Way way; way.direction = _Way::notSure; - way.maximumSpeed = -1; + way.speed = -1; way.type = -1; way.useful = false; way.access = true; From 0f440610b60c9b194b37dae2e972c4f9d484af05 Mon Sep 17 00:00:00 2001 From: DennisOSRM Date: Wed, 5 Oct 2011 17:57:04 +0200 Subject: [PATCH 5/6] Adding a little do{}while(false); safety to macros --- typedefs.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/typedefs.h b/typedefs.h index 078cd9f60..b050bd1fe 100644 --- a/typedefs.h +++ b/typedefs.h @@ -38,15 +38,15 @@ using namespace std; #endif #define STXXL_VERBOSE_LEVEL -100 -#define INFO(x) std::cout << "[info " << __FILE__ << ":" << __LINE__ << "] " << x << std::endl; -#define ERR(x) std::cerr << "[error " << __FILE__ << ":" << __LINE__ << "] " << x << std::endl; exit(-1); -#define WARN(x) std::cerr << "[warn " << __FILE__ << ":" << __LINE__ << "] " << x << std::endl; +#define INFO(x) do {std::cout << "[info " << __FILE__ << ":" << __LINE__ << "] " << x << std::endl;} while(0); +#define ERR(x) do {std::cerr << "[error " << __FILE__ << ":" << __LINE__ << "] " << x << std::endl; exit(-1);} while(0); +#define WARN(x) do {std::cerr << "[warn " << __FILE__ << ":" << __LINE__ << "] " << x << std::endl;} while(0); #ifdef NDEBUG #define DEBUG(x) #else -#define DEBUG(x) std::cout << "[debug " << __FILE__ << ":" << __LINE__ << "] " << x << std::endl; +#define DEBUG(x) do {std::cout << "[debug " << __FILE__ << ":" << __LINE__ << "] " << x << std::endl;} while(0); #endif -#define DELETE(x) { if(NULL != x) { delete x; x = NULL; } } +#define DELETE(x) do { if(NULL != x) { delete x; x = NULL; } }while(0); #ifndef M_PI #define M_PI 3.14159265358979323846 From 89e4d4ac305fcd136bed96cf6a4ce77cfb4e03e7 Mon Sep 17 00:00:00 2001 From: DennisOSRM Date: Wed, 5 Oct 2011 18:02:26 +0200 Subject: [PATCH 6/6] Fixes issue #17 --- Contractor/ContractionCleanup.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Contractor/ContractionCleanup.h b/Contractor/ContractionCleanup.h index b48cd30e4..56669f78c 100644 --- a/Contractor/ContractionCleanup.h +++ b/Contractor/ContractionCleanup.h @@ -171,7 +171,7 @@ private: cout << "Scanning for useless shortcuts" << endl; BuildOutgoingGraph(); #pragma omp parallel for - for ( unsigned i = 0; i < ( unsigned ) _graph.size(); i++ ) { + for ( int i = 0; i < ( int ) _graph.size(); i++ ) { for ( unsigned edge = _firstEdge[_graph[i].source]; edge < _firstEdge[_graph[i].source + 1]; ++edge ) { if ( edge == i ) continue;