Adding a U-turn penalty for very sharp turns. Fixes #188 and #153 and

also partially fixes #65 and #167
This commit is contained in:
DennisOSRM
2012-03-20 12:35:52 +01:00
parent 30d72543b9
commit 556e487a15
5 changed files with 40 additions and 16 deletions
+17 -3
View File
@@ -61,9 +61,21 @@ EdgeBasedGraphFactory::EdgeBasedGraphFactory(int nodes, std::vector<NodeBasedEdg
trafficSignalPenalty = 0;
}
}
if("uturnPenalty" == v.first) {
std::string value = v.second.get<std::string>("");
try {
uturnPenalty = 10*boost::lexical_cast<int>(v.second.get<std::string>(""));
} catch(boost::bad_lexical_cast &) {
uturnPenalty = 0;
}
}
if("takeMinimumOfSpeeds" == v.first) {
std::string value = v.second.get<std::string>("");
takeMinimumOfSpeeds = (v.second.get<std::string>("") == "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);
+2
View File
@@ -116,6 +116,8 @@ private:
// SRTMLookup srtmLookup;
unsigned numberOfTurnRestrictions;
unsigned trafficSignalPenalty;
unsigned uturnPenalty;
bool takeMinimumOfSpeeds;
public:
template< class InputEdgeT >