-
Notifications
You must be signed in to change notification settings - Fork 2
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
Dynamic Rerouting #286
base: dev
Are you sure you want to change the base?
Dynamic Rerouting #286
Conversation
…m OTP from the traveler's curre Tracking is then based on the new itinerary
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.
First round of comments after a first read.
src/main/java/org/opentripplanner/middleware/triptracker/ManageTripTracking.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opentripplanner/middleware/triptracker/ManageTripTracking.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opentripplanner/middleware/triptracker/ManageTripTracking.java
Outdated
Show resolved
Hide resolved
OtpGraphQLVariables query = trackedJourney.trip.otp2QueryParams; | ||
query.fromPlace = new Coordinates(trackedJourney.lastLocation()).getCoordinates(); | ||
query.time = getTimeNowAsString(); |
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.
Extract a method and write unit tests for it.
src/test/java/org/opentripplanner/middleware/controllers/api/TrackedTripControllerTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/opentripplanner/middleware/controllers/api/TrackedTripControllerTest.java
Outdated
Show resolved
Hide resolved
…e PR feedback and updated unit
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.
Here are the next changes I think are needed to get an instruction that matches the rerouted itinerary:
src/main/java/org/opentripplanner/middleware/controllers/api/TrackedTripController.java
Outdated
Show resolved
Hide resolved
var trackedJourney = tripData.journey; | ||
if (trackedJourney != null) { | ||
if (rerouteTrip(tripData)) { | ||
return doUpdateTracking(request, tripData, false); |
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.
Interesting, POST-ing a rerouting request returned a "no-instruction" response instead of a new instruction. Let me dig more.
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.
Also, POST-ing a track
update with the same, originally deviated position should have updated to an on-track position with an updated instruction, but it stayed on the "deviated" status instead.
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 line calls the linked piece of code, where the matching itinerary should be a clone of the journey state's matching itinerary, not of the saved itineary.
otp-middleware/src/main/java/org/opentripplanner/middleware/tripmonitor/jobs/CheckMonitoredTrip.java
Line 257 in 8f981d7
matchingItinerary = trip.itinerary.clone(); |
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 probably need to add or update the flag for updateTracking
so that no new tracked journey is created, but the rerouting gives directions as if it were the beginning of the trip.
src/main/java/org/opentripplanner/middleware/triptracker/ManageTripTracking.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opentripplanner/middleware/controllers/api/TrackedTripController.java
Outdated
Show resolved
Hide resolved
…ed used instead of localhost
…se and updates around this
src/main/java/org/opentripplanner/middleware/triptracker/response/RerouteResponse.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opentripplanner/middleware/triptracker/ManageTripTracking.java
Outdated
Show resolved
Hide resolved
if (tripData != null) { | ||
var trackedJourney = tripData.journey; | ||
return trackedJourney != null && updateTripWithNewItinerary(trackedJourney); | ||
if (trackedJourney != null) { | ||
return updateTripWithNewItinerary(trackedJourney); |
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 should probably notify companions/observers of that change.
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.
If the traveler takes the trip, it will likely still within the active trip monitoring window, and trip monitoring will attempt to replace journeyState.matchingItinerary
with an itinerary matching the original one. To prevent that, if rerouting has occured, getQueryParamsForTargetZonedDateTime
should also plug the most recent rerouting location that is saved in TrackedJourney
.
// Confirm traveler is no longer 'deviated'. | ||
updateTrackingResponse = JsonUtils.getPOJOFromJSON(response.responseBody, TrackingResponse.class); | ||
assertNotEquals(TripStatus.DEVIATED.name(), updateTrackingResponse.tripStatus); | ||
|
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.
Try to insert a call to CheckMonitoredTrip
and assert that it doesn't revert the matching itinerary to what was before.
} | ||
|
||
/** Provides a mock OTP 'plan' rerouted response. */ | ||
public Supplier<OtpResponse> mockOtpPlanResponse() { |
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.
Rename to mockOtpReroutedPlanResponse
or something similar.
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.
Make field itinerary
in RerouteResponse
public, and make the itinerary monitor process also apply the updated origin location so it can update the rerouted itinerary with realtime updates, if any.
Checklist
dev
before they can be merged tomaster
)Description
Adds the ability for a traveler to reroute from their current location if deviated from the original trip. A new itinerary is retrieved from OTP (replacing the original trip) and if available tracking and instructions will be based on this instead. Subsequent rerouting will replace previous rerouted trips.