Skip to content

Commit

Permalink
feed conditional restrictions as key+value pair as suggested in graph…
Browse files Browse the repository at this point in the history
  • Loading branch information
ratrun committed Aug 6, 2023
1 parent ea147ae commit 1ab5b04
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
15 changes: 15 additions & 0 deletions core/src/main/java/com/graphhopper/reader/osm/OSMReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,15 @@ protected void preprocessWay(ReaderWay way, WaySegmentParser.CoordinateSupplier
if (way.hasTag("destination:backward"))
list.add(new KVStorage.KeyValue(STREET_DESTINATION, fixWayName(way.getTag("destination:backward")), false, true));
}

String condition = fixCondition(way.getTag("access:conditional"));
if (!condition.isEmpty())
list.add(new KVStorage.KeyValue(ACCESS_CONDITION, condition));
else {
condition = fixCondition(way.getTag("vehicle:conditional"));
if (!condition.isEmpty())
list.add(new KVStorage.KeyValue(ACCESS_CONDITION, condition));
}
}
way.setTag("key_values", list);

Expand Down Expand Up @@ -501,6 +510,12 @@ static String fixWayName(String str) {
return KVStorage.cutString(WAY_NAME_PATTERN.matcher(str).replaceAll(", "));
}

static String fixCondition(String str) {
if (str == null)
return "";
return KVStorage.cutString(str);
}

/**
* @return the distance of the given way or NaN if some nodes were missing
*/
Expand Down
1 change: 1 addition & 0 deletions core/src/main/java/com/graphhopper/search/KVStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,7 @@ public static class KeyValue {
public static final String STREET_REF = "street_ref";
public static final String STREET_DESTINATION = "street_destination";
public static final String STREET_DESTINATION_REF = "street_destination_ref";
public static final String ACCESS_CONDITION = "access_condition";

public String key;
public Object value;
Expand Down

0 comments on commit 1ab5b04

Please sign in to comment.