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
+18 -10
View File
@@ -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;
+2 -2
View File
@@ -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;
};
+1 -1
View File
@@ -101,7 +101,7 @@ struct TurnInstructionsClass {
if (angle >= 292 && angle < 336) {
return TurnSharpLeft;
}
return 5;
return UTurn;
}
static inline bool TurnIsNecessary ( const short turnInstruction ) {