Skip to content

Commit

Permalink
Include review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ratrun committed Apr 15, 2024
1 parent 1d6b5d9 commit b6ee060
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 23 deletions.
14 changes: 0 additions & 14 deletions core/src/main/java/com/graphhopper/reader/ReaderElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,20 +161,6 @@ public boolean hasTag(List<String> keyList, Object value) {
return false;
}

/**
* Returns the first matching value of the specified list of keys where the order is important.
*
* @return an empty string if nothing found or the value does not match to one of the list of expected values
*/
public String getFirstMatchingValue(List<String> searchedTags, List<String> searchedValues) {
for (String str : searchedTags) {
Object value = properties.get(str);
if ((value != null) && (searchedValues.contains(value)))
return (String) value;
}
return "";
}

/**
* Returns the first existing value of the specified list of keys where the order is important.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,15 +183,12 @@ void collect(ReaderWay way, double wayTypeSpeed, TreeMap<Double, PriorityCode> w
weightToPrioMap.put(50d, worse == EXCLUDE ? REACH_DESTINATION : worse);
}
}
final List<String> searchedTags = Arrays.asList("cycleway", "cycleway:left", "cycleway:right", "cycleway:both");
final List<String> slightPreferredTags = Arrays.asList("lane", "opposite_track", "shared_lane", "share_busway", "shoulder");
final List<String> preferredTags = Arrays.asList("track");
final List<String> searchedValues = Stream.concat(slightPreferredTags.stream(), preferredTags.stream()).toList();
String cycleway = way.getFirstMatchingValue(searchedTags , searchedValues);
if (slightPreferredTags.contains(cycleway)) {
weightToPrioMap.put(100d, SLIGHT_PREFER);
} else if ("track".equals(cycleway)) {

List<String> cyclewayValues = Stream.of("cycleway", "cycleway:left", "cycleway:both", "cycleway:right").map(key -> way.getTag(key, "")).toList();
if (cyclewayValues.contains("track")) {
weightToPrioMap.put(100d, PREFER);
} else if (Stream.of("lane", "opposite_track", "shared_lane", "share_busway", "shoulder").anyMatch(cyclewayValues::contains)) {
weightToPrioMap.put(100d, SLIGHT_PREFER);
}

if (way.hasTag("bicycle", "use_sidepath")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import com.graphhopper.reader.ReaderNode;
import com.graphhopper.reader.ReaderRelation;
import com.graphhopper.reader.ReaderWay;
import com.graphhopper.reader.osm.conditional.DateRangeParser;
import com.graphhopper.routing.ev.*;
import com.graphhopper.routing.util.EncodingManager;
import com.graphhopper.routing.util.PriorityCode;
Expand Down

0 comments on commit b6ee060

Please sign in to comment.