prepare the inbound to calculate the different parameters
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
import {
|
import {
|
||||||
Body,
|
|
||||||
Controller,
|
Controller,
|
||||||
Get,
|
Get,
|
||||||
Delete,
|
Delete,
|
||||||
@@ -44,15 +43,44 @@ export class InboundController {
|
|||||||
} as T;
|
} 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>(
|
private static convertControllerInput<T>(
|
||||||
input: ControllerInput | ControllerInputDto,
|
input: ControllerInput | ControllerInputDto,
|
||||||
): T {
|
): T {
|
||||||
return {
|
if (input instanceof ControllerInputDto) {
|
||||||
reportedTime: input.reportedTime,
|
return {
|
||||||
remainingRoute: WaypointConverter.convertList(input.remainingRoute),
|
reportedTime: input.reportedTime,
|
||||||
requestedRunway: input.requestedRunway,
|
remainingRoute: InboundController.waypointsDtoToPredictedWaypoints(
|
||||||
plannedStand: input.plannedStand,
|
input.remainingRoute,
|
||||||
} as T;
|
),
|
||||||
|
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 {
|
private static convertFlightState<T>(input: FlightState | FlightStateDto): T {
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
|
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
|
||||||
import { Document } from '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;
|
export type ControllerInputDocument = ControllerInput & Document;
|
||||||
|
|
||||||
@@ -13,9 +16,9 @@ export class ControllerInput {
|
|||||||
|
|
||||||
@Prop({
|
@Prop({
|
||||||
required: true,
|
required: true,
|
||||||
type: [WaypointSchema],
|
type: [PredictedWaypointSchema],
|
||||||
})
|
})
|
||||||
remainingRoute: Waypoint[];
|
remainingRoute: PredictedWaypoint[];
|
||||||
|
|
||||||
@Prop({
|
@Prop({
|
||||||
type: String,
|
type: String,
|
||||||
|
|||||||
@@ -13,25 +13,21 @@ export class PredictedWaypoint {
|
|||||||
waypoint: Waypoint;
|
waypoint: Waypoint;
|
||||||
|
|
||||||
@Prop({
|
@Prop({
|
||||||
required: true,
|
|
||||||
type: Number,
|
type: Number,
|
||||||
})
|
})
|
||||||
altitude: number;
|
altitude: number;
|
||||||
|
|
||||||
@Prop({
|
@Prop({
|
||||||
required: true,
|
|
||||||
type: Number,
|
type: Number,
|
||||||
})
|
})
|
||||||
indicatedAirspeed: number;
|
indicatedAirspeed: number;
|
||||||
|
|
||||||
@Prop({
|
@Prop({
|
||||||
required: true,
|
|
||||||
type: Number,
|
type: Number,
|
||||||
})
|
})
|
||||||
groundspeed: number;
|
groundspeed: number;
|
||||||
|
|
||||||
@Prop({
|
@Prop({
|
||||||
required: true,
|
|
||||||
type: String,
|
type: String,
|
||||||
})
|
})
|
||||||
plannedOverheadTime: string;
|
plannedOverheadTime: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user