ソースを参照

prepare the inbound to calculate the different parameters

Sven Czarnian 2 年 前
コミット
4b21859242

+ 35 - 7
src/inbound/inbound.controller.ts

@@ -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 {

+ 6 - 3
src/inbound/models/controllerinput.model.ts

@@ -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,

+ 0 - 4
src/inbound/models/predictedwaypoint.model.ts

@@ -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;