diff --git a/Contractor/EdgeBasedGraphFactory.cpp b/Contractor/EdgeBasedGraphFactory.cpp index 1a25ed9d7..950b4bbff 100644 --- a/Contractor/EdgeBasedGraphFactory.cpp +++ b/Contractor/EdgeBasedGraphFactory.cpp @@ -61,9 +61,21 @@ EdgeBasedGraphFactory::EdgeBasedGraphFactory(int nodes, std::vector(""); + try { + uturnPenalty = 10*boost::lexical_cast(v.second.get("")); + } catch(boost::bad_lexical_cast &) { + uturnPenalty = 0; + } + } + if("takeMinimumOfSpeeds" == v.first) { + std::string value = v.second.get(""); + takeMinimumOfSpeeds = (v.second.get("") == "yes"); + } } - INFO("traffic signal penalty: " << trafficSignalPenalty); +// INFO("traffic signal penalty: " << trafficSignalPenalty << ", U-Turn penalty: " << uturnPenalty << ", takeMinimumOfSpeeds=" << (takeMinimumOfSpeeds ? "yes" : "no")); BOOST_FOREACH(NodeID id, bn) _barrierNodes[id] = true; @@ -221,12 +233,14 @@ void EdgeBasedGraphFactory::Run() { assert(edgeData2.edgeBasedNodeID < _nodeBasedGraph->GetNumberOfEdges()); unsigned distance = edgeData1.distance; - //distance += heightPenalty; - //distance += ComputeTurnPenalty(u, v, w); if(_trafficLights.find(v) != _trafficLights.end()) { distance += trafficSignalPenalty; } short turnInstruction = AnalyzeTurn(u, v, w); + if(turnInstruction == TurnInstructions.UTurn) + distance += uturnPenalty; + //distance += heightPenalty; + //distance += ComputeTurnPenalty(u, v, w); assert(edgeData1.edgeBasedNodeID != edgeData2.edgeBasedNodeID); EdgeBasedEdge newEdge(edgeData1.edgeBasedNodeID, edgeData2.edgeBasedNodeID, v, edgeData2.nameID, distance, true, false, turnInstruction); edgeBasedEdges.push_back(newEdge); diff --git a/Contractor/EdgeBasedGraphFactory.h b/Contractor/EdgeBasedGraphFactory.h index 64ac2eb60..d53bb1cb1 100644 --- a/Contractor/EdgeBasedGraphFactory.h +++ b/Contractor/EdgeBasedGraphFactory.h @@ -116,6 +116,8 @@ private: // SRTMLookup srtmLookup; unsigned numberOfTurnRestrictions; unsigned trafficSignalPenalty; + unsigned uturnPenalty; + bool takeMinimumOfSpeeds; public: template< class InputEdgeT > diff --git a/DataStructures/ExtractorCallBacks.h b/DataStructures/ExtractorCallBacks.h index b970d0565..6578fc8e2 100644 --- a/DataStructures/ExtractorCallBacks.h +++ b/DataStructures/ExtractorCallBacks.h @@ -176,14 +176,22 @@ public: //Is the highway tag listed as usable way? if(("track" == highway && ("yes" == access || "yes" == accessTag)) || ("track" != highway && (0 < settings[highway] || "yes" == accessTag || "designated" == accessTag) )) { - if(!w.isDurationSet) { + if(!w.isDurationSet) { if(0 < settings[highway]) { if(0 < maxspeed) - w.speed = maxspeed; + if(settings.takeMinimumOfSpeeds) + w.speed = std::min(settings[highway], maxspeed); + else + w.speed = maxspeed; else w.speed = settings[highway]; } else { - w.speed = settings.defaultSpeed; + if(0 < maxspeed) + if(settings.takeMinimumOfSpeeds) + w.speed = std::min(settings.defaultSpeed, maxspeed); + else w.speed = maxspeed; + else + w.speed = settings.defaultSpeed; highway = "default"; } } @@ -202,15 +210,15 @@ public: } if( settings.obeyOneways ) { - if( onewayClass == "yes" || onewayClass == "1" || onewayClass == "true" ) { + if( onewayClass == "yes" || onewayClass == "1" || onewayClass == "true" ) { w.direction = _Way::oneway; - } else if( onewayClass == "no" || onewayClass == "0" || onewayClass == "false" ) { - w.direction = _Way::bidirectional; - } else if( onewayClass == "-1" ) { - w.direction = _Way::opposite; - } else if( oneway == "no" || oneway == "0" || oneway == "false" ) { + } else if( onewayClass == "no" || onewayClass == "0" || onewayClass == "false" ) { w.direction = _Way::bidirectional; - } else if( settings.accessTag == "bicycle" && (cycleway == "opposite" || cycleway == "opposite_track" || cycleway == "opposite_lane") ) { + } else if( onewayClass == "-1" ) { + w.direction = _Way::opposite; + } else if( oneway == "no" || oneway == "0" || oneway == "false" ) { + w.direction = _Way::bidirectional; + } else if( settings.accessTag == "bicycle" && (cycleway == "opposite" || cycleway == "opposite_track" || cycleway == "opposite_lane") ) { w.direction = _Way::bidirectional; } else if( oneway == "-1") { w.direction = _Way::opposite; diff --git a/DataStructures/ExtractorStructs.h b/DataStructures/ExtractorStructs.h index ed14200a0..0b0318c69 100644 --- a/DataStructures/ExtractorStructs.h +++ b/DataStructures/ExtractorStructs.h @@ -265,7 +265,7 @@ struct CmpWayByID : public std::binary_function<_WayIDStartAndEndEdge, _WayIDSta }; struct Settings { - Settings() : obeyBollards(true), obeyOneways(true), useRestrictions(true), accessTag("motorcar"), defaultSpeed(30), trafficLightPenalty(0), excludeFromGrid("ferry") {} + Settings() : obeyBollards(true), obeyOneways(true), useRestrictions(true), accessTag("motorcar"), defaultSpeed(30), takeMinimumOfSpeeds(false), excludeFromGrid("ferry") {} StringToIntPairMap speedProfile; int operator[](const std::string & param) const { if(speedProfile.find(param) == speedProfile.end()) @@ -290,7 +290,7 @@ struct Settings { bool useRestrictions; std::string accessTag; int defaultSpeed; - int trafficLightPenalty; + bool takeMinimumOfSpeeds; std::string excludeFromGrid; }; diff --git a/DataStructures/TurnInstructions.h b/DataStructures/TurnInstructions.h index 484ce7ea9..bb45db5c1 100644 --- a/DataStructures/TurnInstructions.h +++ b/DataStructures/TurnInstructions.h @@ -101,7 +101,7 @@ struct TurnInstructionsClass { if (angle >= 292 && angle < 336) { return TurnSharpLeft; } - return 5; + return UTurn; } static inline bool TurnIsNecessary ( const short turnInstruction ) {