From 03de87c2134b388adfb0ef5d4a9d2795095a2a64 Mon Sep 17 00:00:00 2001 From: DennisOSRM Date: Sun, 27 Jan 2013 23:06:23 +0100 Subject: [PATCH] Parsing duration when present --- Extractor/ExtractorCallbacks.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Extractor/ExtractorCallbacks.cpp b/Extractor/ExtractorCallbacks.cpp index 3db1d8d8b..956a9fee4 100644 --- a/Extractor/ExtractorCallbacks.cpp +++ b/Extractor/ExtractorCallbacks.cpp @@ -67,8 +67,7 @@ bool ExtractorCallbacks::restrictionFunction(_RawRestrictionContainer &r) { bool ExtractorCallbacks::wayFunction(_Way &w) { /*** Store name of way and split it into edge segments ***/ - if ( w.speed > 0 ) { //Only true if the way is specified by the speed profile - + if ( 0 < w.speed > 0 || 0 < w.duration ) { //Only true if the way is specified by the speed profile //Get the unique identifier for the street name const StringMap::const_iterator strit = stringMap->find(w.name); if(strit == stringMap->end()) { @@ -79,6 +78,11 @@ bool ExtractorCallbacks::wayFunction(_Way &w) { w.nameID = strit->second; } + if(w.duration > 0) { + //TODO: iterate all way segments and set duration corresponding to the length of each segment + w.speed = w.duration/(w.path.size()-1); + } + if(fabs(-1. - w.speed) < FLT_EPSILON){ WARN("found way with bogus speed, id: " << w.id); return true; @@ -93,7 +97,7 @@ bool ExtractorCallbacks::wayFunction(_Way &w) { } for(std::vector< NodeID >::size_type n = 0; n < w.path.size()-1; ++n) { - externalMemory->allEdges.push_back(_Edge(w.path[n], w.path[n+1], w.type, w.direction, w.speed, w.nameID, w.roundabout, w.ignoreInGrid, w.isDurationSet, w.isAccessRestricted)); + externalMemory->allEdges.push_back(_Edge(w.path[n], w.path[n+1], w.type, w.direction, w.speed, w.nameID, w.roundabout, w.ignoreInGrid, (w.duration > 0), w.isAccessRestricted)); externalMemory->usedNodeIDs.push_back(w.path[n]); } externalMemory->usedNodeIDs.push_back(w.path.back());