Add updated test cases and update call to stop arrival helper

This commit is contained in:
2025-11-10 15:09:13 -08:00
parent 63ed267ded
commit 2a80a049bd
3 changed files with 52 additions and 8 deletions

View File

@@ -41,11 +41,15 @@ export interface IOrderedStop extends IEntityWithTimestamp {
* 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
export function shuttleHasArrivedAtStop(
shuttle: IShuttle,
stop: IStop,
delta = 0.001
) {
const isWithinLatitudeRange = shuttle.coordinates.latitude > stop.coordinates.latitude - delta
&& shuttle.coordinates.latitude < stop.coordinates.latitude + delta;
const isWithinLongitudeRange = shuttle.coordinates.longitude > stop.coordinates.longitude - delta
&& shuttle.coordinates.longitude < stop.coordinates.longitude + delta
return isWithinLatitudeRange && isWithinLongitudeRange;
}