mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-19 08:50:29 +00:00
Add updated test cases and update call to stop arrival helper
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user