Repository navigation
Consider opening conditionals for inaccessible ways - #3168
Conversation
… success and consider all intended values
There was a problem hiding this comment.
Pull Request Overview
This PR updates the handling of conditional access tags to allow opening ways based on a broader set of intended values and improves consistency across parsers. Key changes include:
- Renaming and refactoring methods in OSMTemporalAccessParser to use getTemporaryAccess and an updated hasTemporalRestriction signature.
- Updating test cases in CarTagParserTest, BikeTagParserTest, and OSMTemporalAccessParserTest to cover additional conditional tag scenarios.
- Adjusting calls in ModeAccessParser, FootAccessParser, CarAccessParser, and BikeCommonAccessParser to pass an appropriate accepted/ intended values parameter.
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| core/src/test/java/com/graphhopper/routing/util/parsers/OSMTemporalAccessParserTest.java | Added tests to ensure conditionals with various intended values are correctly interpreted. |
| core/src/test/java/com/graphhopper/routing/util/parsers/CarTagParserTest.java | Added test cases for opening access when conditional parsing fails and handling non-intended values. |
| core/src/test/java/com/graphhopper/routing/util/parsers/BikeTagParserTest.java | Added tests for bicycle access with permit and updated test naming. |
| core/src/main/java/com/graphhopper/routing/util/parsers/OSMTemporalAccessParser.java | Refactored method names and signatures to generalize conditional evaluation logic. |
| core/src/main/java/com/graphhopper/routing/util/parsers/ModeAccessParser.java CarAccessParser.java BikeCommonAccessParser.java FootAccessParser.java |
Updated calls to hasTemporalRestriction to include the new accepted values parameter. |
| } | ||
|
|
||
| Boolean getConditional(Map<String, Object> tags) { | ||
| private Boolean getTemporaryAccess(Map<String, Object> tags) { |
There was a problem hiding this comment.
Consider adding a method-level comment summarizing how getTemporaryAccess differs from the previous getConditional method and what its intended behavior is.
| } | ||
|
|
||
| private static boolean hasTemporalRestriction(String value) { | ||
| private static boolean hasTemporalRestriction(String value, Collection<String> accepted) { |
There was a problem hiding this comment.
It would be helpful to update the method documentation to describe the accepted parameter and its role in determining conditional access, especially since previous defaults like GENERIC_ACCEPTED_VALUES have been removed.
| ReaderWay way = new ReaderWay(1); | ||
| way.setTag("highway", "primary"); | ||
| way.setTag("bicycle", "no"); | ||
| way.setTag("bicycle:conditional", "permit @ (21:00-9:00)"); |
There was a problem hiding this comment.
[nitpick] Since the test 'temporalAccessWithPermit' behaves differently on subsequent calls, please add an inline comment to clarify the rationale behind toggling the access state for permit values for future maintainability.
| int firstIndex = way.getFirstIndex(restrictionKeys); | ||
| String firstValue = firstIndex < 0 ? "" : way.getTag(restrictionKeys.get(firstIndex), ""); | ||
| if (restrictedValues.contains(firstValue) && !hasTemporalRestriction(way, firstIndex, restrictionKeys)) | ||
| if (restrictedValues.contains(firstValue) && !hasTemporalRestriction(way, firstIndex, restrictionKeys, INTENDED)) |
There was a problem hiding this comment.
[nitpick] Consider adding a brief inline comment to explain what the 'INTENDED' parameter represents in this context and why it is used to check conditional access.
* use my branch and graphhopper#3122 * slightly faster * test unknown value and conditional with time only (regarding graphhopper#3168)
This PR now considers any conditionals that open access regardless of range parser success and also all intended values.
For e.g.
the way is now open (with the PR). This is more consistent as there are situations like:
or
which are already open.
Furthermore all conditional tags can be displayed via path details like we do for GraphHopper Maps already.
Another problem was that only yes/no was considered as conditional values for opening up xy_access but now all intendedValues are.