prepare the inbound to calculate the different parameters
This commit is contained in:
@@ -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 {
|
||||
if (input instanceof ControllerInputDto) {
|
||||
return {
|
||||
reportedTime: input.reportedTime,
|
||||
remainingRoute: WaypointConverter.convertList(input.remainingRoute),
|
||||
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 {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
|
||||
import { Document } from 'mongoose';
|
||||
import { Waypoint, WaypointSchema } from 'src/generic/models/waypoint.model';
|
||||
import {
|
||||
PredictedWaypoint,
|
||||
PredictedWaypointSchema,
|
||||
} from './predictedwaypoint.model';
|
||||
|
||||
export type ControllerInputDocument = ControllerInput & Document;
|
||||
|
||||
@@ -13,9 +16,9 @@ export class ControllerInput {
|
||||
|
||||
@Prop({
|
||||
required: true,
|
||||
type: [WaypointSchema],
|
||||
type: [PredictedWaypointSchema],
|
||||
})
|
||||
remainingRoute: Waypoint[];
|
||||
remainingRoute: PredictedWaypoint[];
|
||||
|
||||
@Prop({
|
||||
type: String,
|
||||
|
||||
@@ -13,25 +13,21 @@ export class PredictedWaypoint {
|
||||
waypoint: Waypoint;
|
||||
|
||||
@Prop({
|
||||
required: true,
|
||||
type: Number,
|
||||
})
|
||||
altitude: number;
|
||||
|
||||
@Prop({
|
||||
required: true,
|
||||
type: Number,
|
||||
})
|
||||
indicatedAirspeed: number;
|
||||
|
||||
@Prop({
|
||||
required: true,
|
||||
type: Number,
|
||||
})
|
||||
groundspeed: number;
|
||||
|
||||
@Prop({
|
||||
required: true,
|
||||
type: String,
|
||||
})
|
||||
plannedOverheadTime: string;
|
||||
|
||||
Reference in New Issue
Block a user