-
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
Allow multiple states during transfer edge traversals #6238
Allow multiple states during transfer edge traversals #6238
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev-2.x #6238 +/- ##
=============================================
+ Coverage 69.71% 69.72% +0.01%
- Complexity 17692 17700 +8
=============================================
Files 2008 2008
Lines 75822 75825 +3
Branches 7761 7763 +2
=============================================
+ Hits 52858 52869 +11
+ Misses 20250 20245 -5
+ Partials 2714 2711 -3 ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
24c7dc6
to
7ab8e1e
Compare
Can you resolve the conflicts? |
7ab8e1e
to
4d11307
Compare
|
||
State[] states = transferStates.toArray(new State[0]); | ||
var graphPath = new GraphPath<>(states[states.length - 1]); | ||
var legTransferSearchRequest = transferStreetRequest |
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 one didn't use the EdgeTraverser before. What is the reason for using it here?
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.
Multiple states may also occur here, which need to be handled in a similar manner:
- there could be multiple initial states
- the edge traversal could return multiple states, of which the first one may not be the optimal
As an example, the CAR_PICKUP
transfers resulted in an NPE, since the initial CAR/IN_CAR
state couldn't traverse the StreetTransitLink
entities.
By using EdgeTraverser
traversal results in the same state as when creating the actual transfer.
); | ||
} | ||
if (State.isEmpty(afterTraversal)) { | ||
var vertex = isArriveBy ? e.getToVertex() : e.getFromVertex(); |
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.
Is the reason we need to care about arriveBy is that we now use the SPT?
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.
Yes, it is due to the SPT which stores states by the vertex
. Previously we could ignore the from/to vertex handling since the single previous state was used.
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.
Do we support CAR_PICKUP in transfers? Idk how often using one would be realistic.
@@ -0,0 +1,71 @@ | |||
package org.opentripplanner.routing.algorithm.mapping; | |||
|
|||
import au.com.origin.snapshots.junit5.SnapshotExtension; |
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.
Btw how is this dependency imported into our project?
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 an existing dependency:
Lines 466 to 470 in 5b5d92f
<dependency> | |
<groupId>io.github.origin-energy</groupId> | |
<artifactId>java-snapshot-testing-junit5</artifactId> | |
<version>2.3.0</version> | |
</dependency> |
} | ||
|
||
@Test | ||
public void test_trip_planning_with_car_pickup_only() { |
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.
We usually don't use the snake case in tests. I know some people like to use them since they might be slightly more readable. Is there some other reason to use them here?
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 existing snapshots tests follow the same format, which I built on:
Lines 66 to 67 in 5b5d92f
@Test | |
public void test_trip_planning_with_walk_only() { |
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.
We discussed this in the dev meeting today. Apparently we had made some decision a couple of years ago that snake case is not allowed in tests. But since it's used in snapshot tests, we don't think you should change it in the scope of this pr but if you could create a follow up pr where you rename all the snake case snapshot tests, that would be appreciated.
Related to the If this was just added for a test, I think the test can be changed to another mode, for example. |
|
I tried searching for your name in the OTP gitter chat app, but couldn't find you @flaktack. Can you join the OTP room? Essentially, I think if this mode is used in a test, then it should also be a real-world use case. To fully implement the mode, the changes I listed in the previous comment should be made. Can I'm not that familiar with multiple states in the transfer edge traversals, but I recall that issue #6210 was caused by the use of the |
How about we do the following?
That way we don't need to have @VillePihlava straining to fix a test for behaviour that we actually don't want to support. |
I should have something ready next week using bike with transit. |
Summary
(This builds on #6237)
In
EdgeTraverser
when traversing edge lists multiple states could be returned which was not handled correctly.This updates `EdgeTraverser˙ and its uses to allow multiple states.
Issue
Closes #6210
Unit tests
Unit tests are added for
EdgeTraverser
. To test the updated transfer and leg traversal aCAR_PICKUP
snapshot test is added and then updated.