prepare the inbound to calculate the different parameters

This commit is contained in:
Sven Czarnian
2022-10-23 23:10:33 +02:00
parent 4158e391a5
commit 4b21859242
3 changed files with 41 additions and 14 deletions

View File

@@ -1,5 +1,4 @@
import {
Body,
Controller,
Get,
Delete,
@@ -44,15 +43,44 @@ export class InboundController {
} as T;
}
private static waypointsDtoToPredictedWaypoints(
waypoints: WaypointDto[],
): PredictedWaypoint[] {
const retval: PredictedWaypoint[] = [];
waypoints.forEach((waypoint) =>
retval.push({
waypoint: WaypointConverter.convert(waypoint),
altitude: undefined,
indicatedAirspeed: undefined,
groundspeed: undefined,
plannedOverheadTime: undefined,
}),
);
return retval;
}
private static convertControllerInput<T>(
input: ControllerInput | ControllerInputDto,
): T {
return {
reportedTime: input.reportedTime,
remainingRoute: WaypointConverter.convertList(input.remainingRoute),
requestedRunway: input.requestedRunway,
plannedStand: input.plannedStand,
} as T;
if (input instanceof ControllerInputDto) {
return {
reportedTime: input.reportedTime,
remainingRoute: InboundController.waypointsDtoToPredictedWaypoints(
input.remainingRoute,
),
requestedRunway: input.requestedRunway,
plannedStand: input.plannedStand,
} as T;
} else {
return {
reportedTime: input.reportedTime,
remainingRoute: InboundController.convertPredictedWaypoints(
input.remainingRoute,
),
requestedRunway: input.requestedRunway,
plannedStand: input.plannedStand,
} as T;
}
}
private static convertFlightState<T>(input: FlightState | FlightStateDto): T {