Skip to content

Optimal walking routes when walking starts or ends in an area - #4936

Merged
vesameskanen merged 23 commits into
opentripplanner:dev-2.xfrom
HSLdevcom:area-walk-linking
Mar 17, 2023
Merged

Optimal walking routes when walking starts or ends in an area#4936
vesameskanen merged 23 commits into
opentripplanner:dev-2.xfrom
HSLdevcom:area-walk-linking

Conversation

@vesameskanen

Copy link
Copy Markdown
Contributor

Summary

Street graph is optimised for walks, which pass through open areas. If an itinerary search starts or ends in a point inside an area ( or a transfer happens within the area ), walk routes are often really strange as the walking gets first linked to a random edge which may travel to totally wrong direction. Path to a desired target point becomes a funny zigzag line.

This pull request fixes those problems by linking points near area edges or inside the area to all so called visibility points. This ensures that street routing can start search to optimal directions. Permanently linked points are added to visibility points, which ensures that direct connections between multiple inserted points become generated. So, transfer path between two area stops is a straight line.

Image below shows a typical area walk before and after this improvement.

image

Unit tests

Linking is quite complicated business, so many tests are included. The test bench is fairly easily extendable, if need arises.

@vesameskanen
vesameskanen requested a review from a team as a code owner March 6, 2023 11:23
@vesameskanen vesameskanen added the !Improvement A functional improvement or micro feature label Mar 6, 2023
@codecov

codecov Bot commented Mar 6, 2023

Copy link
Copy Markdown

Codecov Report

Patch coverage: 77.03% and project coverage change: -0.10 ⚠️

Comparison is base (e006aed) 63.89% compared to head (05c07ae) 63.79%.

❗ Current head 05c07ae differs from pull request most recent head e5440f8. Consider uploading reports for the commit e5440f8 to get more accurate results

Additional details and impacted files
@@              Coverage Diff              @@
##             dev-2.x    #4936      +/-   ##
=============================================
- Coverage      63.89%   63.79%   -0.10%     
+ Complexity     13482    13455      -27     
=============================================
  Files           1674     1674              
  Lines          66107    66092      -15     
  Branches        7143     7152       +9     
=============================================
- Hits           42236    42166      -70     
- Misses         21488    21533      +45     
- Partials        2383     2393      +10     
Impacted Files Coverage Δ
...tripplanner/routing/linking/FlexLocationAdder.java 72.72% <ø> (ø)
...pentripplanner/street/model/edge/AreaEdgeList.java 90.90% <ø> (+9.27%) ⬆️
...aph_builder/module/OsmBoardingLocationsModule.java 77.01% <33.33%> (-4.17%) ⬇️
.../algorithm/raptoradapter/router/TransitRouter.java 75.67% <69.23%> (ø)
.../opentripplanner/routing/linking/VertexLinker.java 84.09% <79.56%> (-3.91%) ⬇️
...rg/opentripplanner/street/model/vertex/Vertex.java 84.95% <80.00%> (+1.14%) ⬆️
...rg/opentripplanner/street/model/edge/AreaEdge.java 100.00% <100.00%> (ø)

... and 24 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.


public class LinkStopToPlatformTest {

private static final Logger LOG = LoggerFactory.getLogger(LinkStopToPlatformTest.class);

@leonardehrenfried leonardehrenfried Mar 6, 2023

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It's really, really great to have improved test coverage of this quite hard to understand code. 😻

@Test
public void testLinkStopOutsideArea() {
// test platform is a simple rectangle. It creates a graph of 8 edges.
Coordinate platform[] = {

@leonardehrenfried leonardehrenfried Mar 6, 2023

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
Coordinate platform[] = {
Coordinate[] platform = {

The above line is not wrong but unusual for Java. There are a few others also in the file which would be great if you could change them.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

right! Fixed now.

Comment thread src/main/java/org/opentripplanner/street/model/vertex/Vertex.java
Comment thread src/main/java/org/opentripplanner/routing/linking/DisposableEdgeCollection.java Outdated

@leonardehrenfried leonardehrenfried left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I've tested this and I've consistently seen good results even in complicated areas. I particularly like that there is test coverage of all the complicated cases.

I have a few smaller things that I would like to see changed but all in all I'm quite happy.

@t2gran t2gran added this to the 2.3 milestone Mar 6, 2023
There is a bug in graph serialisation. Quick fix until the actual bug is fixed
Comment thread src/main/java/org/opentripplanner/street/model/vertex/Vertex.java Outdated
@optionsome optionsome added the Digitransit Test Feature is under testing in Digitransit environment(s) label Mar 9, 2023
@optionsome

Copy link
Copy Markdown
Member

I'm not quite sure does this pr cause a need to bump the serialization version or not

@leonardehrenfried

Copy link
Copy Markdown
Member

I think it does as it modifies AreaEdge so let's add the label just in case.

@leonardehrenfried leonardehrenfried added the +Bump Serialization Id Add this label if you want the serialization id automatically bumped after merging the PR label Mar 9, 2023
@leonardehrenfried

Copy link
Copy Markdown
Member

If you want another review, please click "re-request review".

@leonardehrenfried

Copy link
Copy Markdown
Member

You can also check SerializedGraphObject how the serialization of edges work.

@vesameskanen

Copy link
Copy Markdown
Contributor Author

Thanks for advices! This PR is currently in WIP state, because the new area routing finds OSM vertices which have null incoming/outgoing edges after saving and reloading the graph. The root cause must be found.

@leonardehrenfried
leonardehrenfried marked this pull request as draft March 14, 2023 09:44
@vesameskanen
vesameskanen marked this pull request as ready for review March 16, 2023 10:59
@vesameskanen
vesameskanen merged commit b656dd0 into opentripplanner:dev-2.x Mar 17, 2023
@vesameskanen
vesameskanen deleted the area-walk-linking branch March 17, 2023 10:11
t2gran pushed a commit that referenced this pull request Mar 17, 2023
t2gran pushed a commit that referenced this pull request Mar 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

+Bump Serialization Id Add this label if you want the serialization id automatically bumped after merging the PR Digitransit Test Feature is under testing in Digitransit environment(s) !Improvement A functional improvement or micro feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants