Repository navigation
Add support tag combinations cycleway:left and cycleway:right, fixes #2969 - #2970
Merged
Merged
Conversation
karussell
reviewed
Apr 15, 2024
| 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)) { |
Member
There was a problem hiding this comment.
I do not understand this logic with getFirstMatchingValue. What are you trying to do here? Couldn't we keep using getFirstValue and then call searchedValues.contains here?
Member
There was a problem hiding this comment.
E.g. the following code would also make the test pass:
String cycleway = way.getFirstValue(Arrays.asList("cycleway", "cycleway:left", "cycleway:both"));
Collection<String> values = Arrays.asList("lane", "opposite_track", "shared_lane", "share_busway", "shoulder");
if (values.contains(cycleway) || values.contains(way.getTag("cycleway:right", ""))) {Or what about the (IMO relative simple) code which collects all the cycleway values:
List<String> values = Arrays.asList("lane", "opposite_track", "track", "shared_lane", "share_busway", "shoulder");
List<String> cyclewayValues = Stream.of("cycleway", "cycleway:left", "cycleway:both", "cycleway:right").map(key -> way.getTag(key, "")).filter(values::contains).toList();
if (cyclewayValues.contains("track")) {
weightToPrioMap.put(100d, PREFER);
} else if (!cyclewayValues.isEmpty()) {
weightToPrioMap.put(100d, SLIGHT_PREFER);
}or
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);
}
Contributor
Author
There was a problem hiding this comment.
I like your last suggestion the most and will update the PR accordingly.
Member
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes #2969