Skip to content

Commit

Permalink
Commit further changes as suggested in review
Browse files Browse the repository at this point in the history
  • Loading branch information
ratrun committed Jun 10, 2024
1 parent db4dd8a commit a6d14ff
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,9 @@ public WayAccess getAccess(ReaderWay way) {

int firstIndex = way.getFirstIndex(restrictionKeys);
if (firstIndex >= 0) {
String firstRestrictedKey = restrictionKeys.get(firstIndex);
String firstValue = way.getTag(firstRestrictedKey, "");
String firstValue = way.getTag(restrictionKeys.get(firstIndex), "");
String[] restrict = firstValue.split(";");
for (String value : restrict) {
if (value.equals("no")) {
if (firstRestrictedKey.equals("vehicle"))
return WayAccess.WAY;
}
if (restrictedValues.contains(value) && !hasTemporalRestriction(way, firstIndex, restrictionKeys))
return WayAccess.CAN_SKIP;
if (intendedValues.contains(value))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public abstract class BikeCommonAverageSpeedParser extends AbstractAverageSpeedP
private final Map<String, Integer> highwaySpeeds = new HashMap<>();
private final EnumEncodedValue<Smoothness> smoothnessEnc;
protected final Set<String> intendedValues = new HashSet<>(5);
protected final Set<String> restrictedValues = new HashSet<>(8);

protected BikeCommonAverageSpeedParser(DecimalEncodedValue speedEnc, EnumEncodedValue<Smoothness> smoothnessEnc, DecimalEncodedValue ferrySpeedEnc) {
super(speedEnc, ferrySpeedEnc);
Expand Down Expand Up @@ -116,6 +117,15 @@ protected BikeCommonAverageSpeedParser(DecimalEncodedValue speedEnc, EnumEncoded
intendedValues.add("designated");
intendedValues.add("official");
intendedValues.add("permissive");

restrictedValues.add("no");
restrictedValues.add("agricultural");
restrictedValues.add("forestry");
restrictedValues.add("restricted");
restrictedValues.add("military");
restrictedValues.add("emergency");
restrictedValues.add("private");
restrictedValues.add("permit");
}

/**
Expand Down Expand Up @@ -188,7 +198,17 @@ else if (way.hasTag("highway", pushingSectionsHighways)
}
}

if (way.hasTag("vehicle", "no") && !way.hasTag("bicycle", intendedValues))
boolean pushing_restriction = false;
String vehicleValue = way.getTag("vehicle", "");
String[] splitVehicleValues = vehicleValue.split(";");
for (String value : splitVehicleValues) {
if (restrictedValues.contains(value)) {
pushing_restriction = true;
break;
}
}

if (pushing_restriction && !way.hasTag("bicycle", intendedValues))
speed = PUSHING_SECTION_SPEED;

// Until now we assumed that the way is no pushing section
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public OSMGetOffBikeParser(BooleanEncodedValue getOffBikeEnc, BooleanEncodedValu
@Override
public void handleWayTags(int edgeId, EdgeIntAccess edgeIntAccess, ReaderWay way, IntsRef relationFlags) {
String highway = way.getTag("highway");
String vehicle = way.getTag("vehicle") == null ? "" : way.getTag("vehicle");
String vehicle = way.getTag("vehicle", "");
boolean notIntended = !way.hasTag("bicycle", INTENDED) &&
(GET_OFF_BIKE.contains(highway)
|| way.hasTag("railway", "platform")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ public void testAccess() {
assertTrue(accessParser.getAccess(way).canSkip());
way.setTag("bicycle", "no");
assertTrue(accessParser.getAccess(way).canSkip());
way.setTag("bicycle", "yes");
assertTrue(accessParser.getAccess(way).isWay());

way.setTag("highway", "path");
way.setTag("bicycle", "yes");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,13 @@ public void testSpeedAndPriority() {
way.clearTags();
way.setTag("highway", "track");
assertPriorityAndSpeed(UNCHANGED, 12, way);
way.setTag("vehicle", "no");
assertPriorityAndSpeed(UNCHANGED, PUSHING_SECTION_SPEED, way);
way.setTag("vehicle", "forestry;agricultural");
assertPriorityAndSpeed(UNCHANGED, PUSHING_SECTION_SPEED, way);

way.clearTags();
way.setTag("highway", "track");
way.setTag("tracktype", "grade1");
assertPriorityAndSpeed(UNCHANGED, 18, way);

Expand Down

0 comments on commit a6d14ff

Please sign in to comment.