Skip to content

Commit

Permalink
Improve bike handling for highway=living_street
Browse files Browse the repository at this point in the history
  • Loading branch information
ratrun committed Jun 28, 2024
1 parent 666dbca commit 2fbfa81
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected BikeCommonAverageSpeedParser(DecimalEncodedValue speedEnc, EnumEncoded
setSurfaceSpeed("sand", PUSHING_SECTION_SPEED);
setSurfaceSpeed("wood", PUSHING_SECTION_SPEED);

setHighwaySpeed("living_street", PUSHING_SECTION_SPEED);
setHighwaySpeed("living_street", 6);
setHighwaySpeed("steps", MIN_SPEED);

setHighwaySpeed("cycleway", 18);
Expand Down Expand Up @@ -119,6 +119,8 @@ protected BikeCommonAverageSpeedParser(DecimalEncodedValue speedEnc, EnumEncoded
*/
double applyMaxSpeed(ReaderWay way, double speed, boolean bwd) {
double maxSpeed = getMaxSpeed(way, bwd);
if (way.getTag("highway", "").equals("living_street"))
return !isValidSpeed(maxSpeed) ? highwaySpeeds.get("living_street") : maxSpeed <= highwaySpeeds.get("cycleway") ? maxSpeed : highwaySpeeds.get("cycleway");
// We strictly obey speed limits, see #600
return isValidSpeed(maxSpeed) && speed > maxSpeed ? maxSpeed : speed;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ public void testService() {
assertPriorityAndSpeed(PREFER, 12, way);

way.setTag("service", "parking_aisle");
assertPriorityAndSpeed(SLIGHT_AVOID, 4, way);
assertPriorityAndSpeed(SLIGHT_AVOID, 6, way);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ public void testSpeedAndPriority() {
way.setTag("scenic", "yes");
assertPriorityAndSpeed(AVOID_MORE, 18, way);

way.clearTags();
way.setTag("highway", "living_street");
assertPriorityAndSpeed(UNCHANGED, 6, way);
way.setTag("maxspeed", "20");
assertPriorityAndSpeed(PREFER, 18, way);
way.setTag("maxspeed", "10");
assertPriorityAndSpeed(VERY_NICE, 10, way);

// Pushing section: this is fine as we obey the law!
way.clearTags();
way.setTag("highway", "footway");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,22 @@ public void testAvoidTunnel() {
assertPriorityAndSpeed(PREFER, 20, osmWay);
}

@Test
public void testLivingStreet() {
ReaderWay osmWay = new ReaderWay(1);
osmWay.clearTags();
osmWay.setTag("highway", "living_street");
assertPriorityAndSpeed(UNCHANGED, 6, osmWay);
osmWay.setTag("maxspeed", "20");
assertPriorityAndSpeed(PREFER, 18, osmWay);
osmWay.setTag("maxspeed", "10");
assertPriorityAndSpeed(VERY_NICE, 10, osmWay);
osmWay.clearTags();
osmWay.setTag("highway", "residential");
osmWay.setTag("maxspeed", "30");
assertPriorityAndSpeed(SLIGHT_AVOID, 18, osmWay);
}

@Test
@Override
public void testService() {
Expand All @@ -93,7 +109,7 @@ public void testService() {
assertPriorityAndSpeed(SLIGHT_AVOID, 12, way);

way.setTag("service", "parking_aisle");
assertPriorityAndSpeed(SLIGHT_AVOID, 4, way);
assertPriorityAndSpeed(SLIGHT_AVOID, 6, way);
}

@Test
Expand Down

0 comments on commit 2fbfa81

Please sign in to comment.