Skip to content

Consider opening conditionals for inaccessible ways - #3168

Merged
karussell merged 3 commits into
masterfrom
open_conditionals
May 16, 2025
Merged

karussell merged 3 commits into
masterfrom
open_conditionals

Conversation

@karussell

@karussell karussell commented May 16, 2025 •

Copy link
Copy Markdown
Member

This PR now considers any conditionals that open access regardless of range parser success and also all intended values.

For e.g.

access=no
bicycle:conditional=yes @ (10:00 - 11:00)

the way is now open (with the PR). This is more consistent as there are situations like:

access=yes
bicycle:conditional=no @ (10:00 - 11:00)

or

access=no
bicycle:conditional=yes @ (Feb - Jun)

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.

@karussell karussell added this to the 11.0 milestone May 16, 2025
@karussell karussell changed the title Open conditionals Consider opening conditionals for inaccessible ways May 16, 2025
@karussell karussell added the osm label May 16, 2025
@karussell
karussell requested a review from Copilot May 16, 2025 09:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {

Copilot AI May 16, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a method-level comment summarizing how getTemporaryAccess differs from the previous getConditional method and what its intended behavior is.

Copilot uses AI. Check for mistakes.
}

private static boolean hasTemporalRestriction(String value) {
private static boolean hasTemporalRestriction(String value, Collection<String> accepted) {

Copilot AI May 16, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
ReaderWay way = new ReaderWay(1);
way.setTag("highway", "primary");
way.setTag("bicycle", "no");
way.setTag("bicycle:conditional", "permit @ (21:00-9:00)");

Copilot AI May 16, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

Copilot uses AI. Check for mistakes.
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))

Copilot AI May 16, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

Copilot uses AI. Check for mistakes.
@karussell
karussell merged commit 61a27b3 into master May 16, 2025
@karussell
karussell deleted the open_conditionals branch May 16, 2025 09:14
karussell added a commit that referenced this pull request May 19, 2025
karussell added a commit that referenced this pull request Oct 8, 2025
* use my branch and #3122

* slightly faster

* test unknown value and conditional with time only (regarding #3168)
chazab pushed a commit to rayanhidri/graphhopper that referenced this pull request Oct 10, 2025
* use my branch and graphhopper#3122

* slightly faster

* test unknown value and conditional with time only (regarding graphhopper#3168)

This branch was previously deployed

1 inactive deployment
benchmarks — 053d6e88 Deployed May 16, 2025 by karussell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants