aboutsummaryrefslogtreecommitdiff
path: root/src/Costasdev.Busurbano.Backend
diff options
context:
space:
mode:
authorcopilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>2025-11-22 16:17:29 +0000
committerAriel Costas Guerrero <ariel@costas.dev>2025-11-22 18:31:59 +0100
commit71dd498ab6ef05df944ce42e0d2228d8ff4dc418 (patch)
tree57e2a42ddca99d5c8c050cd04d0ae7fb75b8f1f1 /src/Costasdev.Busurbano.Backend
parentbb5745d849d4899d1672b6a689cd071953b01866 (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')
-rw-r--r--src/Costasdev.Busurbano.Backend/Controllers/VigoController.cs7
-rw-r--r--src/Costasdev.Busurbano.Backend/Types/ConsolidatedCirculation.cs2
2 files changed, 7 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);
diff --git a/src/Costasdev.Busurbano.Backend/Types/ConsolidatedCirculation.cs b/src/Costasdev.Busurbano.Backend/Types/ConsolidatedCirculation.cs
index ff6dbde..5b6373d 100644
--- a/src/Costasdev.Busurbano.Backend/Types/ConsolidatedCirculation.cs
+++ b/src/Costasdev.Busurbano.Backend/Types/ConsolidatedCirculation.cs
@@ -9,6 +9,8 @@ public class ConsolidatedCirculation
public RealTimeData? RealTime { get; set; }
public Position? CurrentPosition { get; set; }
public int? StopShapeIndex { get; set; }
+ public bool IsPreviousTrip { get; set; }
+ public string? PreviousTripShapeId { get; set; }
public string[] NextStreets { get; set; } = [];
}