Add a method to check whether a shuttle has arrived at a stop

This commit is contained in:
2025-11-10 14:33:00 -08:00
parent 8ed23544c5
commit b535868897
2 changed files with 77 additions and 0 deletions

View File

@@ -37,3 +37,15 @@ export interface IOrderedStop extends IEntityWithTimestamp {
systemId: string;
}
/**
* Checks if a shuttle has arrived at a stop based on coordinate proximity.
* Uses a threshold of 0.001 degrees (~111 meters at the equator).
*/
export function shuttleHasArrivedAtStop(shuttle: IShuttle, stop: IStop) {
const isWithinLatitudeRange = shuttle.coordinates.latitude > stop.coordinates.latitude - 0.001
&& shuttle.coordinates.latitude < stop.coordinates.latitude + 0.001;
const isWithinLongitudeRange = shuttle.coordinates.longitude > stop.coordinates.longitude - 0.001
&& shuttle.coordinates.longitude < stop.coordinates.longitude + 0.001
return isWithinLatitudeRange && isWithinLongitudeRange;
}