-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Apply correct traversal permissions to barrier vertex #5369
Conversation
Osm contains nodes tagged as access=no and which represent an end point of a way. For example, a doorway leading to a locked gate is sometimes modeled like that. If routing request snaps to such end point, routing fails. Barrier end vertices do not add any kind of useful functionality but just cause trouble.
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## dev-2.x #5369 +/- ##
=============================================
+ Coverage 66.50% 66.53% +0.02%
- Complexity 15235 15255 +20
=============================================
Files 1785 1787 +2
Lines 69271 69303 +32
Branches 7291 7301 +10
=============================================
+ Hits 46069 46110 +41
+ Misses 20733 20719 -14
- Partials 2469 2474 +5
☔ View full report in Codecov by Sentry. |
src/main/java/org/opentripplanner/graph_builder/module/osm/OsmModule.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One small thing, otherwise this looks good.
src/main/java/org/opentripplanner/openstreetmap/model/OSMNode.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opentripplanner/street/model/vertex/BarrierVertex.java
Outdated
Show resolved
Hide resolved
@@ -35,13 +36,15 @@ public boolean hasCrossingTrafficLight() { | |||
return hasTag("crossing") && "traffic_signals".equals(getTag("crossing")); | |||
} | |||
|
|||
/** | |||
* Checks if this node is bollard | |||
static final Set<String> motorVehicleBarriers = Set.of("bollard", "bar", "chain"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think static variables belong to the top of the class and should be named like MOTOR_VEHICLE_BARRIERS
public boolean isBollard() { | ||
return isTag("barrier", "bollard"); | ||
public boolean isMotorVehicleBarrier() { | ||
var barrier = this.getTag("barrier"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's too late now because I don't want to hold up the merge of this PR but whenever we touch this code again, there is the following new helper method for checking if it's one of a set of tag values:
OpenTripPlanner/src/main/java/org/opentripplanner/openstreetmap/model/OSMWithTags.java
Lines 230 to 235 in f664f77
/** | |
* Takes a tag key and checks if the value is any of those in {@code oneOfTags}. | |
*/ | |
public boolean isOneOfTags(String key, Set<String> oneOfTags) { | |
return oneOfTags.stream().anyMatch(value -> isTag(key, value)); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yes, I forgot that new method. Let's fix this in some upcoming OSM related PR.
Summary
Two bug fixes in barrier vertex:
Issue
Closes #5353
Unit tests
Tests updated to reflect correct barrier permissions. One new unit test which tests barrier pruning added.
Documentation
Javadoc updated