Skip to content

Commit

Permalink
Simplification as detected by user caspg (Kacper Golinski)
Browse files Browse the repository at this point in the history
  • Loading branch information
ratrun committed Jun 11, 2024
1 parent 66ebc54 commit 56a82ce
Showing 1 changed file with 4 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public abstract class AbstractAccessParser implements TagParser {
protected final Set<String> barriers = new HashSet<>(5);
protected final BooleanEncodedValue accessEnc;
private boolean blockFords = true;
private TransportationMode transportationMode;

protected AbstractAccessParser(BooleanEncodedValue accessEnc, TransportationMode transportationMode) {
this.accessEnc = accessEnc;
Expand All @@ -36,7 +35,6 @@ protected AbstractAccessParser(BooleanEncodedValue accessEnc, TransportationMode
restrictedValues.add("permit");

restrictionKeys.addAll(OSMRoadAccessParser.toOSMRestrictions(transportationMode));
this.transportationMode = transportationMode;
}

public boolean isBlockFords() {
Expand Down Expand Up @@ -76,29 +74,16 @@ public void handleWayTags(int edgeId, EdgeIntAccess edgeIntAccess, ReaderWay way

public abstract void handleWayTags(int edgeId, EdgeIntAccess edgeIntAccess, ReaderWay way);

private String getVehicleAccessTag(){
if (this.transportationMode.isMotorVehicle())
return "motorcar";
switch (this.transportationMode) {
case FOOT:
return "foot";
case BIKE:
return "bicycle";
case VEHICLE:
return "vehicle";
case OTHER:
default:
throw new IllegalArgumentException("Unknown transportationMode");
}
}

/**
* @return true if the given OSM node blocks access for the specified restrictions, false otherwise
*/
public boolean isBarrier(ReaderNode node) {
// note that this method will be only called for certain nodes as defined by OSMReader!
String firstValue = node.getFirstValue(restrictionKeys);
if (restrictedValues.contains(firstValue) || (node.hasTag("locked", "yes") && !node.hasTag(getVehicleAccessTag(), intendedValues)))

if (restrictedValues.contains(firstValue))
return true;
else if (node.hasTag("locked", "yes") && !intendedValues.contains(firstValue))
return true;
else if (intendedValues.contains(firstValue))
return false;
Expand Down

0 comments on commit 56a82ce

Please sign in to comment.