diff options
Diffstat (limited to 'src/Costasdev.Busurbano.Backend/Controllers')
| -rw-r--r-- | src/Costasdev.Busurbano.Backend/Controllers/VigoController.cs | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/src/Costasdev.Busurbano.Backend/Controllers/VigoController.cs b/src/Costasdev.Busurbano.Backend/Controllers/VigoController.cs index 12489ca..f3f3d69 100644 --- a/src/Costasdev.Busurbano.Backend/Controllers/VigoController.cs +++ b/src/Costasdev.Busurbano.Backend/Controllers/VigoController.cs @@ -210,11 +210,9 @@ public class VigoController : ControllerBase // Matching strategy: // 1) Prefer a started trip whose scheduled calling time is close to the estimated arrival. // 2) If no good started match, pick the next not-started trip (soonest in the future). - // 3) Reject matches where scheduled time is >10 minutes AFTER realtime (data inconsistency). - // 4) Reject matches where the bus would arrive >3 minutes BEFORE schedule (too early). - // 5) Fallbacks: if no future trips, use the best started one even if far. + // 3) Reject matches where the bus would arrive >3 minutes BEFORE schedule (too early). + // 4) Fallbacks: if no future trips, use the best started one even if far. const int startedMatchToleranceMinutes = 15; // how close a started trip must be to consider it a match - const int maxScheduleDelayMinutes = 10; // reject if scheduled is this much later than realtime const int maxEarlyArrivalMinutes = 3; // reject if bus arrives more than 3 minutes before schedule var startedCandidates = possibleCirculations @@ -242,23 +240,17 @@ public class VigoController : ControllerBase // Check best started candidate if (bestStarted != null && bestStarted.AbsDiff <= startedMatchToleranceMinutes && - bestStarted.TimeDiff <= maxScheduleDelayMinutes && // reject if scheduled too far after realtime bestStarted.TimeDiff >= -maxEarlyArrivalMinutes) // reject if bus arrives too early { closestCirculation = bestStarted.Circulation; } else if (futureCandidates.Count > 0) { - // Pick the soonest upcoming trip, but reject if it's scheduled too far after realtime + // Pick the soonest upcoming trip var soonest = futureCandidates.First(); - if (soonest.TimeDiff <= maxScheduleDelayMinutes) - { - closestCirculation = soonest.Circulation; - } - // Otherwise, leave it null (no valid match) + closestCirculation = soonest.Circulation; } else if (bestStarted != null && - bestStarted.TimeDiff <= maxScheduleDelayMinutes && bestStarted.TimeDiff >= -maxEarlyArrivalMinutes) { // nothing upcoming today; fallback to the closest started one (if timing is reasonable) |
