From 71dd498ab6ef05df944ce42e0d2228d8ff4dc418 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 22 Nov 2025 16:17:29 +0000 Subject: Add previous_trip_shape_id field to protobuf and implement linking logic Co-authored-by: arielcostas <94913521+arielcostas@users.noreply.github.com> --- src/Costasdev.Busurbano.Backend/Controllers/VigoController.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/Costasdev.Busurbano.Backend/Controllers') diff --git a/src/Costasdev.Busurbano.Backend/Controllers/VigoController.cs b/src/Costasdev.Busurbano.Backend/Controllers/VigoController.cs index 91ccdab..570b56d 100644 --- a/src/Costasdev.Busurbano.Backend/Controllers/VigoController.cs +++ b/src/Costasdev.Busurbano.Backend/Controllers/VigoController.cs @@ -306,6 +306,7 @@ public class VigoController : ControllerBase var isRunning = closestCirculation.StartingDateTime()!.Value <= now; Position? currentPosition = null; int? stopShapeIndex = null; + bool usePreviousShape = false; // Calculate bus position for realtime trips if (!string.IsNullOrEmpty(closestCirculation.ShapeId)) @@ -314,7 +315,7 @@ public class VigoController : ControllerBase // If the bus is further away than the distance from the start of the trip to the stop, // it implies the bus is on the previous trip (or earlier). double distOnPrevTrip = estimate.Meters - closestCirculation.ShapeDistTraveled; - bool usePreviousShape = !isRunning && + usePreviousShape = !isRunning && !string.IsNullOrEmpty(closestCirculation.PreviousTripShapeId) && distOnPrevTrip > 0; @@ -364,7 +365,9 @@ public class VigoController : ControllerBase Distance = estimate.Meters }, CurrentPosition = currentPosition, - StopShapeIndex = stopShapeIndex + StopShapeIndex = stopShapeIndex, + IsPreviousTrip = usePreviousShape, + PreviousTripShapeId = usePreviousShape ? closestCirculation.PreviousTripShapeId : null }); usedTripIds.Add(closestCirculation.TripId); -- cgit v1.3