diff --git a/DataStructures/ExtractorCallBacks.h b/DataStructures/ExtractorCallBacks.h index eb394493d..d84a5ebfc 100644 --- a/DataStructures/ExtractorCallBacks.h +++ b/DataStructures/ExtractorCallBacks.h @@ -101,7 +101,7 @@ public: std::string oneway( w.keyVals.Find("oneway")); std::string junction( w.keyVals.Find("junction") ); std::string route( w.keyVals.Find("route") ); - double maxspeed( atoi(w.keyVals.Find("maxspeed").c_str()) ); + int maxspeed( atoi(w.keyVals.Find("maxspeed").c_str()) ); std::string access( w.keyVals.Find("access") ); std::string accessTag( w.keyVals.Find(settings.accessTag) ); std::string man_made( w.keyVals.Find("man_made") ); @@ -119,12 +119,17 @@ public: } //Is the highway tag listed as usable way? - if(0 < settings[highway]) { + if(0 < settings[highway] || "yes" == accessTag || "designated" == accessTag) { - if(0 < maxspeed) - w.speed = maxspeed; - else - w.speed = settings[highway]; + if(0 < settings[highway]) { + if(0 < maxspeed) + w.speed = std::min(maxspeed, settings[highway]); + else + w.speed = settings[highway]; + } else { + w.speed = settings.defaultSpeed; + highway = "default"; + } w.useful = true; //Okay, do we have access to that way? @@ -135,9 +140,6 @@ public: } } - if("yes" == accessTag || "designated" == accessTag) { - w.access = true; - } if("no" == accessTag) { return true; } @@ -158,11 +160,16 @@ public: w.useful = true; w.speed = settings[route]; w.direction = _Way::bidirectional; + if(0 < settings[route]) + highway = route; + else if (0 < settings[man_made]) { + highway = man_made; + } } } if ( w.useful && w.access && (1 < w.path.size()) ) { //Only true if the way is specified by the speed profile //TODO: type is not set, perhaps use a bimap'ed speed profile to do set the type correctly? - w.type = 1; + w.type = settings.GetHighwayTypeID(highway); //Get the unique identifier for the street name const StringMap::const_iterator strit = stringMap->find(w.name); diff --git a/DataStructures/ExtractorStructs.h b/DataStructures/ExtractorStructs.h index 864b05761..5abfd67cd 100644 --- a/DataStructures/ExtractorStructs.h +++ b/DataStructures/ExtractorStructs.h @@ -35,7 +35,8 @@ struct _PathData { short turnInstruction; }; -typedef boost::unordered_map StringMap; +typedef boost::unordered_map StringMap; +typedef boost::unordered_map > StringToIntPairMap; struct _Node : NodeInfo{ _Node(int _lat, int _lon, unsigned int _id) : NodeInfo(_lat, _lon, _id) {} @@ -254,19 +255,28 @@ struct CmpWayByID : public std::binary_function<_WayIDStartAndEndEdge, _WayIDSta }; struct Settings { - Settings() : obeyPollards(true), obeyOneways(true), useRestrictions(true), accessTag("motorcar") {} - StringMap speedProfile; - int operator[](const string & param) const { + Settings() : obeyPollards(true), obeyOneways(true), useRestrictions(true), accessTag("motorcar"), defaultSpeed(30), excludeFromGrid("ferry") {} + StringToIntPairMap speedProfile; + int operator[](const std::string & param) const { if(speedProfile.find(param) == speedProfile.end()) return 0; else - return speedProfile.at(param); + return speedProfile.at(param).first; + } + int GetHighwayTypeID(const std::string & param) const { + if(speedProfile.find(param) == speedProfile.end()) { + DEBUG("There is a bug with highway \"" << param << "\""); + return -1; + } else { + return speedProfile.at(param).second; + } } bool obeyPollards; bool obeyOneways; bool useRestrictions; - string accessTag; - + std::string accessTag; + int defaultSpeed; + std::string excludeFromGrid; }; struct Cmp : public std::binary_function {