Skip to content

Commit

Permalink
Also provide vehicle speed on request
Browse files Browse the repository at this point in the history
  • Loading branch information
n1kPLV committed Sep 6, 2023
1 parent 616a5fa commit 890b407
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Server/src/models/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

/**
Expand Down Expand Up @@ -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
}

Expand Down
4 changes: 3 additions & 1 deletion Server/src/routes/track.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -236,7 +237,8 @@ export class TrackRoute {
trackerIds: (await database.trackers.getByVehicleId(vehicle.uid)).map(y => y.uid),
pos,
percentagePosition,
heading
heading,
speed
}
})
)
Expand Down

0 comments on commit 890b407

Please sign in to comment.