add all waypoints of the arrival routes
This commit is contained in:
		| @@ -22,6 +22,8 @@ import { Assignment } from './models/assignment.model'; | ||||
| import { Constraint } from './models/constraint.model'; | ||||
| import { Planning } from './models/planning.model'; | ||||
| import { RunwaySpacing } from './models/runwayspacing.model'; | ||||
| import { Waypoint } from './models/waypoint.model'; | ||||
| import { WaypointDto } from './dto/waypoint.dto'; | ||||
|  | ||||
| @Controller('airport') | ||||
| export class AirportController { | ||||
| @@ -53,7 +55,29 @@ export class AirportController { | ||||
|     return retval; | ||||
|   } | ||||
|  | ||||
|   private static convertArrivalRoutes<T, U>( | ||||
|   private static convertWaypoint<T>(waypoint: Waypoint | WaypointDto): T { | ||||
|     return { | ||||
|       identifier: waypoint.identifier, | ||||
|       latitude: waypoint.latitude, | ||||
|       longitude: waypoint.longitude, | ||||
|     } as T; | ||||
|   } | ||||
|  | ||||
|   private static convertWaypoints<T>( | ||||
|     waypoints: Waypoint[] | WaypointDto[], | ||||
|   ): T[] { | ||||
|     const retval: T[] = []; | ||||
|     waypoints.forEach((waypoint) => | ||||
|       retval.push({ | ||||
|         identifier: waypoint.identifier, | ||||
|         latitude: waypoint.latitude, | ||||
|         longitude: waypoint.longitude, | ||||
|       } as T), | ||||
|     ); | ||||
|     return retval; | ||||
|   } | ||||
|  | ||||
|   private static convertArrivalRoutes<T, C, W>( | ||||
|     routes: ArrivalRoute[] | ArrivalRouteDto[], | ||||
|   ): T[] { | ||||
|     const retval: T[] = []; | ||||
| @@ -61,7 +85,8 @@ export class AirportController { | ||||
|       retval.push({ | ||||
|         arrival: route.runway, | ||||
|         runway: route.runway, | ||||
|         constraints: AirportController.convertConstraints<U>(route.constraints), | ||||
|         waypoints: AirportController.convertWaypoints<W>(route.waypoints), | ||||
|         constraints: AirportController.convertConstraints<C>(route.constraints), | ||||
|       } as T), | ||||
|     ); | ||||
|     return retval; | ||||
| @@ -115,12 +140,17 @@ export class AirportController { | ||||
|  | ||||
|     return { | ||||
|       icao: airport.icao, | ||||
|       location: AirportController.convertWaypoint<WaypointDto>( | ||||
|         airport.location, | ||||
|       ), | ||||
|       elevation: airport.elevation, | ||||
|       upperConstraints: AirportController.convertConstraints<ConstraintDto>( | ||||
|         airport.upperConstraints, | ||||
|       ), | ||||
|       arrivalRoutes: AirportController.convertArrivalRoutes< | ||||
|         ArrivalRouteDto, | ||||
|         ConstraintDto | ||||
|         ConstraintDto, | ||||
|         WaypointDto | ||||
|       >(airport.arrivalRoutes), | ||||
|       spacings: AirportController.convertRunwaySpacings<RunwaySpacingDto>( | ||||
|         airport.spacings, | ||||
| @@ -136,12 +166,15 @@ export class AirportController { | ||||
|  | ||||
|     return { | ||||
|       icao: airport.icao, | ||||
|       location: AirportController.convertWaypoint<Waypoint>(airport.location), | ||||
|       elevation: airport.elevation, | ||||
|       upperConstraints: AirportController.convertConstraints<Constraint>( | ||||
|         airport.upperConstraints, | ||||
|       ), | ||||
|       arrivalRoutes: AirportController.convertArrivalRoutes< | ||||
|         ArrivalRoute, | ||||
|         Constraint | ||||
|         Constraint, | ||||
|         Waypoint | ||||
|       >(airport.arrivalRoutes), | ||||
|       spacings: AirportController.convertRunwaySpacings<RunwaySpacing>( | ||||
|         airport.spacings, | ||||
|   | ||||
| @@ -4,6 +4,7 @@ import { ConstraintDto } from './constraint.dto'; | ||||
| import { ArrivalRouteDto } from './arrivalroute.dto'; | ||||
| import { RunwaySpacingDto } from './runwayspacing.dto'; | ||||
| import { PlanningDto } from './planning.dto'; | ||||
| import { WaypointDto } from './waypoint.dto'; | ||||
|  | ||||
| export class AirportDto { | ||||
|   @IsNotEmpty() | ||||
| @@ -13,6 +14,18 @@ export class AirportDto { | ||||
|   }) | ||||
|   icao: string; | ||||
|  | ||||
|   @IsNotEmpty() | ||||
|   @ApiProperty({ | ||||
|     description: 'The airport location', | ||||
|   }) | ||||
|   location: WaypointDto; | ||||
|  | ||||
|   @IsNotEmpty() | ||||
|   @ApiProperty({ | ||||
|     description: 'The airport elevation in feet', | ||||
|   }) | ||||
|   elevation: number; | ||||
|  | ||||
|   @IsOptional() | ||||
|   @ApiProperty({ | ||||
|     description: 'The constraints in upper airspaces', | ||||
|   | ||||
| @@ -1,6 +1,7 @@ | ||||
| import { IsNotEmpty, IsOptional } from 'class-validator'; | ||||
| import { ApiProperty } from '@nestjs/swagger'; | ||||
| import { ConstraintDto } from './constraint.dto'; | ||||
| import { WaypointDto } from './waypoint.dto'; | ||||
|  | ||||
| export class ArrivalRouteDto { | ||||
|   @IsNotEmpty() | ||||
| @@ -17,6 +18,12 @@ export class ArrivalRouteDto { | ||||
|   }) | ||||
|   runway: string; | ||||
|  | ||||
|   @IsNotEmpty() | ||||
|   @ApiProperty({ | ||||
|     description: 'The waypoints of the arrival route', | ||||
|   }) | ||||
|   waypoints: WaypointDto[]; | ||||
|  | ||||
|   @IsOptional() | ||||
|   @ApiProperty({ | ||||
|     description: 'The constraints on the arrival route', | ||||
|   | ||||
							
								
								
									
										27
									
								
								src/airport/dto/waypoint.dto.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								src/airport/dto/waypoint.dto.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,27 @@ | ||||
| import { IsNotEmpty, IsLatitude, IsLongitude } from 'class-validator'; | ||||
| import { ApiProperty } from '@nestjs/swagger'; | ||||
|  | ||||
| export class WaypointDto { | ||||
|   @IsNotEmpty() | ||||
|   @ApiProperty({ | ||||
|     description: 'The unique waypoint code', | ||||
|     example: 'KETAP', | ||||
|   }) | ||||
|   identifier: string; | ||||
|  | ||||
|   @IsNotEmpty() | ||||
|   @ApiProperty({ | ||||
|     description: 'The latitudinal component', | ||||
|     example: 42.8402, | ||||
|   }) | ||||
|   @IsLatitude() | ||||
|   latitude: number; | ||||
|  | ||||
|   @IsNotEmpty() | ||||
|   @ApiProperty({ | ||||
|     description: 'The longitudinal component', | ||||
|     example: 18.8402, | ||||
|   }) | ||||
|   @IsLongitude() | ||||
|   longitude: number; | ||||
| } | ||||
| @@ -4,6 +4,7 @@ import { ArrivalRoute, ArrivalRouteSchema } from './arrivalroute.model'; | ||||
| import { Constraint, ConstraintSchema } from './constraint.model'; | ||||
| import { Planning, PlanningSchema } from './planning.model'; | ||||
| import { RunwaySpacing, RunwaySpacingSchema } from './runwayspacing.model'; | ||||
| import { Waypoint } from './waypoint.model'; | ||||
|  | ||||
| export type AirportDocument = Airport & Document; | ||||
|  | ||||
| @@ -15,6 +16,18 @@ export class Airport { | ||||
|   }) | ||||
|   icao: string; | ||||
|  | ||||
|   @Prop({ | ||||
|     required: true, | ||||
|     type: Waypoint, | ||||
|   }) | ||||
|   location: Waypoint; | ||||
|  | ||||
|   @Prop({ | ||||
|     required: true, | ||||
|     type: Number, | ||||
|   }) | ||||
|   elevation: number; | ||||
|  | ||||
|   @Prop({ | ||||
|     type: [ConstraintSchema], | ||||
|   }) | ||||
|   | ||||
| @@ -1,6 +1,7 @@ | ||||
| import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; | ||||
| import { Document } from 'mongoose'; | ||||
| import { Constraint, ConstraintSchema } from './constraint.model'; | ||||
| import { Waypoint, WaypointSchema } from './waypoint.model'; | ||||
|  | ||||
| export type ArrivalRouteDocument = ArrivalRoute & Document; | ||||
|  | ||||
| @@ -18,6 +19,12 @@ export class ArrivalRoute { | ||||
|   }) | ||||
|   runway: string; | ||||
|  | ||||
|   @Prop({ | ||||
|     required: true, | ||||
|     type: [WaypointSchema], | ||||
|   }) | ||||
|   waypoints: Waypoint[]; | ||||
|  | ||||
|   @Prop({ | ||||
|     type: [ConstraintSchema], | ||||
|   }) | ||||
|   | ||||
							
								
								
									
										27
									
								
								src/airport/models/waypoint.model.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								src/airport/models/waypoint.model.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,27 @@ | ||||
| import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; | ||||
| import { Document } from 'mongoose'; | ||||
|  | ||||
| export type WaypointDocument = Waypoint & Document; | ||||
|  | ||||
| @Schema() | ||||
| export class Waypoint { | ||||
|   @Prop({ | ||||
|     required: true, | ||||
|     type: String, | ||||
|   }) | ||||
|   identifier: string; | ||||
|  | ||||
|   @Prop({ | ||||
|     required: true, | ||||
|     type: Number, | ||||
|   }) | ||||
|   latitude: number; | ||||
|  | ||||
|   @Prop({ | ||||
|     required: true, | ||||
|     type: Number, | ||||
|   }) | ||||
|   longitude: number; | ||||
| } | ||||
|  | ||||
| export const WaypointSchema = SchemaFactory.createForClass(Waypoint); | ||||
		Reference in New Issue
	
	Block a user