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 { Constraint } from './models/constraint.model';
|
||||||
import { Planning } from './models/planning.model';
|
import { Planning } from './models/planning.model';
|
||||||
import { RunwaySpacing } from './models/runwayspacing.model';
|
import { RunwaySpacing } from './models/runwayspacing.model';
|
||||||
|
import { Waypoint } from './models/waypoint.model';
|
||||||
|
import { WaypointDto } from './dto/waypoint.dto';
|
||||||
|
|
||||||
@Controller('airport')
|
@Controller('airport')
|
||||||
export class AirportController {
|
export class AirportController {
|
||||||
@@ -53,7 +55,29 @@ export class AirportController {
|
|||||||
return retval;
|
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[],
|
routes: ArrivalRoute[] | ArrivalRouteDto[],
|
||||||
): T[] {
|
): T[] {
|
||||||
const retval: T[] = [];
|
const retval: T[] = [];
|
||||||
@@ -61,7 +85,8 @@ export class AirportController {
|
|||||||
retval.push({
|
retval.push({
|
||||||
arrival: route.runway,
|
arrival: route.runway,
|
||||||
runway: 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),
|
} as T),
|
||||||
);
|
);
|
||||||
return retval;
|
return retval;
|
||||||
@@ -115,12 +140,17 @@ export class AirportController {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
icao: airport.icao,
|
icao: airport.icao,
|
||||||
|
location: AirportController.convertWaypoint<WaypointDto>(
|
||||||
|
airport.location,
|
||||||
|
),
|
||||||
|
elevation: airport.elevation,
|
||||||
upperConstraints: AirportController.convertConstraints<ConstraintDto>(
|
upperConstraints: AirportController.convertConstraints<ConstraintDto>(
|
||||||
airport.upperConstraints,
|
airport.upperConstraints,
|
||||||
),
|
),
|
||||||
arrivalRoutes: AirportController.convertArrivalRoutes<
|
arrivalRoutes: AirportController.convertArrivalRoutes<
|
||||||
ArrivalRouteDto,
|
ArrivalRouteDto,
|
||||||
ConstraintDto
|
ConstraintDto,
|
||||||
|
WaypointDto
|
||||||
>(airport.arrivalRoutes),
|
>(airport.arrivalRoutes),
|
||||||
spacings: AirportController.convertRunwaySpacings<RunwaySpacingDto>(
|
spacings: AirportController.convertRunwaySpacings<RunwaySpacingDto>(
|
||||||
airport.spacings,
|
airport.spacings,
|
||||||
@@ -136,12 +166,15 @@ export class AirportController {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
icao: airport.icao,
|
icao: airport.icao,
|
||||||
|
location: AirportController.convertWaypoint<Waypoint>(airport.location),
|
||||||
|
elevation: airport.elevation,
|
||||||
upperConstraints: AirportController.convertConstraints<Constraint>(
|
upperConstraints: AirportController.convertConstraints<Constraint>(
|
||||||
airport.upperConstraints,
|
airport.upperConstraints,
|
||||||
),
|
),
|
||||||
arrivalRoutes: AirportController.convertArrivalRoutes<
|
arrivalRoutes: AirportController.convertArrivalRoutes<
|
||||||
ArrivalRoute,
|
ArrivalRoute,
|
||||||
Constraint
|
Constraint,
|
||||||
|
Waypoint
|
||||||
>(airport.arrivalRoutes),
|
>(airport.arrivalRoutes),
|
||||||
spacings: AirportController.convertRunwaySpacings<RunwaySpacing>(
|
spacings: AirportController.convertRunwaySpacings<RunwaySpacing>(
|
||||||
airport.spacings,
|
airport.spacings,
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { ConstraintDto } from './constraint.dto';
|
|||||||
import { ArrivalRouteDto } from './arrivalroute.dto';
|
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 './waypoint.dto';
|
||||||
|
|
||||||
export class AirportDto {
|
export class AirportDto {
|
||||||
@IsNotEmpty()
|
@IsNotEmpty()
|
||||||
@@ -13,6 +14,18 @@ export class AirportDto {
|
|||||||
})
|
})
|
||||||
icao: string;
|
icao: string;
|
||||||
|
|
||||||
|
@IsNotEmpty()
|
||||||
|
@ApiProperty({
|
||||||
|
description: 'The airport location',
|
||||||
|
})
|
||||||
|
location: WaypointDto;
|
||||||
|
|
||||||
|
@IsNotEmpty()
|
||||||
|
@ApiProperty({
|
||||||
|
description: 'The airport elevation in feet',
|
||||||
|
})
|
||||||
|
elevation: number;
|
||||||
|
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@ApiProperty({
|
@ApiProperty({
|
||||||
description: 'The constraints in upper airspaces',
|
description: 'The constraints in upper airspaces',
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { IsNotEmpty, IsOptional } from 'class-validator';
|
import { IsNotEmpty, IsOptional } from 'class-validator';
|
||||||
import { ApiProperty } from '@nestjs/swagger';
|
import { ApiProperty } from '@nestjs/swagger';
|
||||||
import { ConstraintDto } from './constraint.dto';
|
import { ConstraintDto } from './constraint.dto';
|
||||||
|
import { WaypointDto } from './waypoint.dto';
|
||||||
|
|
||||||
export class ArrivalRouteDto {
|
export class ArrivalRouteDto {
|
||||||
@IsNotEmpty()
|
@IsNotEmpty()
|
||||||
@@ -17,6 +18,12 @@ export class ArrivalRouteDto {
|
|||||||
})
|
})
|
||||||
runway: string;
|
runway: string;
|
||||||
|
|
||||||
|
@IsNotEmpty()
|
||||||
|
@ApiProperty({
|
||||||
|
description: 'The waypoints of the arrival route',
|
||||||
|
})
|
||||||
|
waypoints: WaypointDto[];
|
||||||
|
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@ApiProperty({
|
@ApiProperty({
|
||||||
description: 'The constraints on the arrival route',
|
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 { 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 './waypoint.model';
|
||||||
|
|
||||||
export type AirportDocument = Airport & Document;
|
export type AirportDocument = Airport & Document;
|
||||||
|
|
||||||
@@ -15,6 +16,18 @@ export class Airport {
|
|||||||
})
|
})
|
||||||
icao: string;
|
icao: string;
|
||||||
|
|
||||||
|
@Prop({
|
||||||
|
required: true,
|
||||||
|
type: Waypoint,
|
||||||
|
})
|
||||||
|
location: Waypoint;
|
||||||
|
|
||||||
|
@Prop({
|
||||||
|
required: true,
|
||||||
|
type: Number,
|
||||||
|
})
|
||||||
|
elevation: number;
|
||||||
|
|
||||||
@Prop({
|
@Prop({
|
||||||
type: [ConstraintSchema],
|
type: [ConstraintSchema],
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
|
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
|
||||||
import { Document } from 'mongoose';
|
import { Document } from 'mongoose';
|
||||||
import { Constraint, ConstraintSchema } from './constraint.model';
|
import { Constraint, ConstraintSchema } from './constraint.model';
|
||||||
|
import { Waypoint, WaypointSchema } from './waypoint.model';
|
||||||
|
|
||||||
export type ArrivalRouteDocument = ArrivalRoute & Document;
|
export type ArrivalRouteDocument = ArrivalRoute & Document;
|
||||||
|
|
||||||
@@ -18,6 +19,12 @@ export class ArrivalRoute {
|
|||||||
})
|
})
|
||||||
runway: string;
|
runway: string;
|
||||||
|
|
||||||
|
@Prop({
|
||||||
|
required: true,
|
||||||
|
type: [WaypointSchema],
|
||||||
|
})
|
||||||
|
waypoints: Waypoint[];
|
||||||
|
|
||||||
@Prop({
|
@Prop({
|
||||||
type: [ConstraintSchema],
|
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