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 { WaypointDto } from '../generic/dto/waypoint.dto';
|
||||||
import { Coordinate } from '../generic/models/coordinate.model';
|
import { Coordinate } from '../generic/models/coordinate.model';
|
||||||
import { CoordinateDto } from '../generic/dto/coordinate.dto';
|
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 { ActiveRunwaysDto } from './dto/activerunways.dto';
|
||||||
|
import { Runway } from './models/runway.model';
|
||||||
|
import { RunwayDto } from './dto/runway.dto';
|
||||||
|
|
||||||
@Controller('airport')
|
@Controller('airport')
|
||||||
export class AirportController {
|
export class AirportController {
|
||||||
@@ -118,6 +120,17 @@ export class AirportController {
|
|||||||
} as T;
|
} 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 {
|
private static airportToAirportDto(airport: Airport): AirportDto {
|
||||||
if (!airport) return null;
|
if (!airport) return null;
|
||||||
|
|
||||||
@@ -127,6 +140,7 @@ export class AirportController {
|
|||||||
airport.location,
|
airport.location,
|
||||||
),
|
),
|
||||||
elevation: airport.elevation,
|
elevation: airport.elevation,
|
||||||
|
runways: AirportController.convertRunways(airport.runways),
|
||||||
upperConstraints: AirportController.convertConstraints<ConstraintDto>(
|
upperConstraints: AirportController.convertConstraints<ConstraintDto>(
|
||||||
airport.upperConstraints,
|
airport.upperConstraints,
|
||||||
),
|
),
|
||||||
@@ -156,6 +170,7 @@ export class AirportController {
|
|||||||
airport.location,
|
airport.location,
|
||||||
),
|
),
|
||||||
elevation: airport.elevation,
|
elevation: airport.elevation,
|
||||||
|
runways: AirportController.convertRunways(airport.runways),
|
||||||
upperConstraints: AirportController.convertConstraints<Constraint>(
|
upperConstraints: AirportController.convertConstraints<Constraint>(
|
||||||
airport.upperConstraints,
|
airport.upperConstraints,
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { ArrivalRouteDto } from './arrivalroute.dto';
|
|||||||
import { RunwaySpacingDto } from './runwayspacing.dto';
|
import { RunwaySpacingDto } from './runwayspacing.dto';
|
||||||
import { PlanningDto } from './planning.dto';
|
import { PlanningDto } from './planning.dto';
|
||||||
import { WaypointDto } from '../../generic/dto/waypoint.dto';
|
import { WaypointDto } from '../../generic/dto/waypoint.dto';
|
||||||
|
import { RunwayDto } from './runway.dto';
|
||||||
|
|
||||||
export class AirportDto {
|
export class AirportDto {
|
||||||
@IsNotEmpty()
|
@IsNotEmpty()
|
||||||
@@ -26,6 +27,12 @@ export class AirportDto {
|
|||||||
})
|
})
|
||||||
elevation: number;
|
elevation: number;
|
||||||
|
|
||||||
|
@IsNotEmpty()
|
||||||
|
@ApiProperty({
|
||||||
|
description: 'All possible arrival runways',
|
||||||
|
})
|
||||||
|
runways: RunwayDto[];
|
||||||
|
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@ApiProperty({
|
@ApiProperty({
|
||||||
description: 'The constraints in upper airspaces',
|
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 { Planning, PlanningSchema } from './planning.model';
|
||||||
import { RunwaySpacing, RunwaySpacingSchema } from './runwayspacing.model';
|
import { RunwaySpacing, RunwaySpacingSchema } from './runwayspacing.model';
|
||||||
import { Waypoint } from '../../generic/models/waypoint.model';
|
import { Waypoint } from '../../generic/models/waypoint.model';
|
||||||
|
import { Runway, RunwaySchema } from './runway.model';
|
||||||
|
|
||||||
export type AirportDocument = Airport & Document;
|
export type AirportDocument = Airport & Document;
|
||||||
|
|
||||||
@@ -29,6 +30,12 @@ export class Airport {
|
|||||||
})
|
})
|
||||||
elevation: number;
|
elevation: number;
|
||||||
|
|
||||||
|
@Prop({
|
||||||
|
required: true,
|
||||||
|
type: [RunwaySchema],
|
||||||
|
})
|
||||||
|
runways: Runway[];
|
||||||
|
|
||||||
@Prop({
|
@Prop({
|
||||||
type: [ConstraintSchema],
|
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