introduce the runway definitions
This commit is contained in:
		| @@ -27,8 +27,10 @@ import { Waypoint } from '../generic/models/waypoint.model'; | ||||
| import { WaypointDto } from '../generic/dto/waypoint.dto'; | ||||
| import { Coordinate } from '../generic/models/coordinate.model'; | ||||
| import { CoordinateDto } from '../generic/dto/coordinate.dto'; | ||||
| import { WaypointConverter } from '../generic/converters'; | ||||
| import { CoordinateConverter, WaypointConverter } from '../generic/converters'; | ||||
| import { ActiveRunwaysDto } from './dto/activerunways.dto'; | ||||
| import { Runway } from './models/runway.model'; | ||||
| import { RunwayDto } from './dto/runway.dto'; | ||||
|  | ||||
| @Controller('airport') | ||||
| export class AirportController { | ||||
| @@ -118,6 +120,17 @@ export class AirportController { | ||||
|     } as T; | ||||
|   } | ||||
|  | ||||
|   private static convertRunways<T>(runways: Runway[] | RunwayDto[]): T[] { | ||||
|     const retval: T[] = []; | ||||
|     runways.forEach((runway) => | ||||
|       retval.push({ | ||||
|         identifier: runway.identifier, | ||||
|         threshold: CoordinateConverter.convert(runway.threshold), | ||||
|       } as T), | ||||
|     ); | ||||
|     return retval; | ||||
|   } | ||||
|  | ||||
|   private static airportToAirportDto(airport: Airport): AirportDto { | ||||
|     if (!airport) return null; | ||||
|  | ||||
| @@ -127,6 +140,7 @@ export class AirportController { | ||||
|         airport.location, | ||||
|       ), | ||||
|       elevation: airport.elevation, | ||||
|       runways: AirportController.convertRunways(airport.runways), | ||||
|       upperConstraints: AirportController.convertConstraints<ConstraintDto>( | ||||
|         airport.upperConstraints, | ||||
|       ), | ||||
| @@ -156,6 +170,7 @@ export class AirportController { | ||||
|         airport.location, | ||||
|       ), | ||||
|       elevation: airport.elevation, | ||||
|       runways: AirportController.convertRunways(airport.runways), | ||||
|       upperConstraints: AirportController.convertConstraints<Constraint>( | ||||
|         airport.upperConstraints, | ||||
|       ), | ||||
|   | ||||
| @@ -5,6 +5,7 @@ import { ArrivalRouteDto } from './arrivalroute.dto'; | ||||
| import { RunwaySpacingDto } from './runwayspacing.dto'; | ||||
| import { PlanningDto } from './planning.dto'; | ||||
| import { WaypointDto } from '../../generic/dto/waypoint.dto'; | ||||
| import { RunwayDto } from './runway.dto'; | ||||
|  | ||||
| export class AirportDto { | ||||
|   @IsNotEmpty() | ||||
| @@ -26,6 +27,12 @@ export class AirportDto { | ||||
|   }) | ||||
|   elevation: number; | ||||
|  | ||||
|   @IsNotEmpty() | ||||
|   @ApiProperty({ | ||||
|     description: 'All possible arrival runways', | ||||
|   }) | ||||
|   runways: RunwayDto[]; | ||||
|  | ||||
|   @IsOptional() | ||||
|   @ApiProperty({ | ||||
|     description: 'The constraints in upper airspaces', | ||||
|   | ||||
							
								
								
									
										18
									
								
								src/airport/dto/runway.dto.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								src/airport/dto/runway.dto.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,18 @@ | ||||
| import { IsNotEmpty } from 'class-validator'; | ||||
| import { ApiProperty } from '@nestjs/swagger'; | ||||
| import { CoordinateDto } from '../../generic/dto/coordinate.dto'; | ||||
|  | ||||
| export class RunwayDto { | ||||
|   @IsNotEmpty() | ||||
|   @ApiProperty({ | ||||
|     description: 'The identifier of the runway', | ||||
|     example: '25L', | ||||
|   }) | ||||
|   identifier: string; | ||||
|  | ||||
|   @IsNotEmpty() | ||||
|   @ApiProperty({ | ||||
|     description: 'The runway threshold', | ||||
|   }) | ||||
|   altitude: CoordinateDto; | ||||
| } | ||||
| @@ -5,6 +5,7 @@ import { Constraint, ConstraintSchema } from './constraint.model'; | ||||
| import { Planning, PlanningSchema } from './planning.model'; | ||||
| import { RunwaySpacing, RunwaySpacingSchema } from './runwayspacing.model'; | ||||
| import { Waypoint } from '../../generic/models/waypoint.model'; | ||||
| import { Runway, RunwaySchema } from './runway.model'; | ||||
|  | ||||
| export type AirportDocument = Airport & Document; | ||||
|  | ||||
| @@ -29,6 +30,12 @@ export class Airport { | ||||
|   }) | ||||
|   elevation: number; | ||||
|  | ||||
|   @Prop({ | ||||
|     required: true, | ||||
|     type: [RunwaySchema], | ||||
|   }) | ||||
|   runways: Runway[]; | ||||
|  | ||||
|   @Prop({ | ||||
|     type: [ConstraintSchema], | ||||
|   }) | ||||
|   | ||||
							
								
								
									
										25
									
								
								src/airport/models/runway.model.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								src/airport/models/runway.model.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,25 @@ | ||||
| import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; | ||||
| import { Document } from 'mongoose'; | ||||
| import { | ||||
|   Coordinate, | ||||
|   CoordinateSchema, | ||||
| } from '../../generic/models/coordinate.model'; | ||||
|  | ||||
| export type RunwayDocument = Runway & Document; | ||||
|  | ||||
| @Schema() | ||||
| export class Runway { | ||||
|   @Prop({ | ||||
|     required: true, | ||||
|     type: String, | ||||
|   }) | ||||
|   identifier: string; | ||||
|  | ||||
|   @Prop({ | ||||
|     required: true, | ||||
|     type: CoordinateSchema, | ||||
|   }) | ||||
|   threshold: Coordinate; | ||||
| } | ||||
|  | ||||
| export const RunwaySchema = SchemaFactory.createForClass(Runway); | ||||
		Reference in New Issue
	
	Block a user