From 890b40783dddad5e1c0479c5f20557b73efa0273 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20M=C3=A4ckelmann?= <6890706+n1kPLV@users.noreply.github.com> Date: Wed, 6 Sep 2023 17:15:04 +0200 Subject: [PATCH] Also provide vehicle speed on request --- Server/src/models/api.ts | 3 ++- Server/src/routes/track.route.ts | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Server/src/models/api.ts b/Server/src/models/api.ts index 0c63a109..c4ea3ba0 100644 --- a/Server/src/models/api.ts +++ b/Server/src/models/api.ts @@ -102,6 +102,7 @@ export type Vehicle = UpdateVehicle & { pos?: Position // undefined if position is unknown. percentagePosition?: number // A position mapped onto percentage 0-100) e.g. 0% Malente; 100% Lütjenburg heading?: number // between 0 and 360 + speed?: number // in km/h } /** @@ -129,7 +130,7 @@ export type VehicleType = UpdateVehicleType & { export type Tracker = { id: string vehicleId: number | null - battery?: number + battery?: number // ideally between 0 (empty) and 1 (full). But probably some arbitrary value... data?: unknown } diff --git a/Server/src/routes/track.route.ts b/Server/src/routes/track.route.ts index d670083e..c638b0f2 100644 --- a/Server/src/routes/track.route.ts +++ b/Server/src/routes/track.route.ts @@ -228,6 +228,7 @@ export class TrackRoute { // This might not make much sense. const percentagePosition = (await VehicleService.getVehicleTrackDistancePercentage(vehicle)) ?? undefined const heading = await VehicleService.getVehicleHeading(vehicle) + const speed = await VehicleService.getVehicleSpeed(vehicle) return { id: vehicle.uid, track: vehicle.trackId, @@ -236,7 +237,8 @@ export class TrackRoute { trackerIds: (await database.trackers.getByVehicleId(vehicle.uid)).map(y => y.uid), pos, percentagePosition, - heading + heading, + speed } }) )