-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Extend support for more kinds of barriers, including node and ways, and blocking pedestrians / bicycles in addition to motor vehicles #6774
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
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## dev-2.x #6774 +/- ##
=============================================
+ Coverage 71.96% 72.08% +0.12%
- Complexity 19423 19517 +94
=============================================
Files 2099 2105 +6
Lines 78756 78966 +210
Branches 7970 8003 +33
=============================================
+ Hits 56680 56926 +246
+ Misses 19257 19225 -32
+ Partials 2819 2815 -4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
An example in the wiki page https://wiki.openstreetmap.org/wiki/Guidelines_for_pedestrian_navigation shows that when a wall ends on the edge of a pedestrian area, a pedestrian can't go through that node. This has been verified with real-world mapping in Farringdon station.
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.
Add comment on barrier after OSM ground survey
application/src/main/java/org/opentripplanner/osm/model/OsmEntity.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.
The logic is somewhat complex and it is a bit hard to understand what kind of effects this PR has, although there is a very nice test set. It may be that areas surrounded by barriers get some sort of redundant edge set, which does not lead anywhere, at every boundary vertex. The screenshots below indicate that there are regressions in area processing. Maybe the code should more carefully process only vertices between two areas.


application/src/main/java/org/opentripplanner/graph_builder/module/osm/OsmAreaGroup.java
Outdated
Show resolved
Hide resolved
application/src/main/java/org/opentripplanner/graph_builder/module/osm/OsmAreaGroup.java
Show resolved
Hide resolved
// make a separate vertex if the node is on a barrier | ||
if (nodesInBarrierWays.containsKey(node)) { | ||
return getSplitVertexOnBarrier(node, way); | ||
} | ||
// single-level case |
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.
This change has side effects, which are hard to predict. Vertex is no longer added to intersectionNodes map, which is later used in area processing.
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.
This is intended. intersectionNodes track nodes which are used in multiple OSM ways, however, if a node is on a barrier, a separate node is created for each way so it is not used in multiple OSM ways.
The reasoning is the same as splitting nodes on areas on multiple levels into different vertices.
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 am a bit concerned how WalkableAreaBuilder selects OSM way entities in vertex generation. Sometimes way is picked randomly, sometimes parent area is used. I suspect that this occasionally creates duplicated vertices and somewhat strange edge connections.
In the past, intersection vertex map eliminated duplicates in a simple way.
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 added some logging and found out that BarrierEdgeBuilder tries to connect distant sections of area groups, not just the two at opposite side of a barrier.
I believe use of this entity reference is the reason:
Line 191 in ec60f14
OsmEntity areaEntity = group.getSomeOsmObject(); |
The code should consistently use parent entity of the currently processed area, not a random pick from the area group.
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.
application/src/main/java/org/opentripplanner/graph_builder/module/osm/VertexGenerator.java
Outdated
Show resolved
Hide resolved
application/src/main/java/org/opentripplanner/osm/model/OsmWay.java
Outdated
Show resolved
Hide resolved
application/src/main/java/org/opentripplanner/street/model/vertex/OsmVertexOnWay.java
Outdated
Show resolved
Hide resolved
application/src/main/java/org/opentripplanner/street/model/vertex/StationEntranceVertex.java
Outdated
Show resolved
Hide resolved
I have found the regression. The intention of |
this fixes a regression where area edges are generated to nowhere
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.
Graph build works now much better. Barriers no longer remove important bridges in Helsinki.
// make a separate vertex if the node is on a barrier | ||
if (nodesInBarrierWays.containsKey(node)) { | ||
return getSplitVertexOnBarrier(node, way); | ||
} | ||
// single-level case |
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 am a bit concerned how WalkableAreaBuilder selects OSM way entities in vertex generation. Sometimes way is picked randomly, sometimes parent area is used. I suspect that this occasionally creates duplicated vertices and somewhat strange edge connections.
In the past, intersection vertex map eliminated duplicates in a simple way.
application/src/main/java/org/opentripplanner/graph_builder/module/osm/VertexGenerator.java
Outdated
Show resolved
Hide resolved
One more discovery: you should consider no through traversal limitations when adding connections through a barrier, the same way as here: If areas (or a way connecting to an area) have private access and the connecting edges are not marked as no through, traversal is not possible - the edges are added for no reason. |
This is to ensure that local traffic can get across the barrier between two no through traffic areas.
…riers to avoid creating useless edges
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 am quite happy with the functionality now, especially when #6826 is included as well.
We are still considering if the two new issues are useful in their current form, or should the logic examine the data more carefully. For example, highways crossing a barrier tagged as barrier=retaining wall
at a bridge structure seem to be very common. An example: https://www.openstreetmap.org/node/444209183
application/src/main/java/org/opentripplanner/graph_builder/module/osm/VertexGenerator.java
Outdated
Show resolved
Hide resolved
var from = vs[i]; | ||
var to = vs[j]; | ||
|
||
if (inDegrees[i] > 0 && outDegrees[j] > 0) { |
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.
After the fix presented in #6826, degree check seems unnecessary. I tested that this condition was always true when building helsinki area street graph.
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 this check is still needed to prevent unnecessary edges being built when a one-way street joins an area at a gate through a wall. The end vertex of the one-way street will only have incoming edge but not outgoing edge, so this block will skip it when attempting to join from the vertex on the area to the vertex at the end of a one-way street which doesn't have outgoing edges.
application/src/main/java/org/opentripplanner/graph_builder/module/osm/OsmDatabase.java
Outdated
Show resolved
Hide resolved
application/src/main/java/org/opentripplanner/graph_builder/module/osm/VertexGenerator.java
Outdated
Show resolved
Hide resolved
...ation/src/test/java/org/opentripplanner/graph_builder/module/osm/BarrierEdgeBuilderTest.java
Show resolved
Hide resolved
application/src/main/java/org/opentripplanner/street/model/vertex/VertexFactory.java
Outdated
Show resolved
Hide resolved
I just found out that I made a mistake in a previous PR, which was surprising untested. The method had a test case but it didn't contain this specific case. I forgot to add a I have just corrected it and added a test for it. |
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 added a couple of minor request. We are close getting this merged.
application/src/main/java/org/opentripplanner/street/model/vertex/VertexFactory.java
Outdated
Show resolved
Hide resolved
0455e75
to
d9b9332
Compare
d9b9332
to
7ba8b42
Compare
@miklcct you can merge this if you think this is ready |
Summary
Improve support for more kinds of barriers, including point barriers and linear barriers, which can block travel for multiple modes of traversal.
In implementation terms, it does the following:
barrier=entrance
, the restrictions for the barrier is ignored.Note that if two linear barriers join end to end, it is possible to cross between them at the joining node, unless the node itself blocks access.Update 2025-08-06: After checking some real-world mapping, I have decided to disallow passing through the end of a barrier as well, like the photo shown below but with two areas.What this PR does not do
Note that barrier blocking access within a single area (whether the barrier effectively splits the area into two or not), like the following picture is not implemented.

Issue
Closes #6689
The following screenshots show the fixed routing to avoid walking into a wall inside a train station:
original:


fixed:
Unit tests
Added for area splitting, vertex handling and barrier permission detection including wheelchair accessibility.
Documentation
Changelog
Bumping the serialization version id
Definitely required. A new kind of vertex is added to prevent duplicate labels for split vertices.