diff options
| author | Ariel Costas Guerrero <ariel@costas.dev> | 2025-11-22 17:59:54 +0100 |
|---|---|---|
| committer | Ariel Costas Guerrero <ariel@costas.dev> | 2025-11-22 18:33:23 +0100 |
| commit | 2901dddf0309942583ffc812168a149b65b3bdc6 (patch) | |
| tree | 1a03b4bb3838f823735dfd3c9d0340785987949e | |
| parent | dc1cf01110fe9ecee05c11dcddc50cb3c8f674fc (diff) | |
feat: Enhance bus position calculation to support previous trip shapes and improve trip ID parsing for multiple formats
| -rw-r--r-- | src/Costasdev.Busurbano.Backend/Controllers/VigoController.cs | 4 | ||||
| -rw-r--r-- | src/gtfs_vigo_stops/stop_report.py | 2 |
2 files changed, 2 insertions, 4 deletions
diff --git a/src/Costasdev.Busurbano.Backend/Controllers/VigoController.cs b/src/Costasdev.Busurbano.Backend/Controllers/VigoController.cs index 570b56d..8e3f54e 100644 --- a/src/Costasdev.Busurbano.Backend/Controllers/VigoController.cs +++ b/src/Costasdev.Busurbano.Backend/Controllers/VigoController.cs @@ -315,8 +315,8 @@ 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; - usePreviousShape = !isRunning && - !string.IsNullOrEmpty(closestCirculation.PreviousTripShapeId) && + usePreviousShape = !isRunning && + !string.IsNullOrEmpty(closestCirculation.PreviousTripShapeId) && distOnPrevTrip > 0; if (usePreviousShape) diff --git a/src/gtfs_vigo_stops/stop_report.py b/src/gtfs_vigo_stops/stop_report.py index adc08b1..cb10801 100644 --- a/src/gtfs_vigo_stops/stop_report.py +++ b/src/gtfs_vigo_stops/stop_report.py @@ -166,7 +166,6 @@ def parse_trip_id_components(trip_id: str) -> Optional[Tuple[str, str, int]]: if len(parts) >= 2: shift_part = parts[-2] trip_num_str = parts[-1] - if len(shift_part) == 6 and shift_part.isdigit() and trip_num_str.isdigit(): line = shift_part[:3] shift_id = shift_part[3:6] @@ -186,7 +185,6 @@ def parse_trip_id_components(trip_id: str) -> Optional[Tuple[str, str, int]]: shift_id = shift_part[3:6] # Next 3 digits trip_number = int(trip_num_str) return (line, shift_id, trip_number) - return None except (ValueError, IndexError): return None |
