Skip to content

Gmap pending fixes #303

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

Draft
wants to merge 95 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
7145895
feat(TrackingLocation): Add fields for troubleshooting.
binh-dam-ibigroup Jan 27, 2025
56734b2
docs(swagger): Update snapshot.
binh-dam-ibigroup Jan 27, 2025
85050cc
feat(ManageTripTracking): Log calls to endtracking endpoints.
binh-dam-ibigroup Jan 27, 2025
c07d302
refactor(ManageTripTracking): Log calls to tracking endpoints includi…
binh-dam-ibigroup Jan 28, 2025
7c9f553
Merge branch 'revert-pr-288' into live-tracking-debug
binh-dam-ibigroup Jan 28, 2025
1f2f131
Merge branch 'dev' into live-tracking-debug
binh-dam-ibigroup Feb 3, 2025
5d686e8
Merge branch 'live-tracking-debug' into gmap-pending-fixes
binh-dam-ibigroup Feb 5, 2025
ecd255b
Merge remote-tracking branch 'origin/feature/trip-is-next-UTC-day' in…
binh-dam-ibigroup Feb 5, 2025
9dad966
Merge branch 'rerouting-reset-itinerary' into gmap-pending-fixes
binh-dam-ibigroup Feb 5, 2025
bf9fbd4
Merge branch 'rename-trip-survey-response-files' into gmap-pending-fixes
binh-dam-ibigroup Feb 5, 2025
7940af0
Merge branch 'dev' into gmap-pending-fixes
binh-dam-ibigroup Feb 6, 2025
e485c36
Merge branch 'no-deviation-if-near-bus-stop' into gmap-pending-fixes
binh-dam-ibigroup Feb 10, 2025
5650526
test(TrackedTripController): Fix bad merge.
binh-dam-ibigroup Feb 10, 2025
7bfa61f
Merge branch 'trip-surveys-remove-speed-req' into gmap-pending-fixes
binh-dam-ibigroup Feb 12, 2025
94df32d
test(TripSurveySenderJob): Harden the test to get notified users.
binh-dam-ibigroup Feb 12, 2025
ca9f862
fix(ManageTripTracking): Return trip 'completed' with end-of-routing …
binh-dam-ibigroup Feb 12, 2025
6064544
test(TripSurveySenderJob): Harden test removing foreign journeys.
binh-dam-ibigroup Feb 12, 2025
2029cb3
fix(TravelerLocator): Modify def for dist to end of leg.
binh-dam-ibigroup Feb 12, 2025
3e38707
fix(TravelerLocator): Handle step range for end-of-routing.
binh-dam-ibigroup Feb 12, 2025
42684b9
Merge branch 'dev' into gmap-pending-fixes
binh-dam-ibigroup Feb 14, 2025
3da269f
refactor(ManageTripTracking): Fix typos
binh-dam-ibigroup Feb 14, 2025
980f4ab
fix(TravelerLocator): Include last shape coordinate in injected points.
binh-dam-ibigroup Feb 18, 2025
292b383
feat(Initial reminder for one time trips): Update to send notificatio…
br648 Feb 18, 2025
f3c9b5f
test(ManageLegTraversal): Combine inject waypoint tests.
binh-dam-ibigroup Feb 18, 2025
2d747ce
test(ManageLegTraversal): Add test for distance to end of leg.
binh-dam-ibigroup Feb 18, 2025
5316447
test(ManageLegTraversal): Add missing import.
binh-dam-ibigroup Feb 18, 2025
4f50821
refactor(Addressed merge conflicts):
br648 Feb 18, 2025
1a8206c
Merge branch 'dev' into gmap-pending-fixes
binh-dam-ibigroup Feb 18, 2025
8246112
Merge branch 'feature/OTP-1626-add-haptic-notify-mode' into gmap-pend…
binh-dam-ibigroup Feb 18, 2025
b23bd69
improvement(Addressed PR feedback):
br648 Feb 18, 2025
a633e87
Merge branch 'dev' into no-deviation-if-near-bus-stop
binh-dam-ibigroup Feb 18, 2025
c2dbf51
Merge branch 'no-deviation-if-near-bus-stop' into end-of-routing-fix
binh-dam-ibigroup Feb 18, 2025
ba5d4ce
fix(ManageTripTracking): Return trip 'completed' with end-of-routing …
binh-dam-ibigroup Feb 12, 2025
2e8bebf
ix(TravelerLocator): Modify def for dist to end of leg [routing]
binh-dam-ibigroup Feb 18, 2025
33fd90a
fix(TravelerLocator): Handle step range for end-of-routing.
binh-dam-ibigroup Feb 12, 2025
5dabdfd
fix(TravelerLocator): Include last shape coordinate in injected points.
binh-dam-ibigroup Feb 18, 2025
e499e7a
test(ManageLegTraversal): Combine inject waypoint tests.
binh-dam-ibigroup Feb 18, 2025
5d543c7
test(ManageLegTraversal): Add test for distance to end of leg [routing]
binh-dam-ibigroup Feb 18, 2025
6948c7a
improvement(Added one time exception to trip checking):
br648 Feb 19, 2025
02d9884
improvement(CheckMonitoredTrip.java): Updates to better guard against…
br648 Feb 19, 2025
60c207e
fix(TravelerLocator): Make end-of-routing second priority after at-de…
binh-dam-ibigroup Feb 19, 2025
5c296fa
fix(TravelerLocator): Make end-of-routing second priority after at-de…
binh-dam-ibigroup Feb 19, 2025
92394ce
Merge branch 'dev' into feature/OTP-1619-one-time-trip-no-reminder
br648 Feb 20, 2025
581d3fd
improvement(CheckMonitoredTrip.java): Extracted delay offset code to …
br648 Feb 20, 2025
ba19fca
Merge branch 'dev' into feature/OTP-1619-one-time-trip-no-reminder
br648 Feb 20, 2025
8230c00
Merge branch 'dev' into gmap-pending-fixes
binh-dam-ibigroup Feb 20, 2025
e41f6ff
Merge branch 'dev' into end-of-routing-fix
binh-dam-ibigroup Feb 20, 2025
b7e0459
Merge branch 'feature/OTP-1619-one-time-trip-no-reminder' into gmap-p…
binh-dam-ibigroup Feb 20, 2025
b139e5a
refactor(TravelerLocator): Apply review feedback.
binh-dam-ibigroup Feb 21, 2025
03ce9d3
test(ManageLegTraversal): Apply review feedback.
binh-dam-ibigroup Feb 21, 2025
e44814f
Merge branch 'dev' into end-of-routing-fix
binh-dam-ibigroup Feb 21, 2025
8796cf2
fix: Issue wait for transit even after bus departure time. Harden tests.
binh-dam-ibigroup Feb 21, 2025
70088db
fix(TravelerLocator): Issue wait for transit after bus departure time…
binh-dam-ibigroup Feb 21, 2025
e99b9db
fix(TravelerLocator): Issue wait for transit after bus departure time.
binh-dam-ibigroup Feb 21, 2025
7d8bcb8
test(ManageLegTraversal): Update test.
binh-dam-ibigroup Feb 21, 2025
0bb326d
Merge branch 'dev' into gmap-pending-fixes
binh-dam-ibigroup Feb 23, 2025
c522263
Merge branch 'end-of-routing-fix' into gmap-pending-fixes
binh-dam-ibigroup Feb 23, 2025
4da860b
Merge branch 'bus-stop-instructions-fix' into gmap-pending-fixes
binh-dam-ibigroup Feb 23, 2025
7d0cbac
fix(TravelerLocator): Better compute last shape position.
binh-dam-ibigroup Feb 23, 2025
0278504
fix(ManageLegTraversal): Distinguish transit leg based on speed.
binh-dam-ibigroup Feb 23, 2025
80de721
refactor(TravelerLocator): Reuse transit leg speed.
binh-dam-ibigroup Feb 23, 2025
e9ee6f1
refactor(TraceDate): Make class public.
binh-dam-ibigroup Feb 23, 2025
21ecdb9
test(TrackedTripController): Use TraceData in endpoint test.
binh-dam-ibigroup Feb 23, 2025
02e5db5
test(ManageLegTraversal): Fix on board instruction. Share coordinates.
binh-dam-ibigroup Feb 23, 2025
b5d870e
test(TrackedTripController): Consolidate wait for transit instruction.
binh-dam-ibigroup Feb 23, 2025
3c97b80
fix(TravelerLocator): Emit same instruction whether start of trip or …
binh-dam-ibigroup Feb 23, 2025
a7a8235
test: Consolidate mock itinerary files.
binh-dam-ibigroup Feb 23, 2025
a26bdb2
fix(UsRideGw...Message): Correctly pick current transit leg if first …
binh-dam-ibigroup Feb 23, 2025
808f87c
refactor(TravelerLocator): Cache leg positions in TravelerPosition.
binh-dam-ibigroup Feb 26, 2025
7ec2cfa
test(ManageLegTraversal): Consolidate tests for dist to end of leg.
binh-dam-ibigroup Feb 26, 2025
9241fd3
fix(MonitoredTrip): Fix how the primary user is determined.
binh-dam-ibigroup Feb 27, 2025
91ae3ab
fix(TravelerLocator): Include beginning of routing as start of leg.
binh-dam-ibigroup Feb 27, 2025
e315507
chore(deps): Update logback and dependencies.
binh-dam-ibigroup Apr 15, 2025
e5bea3f
chore(logback): Log GMAP and notifications to separate files.
binh-dam-ibigroup Apr 15, 2025
cfcd343
fix(CheckMonitoredTrip): Update target date after change in monitored…
binh-dam-ibigroup Apr 9, 2025
e103aed
fix(CheckMonitoredTrip): Update target date if new monitored day is a…
binh-dam-ibigroup Apr 9, 2025
47c4a95
fix(CheckMonitoredTrip): Update target date if new monitored day is a…
binh-dam-ibigroup Apr 9, 2025
e4d73ae
test(CheckMonitoredTrip): Add test for changing monit days while trip…
binh-dam-ibigroup Apr 9, 2025
ae94b96
test(CheckMonitoredTrip): Pass test itineraries to createDefaultItine…
binh-dam-ibigroup Apr 10, 2025
cc06d8d
test(OtpTestUtils): Refactor createDefaultJourneyState.
binh-dam-ibigroup Apr 10, 2025
c1468f8
fix(CheckMonitoredTrip): Do not advance to next day if matching itine…
binh-dam-ibigroup Apr 10, 2025
a72584c
refactor(CheckMonitoredTrip): Add method to find earliest target date.
binh-dam-ibigroup Apr 11, 2025
75da14b
fix(CheckMonitoredTrip): Correctly compute earliest start date/time.
binh-dam-ibigroup Apr 11, 2025
b75e643
refactor(CheckMonitoredTrip): Remove unused code.
binh-dam-ibigroup Apr 11, 2025
e22fa3e
refactor(CheckMonitoredTrip): Extract and consolidate making date+tim…
binh-dam-ibigroup Apr 11, 2025
5fa01e1
refactor(CheckMonitoredTrip): Reuse DateUtils code and tweak comments.
binh-dam-ibigroup Apr 14, 2025
ca6e1e8
refactor(DateTimeUtils): Extract nowAsZonedDateTime w/o params using …
binh-dam-ibigroup Apr 14, 2025
706403b
refactor(OtpTestUtils): Make firstItinerary public and reuse in other…
binh-dam-ibigroup Apr 14, 2025
6c72722
test(CheckMonitoredTripBasic): Tweak canFindEarliestTargetDateTime.
binh-dam-ibigroup Apr 14, 2025
455b01d
test(CheckMonitoredTrip): Parameterize monitored day change tests.
binh-dam-ibigroup Apr 14, 2025
7328211
test(CheckMonitoredTrip): Tweak comments and refactor monitored day p…
binh-dam-ibigroup Apr 14, 2025
0512bbb
test(CheckMonitoredTrip): Extract setItineraryDay, reuse getter for J…
binh-dam-ibigroup Apr 14, 2025
5003c9d
test(CheckMonitoredTrip): Extract consts for most commonly used dates.
binh-dam-ibigroup Apr 14, 2025
c9d9e6b
refactor(CheckMonitoredTrip): Apply review feedback.
binh-dam-ibigroup Apr 15, 2025
8be90c5
refactor(ItineraryUtilsTest): Fix bad merge.
binh-dam-ibigroup May 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jackson.version>2.13.5</jackson.version>
<awsjavasdk.version>1.11.728</awsjavasdk.version>
<awsjavasdk.version>1.12.261</awsjavasdk.version>
</properties>
<repositories>
<!-- used for importing java projects from github -->
Expand Down Expand Up @@ -122,7 +122,7 @@
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.7</version>
<version>2.15.1</version>
</dependency>

<!-- Use for better object state checking. -->
Expand All @@ -136,13 +136,13 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.30</version>
<version>2.0.17</version>
</dependency>

<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
<version>1.5.18</version>
</dependency>

<!-- Required to construct URI (UriBuilder) -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -521,10 +521,12 @@ public TripUsers(MobilityProfileLite primary, RelatedUser companion, List<Relate
}

/**
* Trip created by primary user.
* Determines whether this trip was created by primary user.
* The primary user is either be the user denoted with userId if there are no companions (there can be observers),
* or the user denoted with the `primary` field if that field is populated.
*/
public boolean ownedByPrimary() {
return primary != null && userId.equalsIgnoreCase(primary.userId);
return primary == null || userId.equalsIgnoreCase(primary.userId);
}

/**
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.util.ArrayList;
import java.util.List;

import static org.opentripplanner.middleware.triptracker.TravelerLocator.MIN_TRANSIT_VEHICLE_SPEED;
import static org.opentripplanner.middleware.triptracker.TravelerLocator.getAllLegPositions;
import static org.opentripplanner.middleware.triptracker.TravelerLocator.getLegGeoPoints;
import static org.opentripplanner.middleware.utils.ConfigUtils.getConfigPropertyAsInt;
Expand Down Expand Up @@ -62,10 +63,10 @@ private static boolean canUseLeg(Leg leg) {
* match, return this leg, if not simply return the leg that is nearest to the current position.
*/
@Nullable
public static Leg getExpectedLeg(Coordinates position, Itinerary itinerary) {
public static Leg getExpectedLeg(Coordinates position, int speed, Itinerary itinerary) {
if (canUseTripLegs(itinerary)) {
Leg leg = getContainingLeg(position, itinerary);
return (leg != null) ? leg : getNearestLeg(position, itinerary);
return (leg != null) ? leg : getNearestLeg(position, speed, itinerary);
}
return null;
}
Expand All @@ -92,9 +93,12 @@ public static Leg getNextLeg(Leg expectedLeg, Itinerary itinerary) {
* identical. In this scenario it would be possible for the current position to be attributed to the exit leg,
* therefore missing the instruction at the end of the cul-de-sac.
*/
private static Leg getNearestLeg(Coordinates position, Itinerary itinerary) {
double shortestDistance = Double.MAX_VALUE;
private static Leg getNearestLeg(Coordinates position, int speed, Itinerary itinerary) {
Leg nearestTransitLeg = null;
Leg nearestLeg = null;

double shortestDistance = Double.MAX_VALUE;
double shortestTransitDistance = Double.MAX_VALUE;
for (int i = 0; i < itinerary.legs.size(); i++) {
Leg leg = itinerary.legs.get(i);
for (Coordinates positionOnLeg : getAllLegPositions(leg)) {
Expand All @@ -103,8 +107,16 @@ private static Leg getNearestLeg(Coordinates position, Itinerary itinerary) {
nearestLeg = leg;
shortestDistance = distance;
}
if (Boolean.TRUE.equals(leg.transitLeg) && distance < shortestTransitDistance) {
nearestTransitLeg = leg;
shortestTransitDistance = distance;
}
}
}

if (speed >= MIN_TRANSIT_VEHICLE_SPEED && nearestTransitLeg != null) {
return nearestTransitLeg;
}
return nearestLeg;
}

Expand All @@ -121,6 +133,7 @@ private static Leg getContainingLeg(Coordinates position, Itinerary itinerary) {
}
}
}

return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.opentripplanner.middleware.otp.response.Itinerary;
import org.opentripplanner.middleware.otp.response.Leg;
import org.opentripplanner.middleware.otp.response.OtpResponse;
import org.opentripplanner.middleware.otp.response.Step;
import org.opentripplanner.middleware.otp.response.TripPlan;
import org.opentripplanner.middleware.persistence.Persistence;
import org.opentripplanner.middleware.triptracker.instruction.OnTrackInstruction;
Expand All @@ -27,6 +28,8 @@
import org.opentripplanner.middleware.utils.Coordinates;
import org.opentripplanner.middleware.utils.DateTimeUtils;
import org.opentripplanner.middleware.utils.NotificationUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import spark.Request;

import java.time.LocalDate;
Expand All @@ -48,6 +51,7 @@
import static org.opentripplanner.middleware.utils.JsonUtils.logMessageAndHalt;

public class ManageTripTracking {
private static final Logger LOG = LoggerFactory.getLogger(ManageTripTracking.class);

public static Supplier<OtpResponse> otpResponseProviderOverride = null;
private static OtpGraphQLVariables rerouteVariables = null;
Expand Down Expand Up @@ -138,6 +142,11 @@ private static TrackingResponse doUpdateTracking(
tripStatus = TripStatus.getTimingStatus(travelerPosition);
}

if (isEndOfRoutingInstruction(instruction)) {
// Deem trip completed if issuing a "destination in vicinity" instruction.
tripStatus = TripStatus.COMPLETED;
}

// Perform interactions such as triggering traffic signals when approaching segments so configured.
// It is assumed to be ok to repeatedly perform the interaction.
if (instruction instanceof SelfLegInstruction && instruction.distance <= TRIP_INSTRUCTION_UPCOMING_RADIUS) {
Expand All @@ -160,6 +169,20 @@ private static TrackingResponse doUpdateTracking(
return null;
}

/**
* Detect if the instruction is an end-of-routing instruction
* (to give a 'completed' status to the trip, for instance).
*/
private static boolean isEndOfRoutingInstruction(TripInstruction instruction) {
if (instruction instanceof OnTrackInstruction) {
Step step = ((OnTrackInstruction) instruction).getLegStep();
if (step != null) {
return step.isEndOfRouting();
}
}
return false;
}

/**
* Detect if we are deeming a traveler deviated while giving out a non-deviated instruction
* (to prevent, for instance, being offered rerouting while near a bus stop).
Expand All @@ -186,17 +209,37 @@ public static TrackingResponse updateTracking(Request request) {
public static TrackingResponse startOrUpdateTracking(Request request) {
TripTrackingData tripData = TripTrackingData.fromRequestTripId(request);
if (tripData != null) {
logTracking(request, "track/updatetracking");
// write device info to last location reported location
if (tripData.locations != null && !tripData.locations.isEmpty()) {
var lastLocation = tripData.locations.get(tripData.locations.size() - 1);
lastLocation.device_id = request.headers("device_id");
lastLocation.app_platform = request.headers("app_platform");
lastLocation.app_version = request.headers("app_version");
}

return doUpdateTracking(request, tripData, tripData.journey == null);
}
return null;
}

public static void logTracking(Request request, String operation) {
LOG.info(
"{} called by device {} running {} app version {}",
operation,
request.headers("device_id"),
request.headers("app_platform"),
request.headers("app_version")
);
}

/**
* End tracking by saving the end condition and date.
*/
public static EndTrackingResponse endTracking(Request request) {
TripTrackingData tripData = TripTrackingData.fromRequestJourneyId(request);
if (tripData != null) {
logTracking(request, "endtracking");
return completeJourney(tripData, false);
}
return null;
Expand All @@ -211,6 +254,7 @@ public static EndTrackingResponse forciblyEndTracking(Request request) {
TripTrackingData tripData = TripTrackingData.fromRequestTripId(request);
if (tripData != null) {
if (tripData.journey != null) {
logTracking(request, "forciblyendtracking");
return completeJourney(tripData, true);
} else {
logMessageAndHalt(request, HttpStatus.BAD_REQUEST_400, "Journey for provided trip id does not exist!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ public class TrackingLocation {

public Date timestamp;

/** ID of the device that reported the location - For troubleshooting only. */
public String device_id;

/** The OS of the device that reported the location - For troubleshooting only. */
public String app_platform;

/** App version of the device that reported the location - For troubleshooting only. */
public String app_version;

/** Deviation or on-time status computed for this location. */
public TripStatus tripStatus;

Expand Down
Loading
Loading