diff options
| author | copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> | 2025-11-22 16:17:29 +0000 |
|---|---|---|
| committer | Ariel Costas Guerrero <ariel@costas.dev> | 2025-11-22 18:31:59 +0100 |
| commit | 71dd498ab6ef05df944ce42e0d2228d8ff4dc418 (patch) | |
| tree | 57e2a42ddca99d5c8c050cd04d0ae7fb75b8f1f1 /src/Costasdev.Busurbano.Backend/Controllers/VigoController.cs | |
| parent | bb5745d849d4899d1672b6a689cd071953b01866 (diff) | |
Add previous_trip_shape_id field to protobuf and implement linking logic
Co-authored-by: arielcostas <94913521+arielcostas@users.noreply.github.com>
Diffstat (limited to 'src/Costasdev.Busurbano.Backend/Controllers/VigoController.cs')
| -rw-r--r-- | src/Costasdev.Busurbano.Backend/Controllers/VigoController.cs | 7 |
1 files changed, 5 insertions, 2 deletions
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); |
