define a generic folder
This commit is contained in:
@@ -22,10 +22,11 @@ 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';
|
||||
import { Coordinate } from 'src/models/coordinate.model';
|
||||
import { CoordinateDto } from 'src/dto/coordinate.dto';
|
||||
import { Waypoint } from '../generic/models/waypoint.model';
|
||||
import { WaypointDto } from '../generic/dto/waypoint.dto';
|
||||
import { Coordinate } from 'src/generic/models/coordinate.model';
|
||||
import { CoordinateDto } from 'src/generic/dto/coordinate.dto';
|
||||
import { WaypointConverter } from 'src/generic/converters';
|
||||
|
||||
@Controller('airport')
|
||||
export class AirportController {
|
||||
@@ -57,32 +58,6 @@ export class AirportController {
|
||||
return retval;
|
||||
}
|
||||
|
||||
private static convertCoordinate<T>(
|
||||
coordinate: Coordinate | CoordinateDto,
|
||||
): T {
|
||||
return {
|
||||
latitude: coordinate.latitude,
|
||||
longitude: coordinate.longitude,
|
||||
} as T;
|
||||
}
|
||||
|
||||
private static convertWaypoint<T, C>(waypoint: Waypoint | WaypointDto): T {
|
||||
return {
|
||||
identifier: waypoint.identifier,
|
||||
coordinate: AirportController.convertCoordinate<C>(waypoint.coordinate),
|
||||
} as T;
|
||||
}
|
||||
|
||||
private static convertWaypoints<T, C>(
|
||||
waypoints: Waypoint[] | WaypointDto[],
|
||||
): T[] {
|
||||
const retval: T[] = [];
|
||||
waypoints.forEach((waypoint) =>
|
||||
retval.push(AirportController.convertWaypoint<T, C>(waypoint)),
|
||||
);
|
||||
return retval;
|
||||
}
|
||||
|
||||
private static convertArrivalRoutes<T, C, W, WC>(
|
||||
routes: ArrivalRoute[] | ArrivalRouteDto[],
|
||||
): T[] {
|
||||
@@ -91,7 +66,7 @@ export class AirportController {
|
||||
retval.push({
|
||||
arrival: route.runway,
|
||||
runway: route.runway,
|
||||
waypoints: AirportController.convertWaypoints<W, WC>(route.waypoints),
|
||||
waypoints: WaypointConverter.convertList<W, WC>(route.waypoints),
|
||||
constraints: AirportController.convertConstraints<C>(route.constraints),
|
||||
} as T),
|
||||
);
|
||||
@@ -146,7 +121,7 @@ export class AirportController {
|
||||
|
||||
return {
|
||||
icao: airport.icao,
|
||||
location: AirportController.convertWaypoint<WaypointDto, CoordinateDto>(
|
||||
location: WaypointConverter.convert<WaypointDto, CoordinateDto>(
|
||||
airport.location,
|
||||
),
|
||||
elevation: airport.elevation,
|
||||
@@ -173,7 +148,7 @@ export class AirportController {
|
||||
|
||||
return {
|
||||
icao: airport.icao,
|
||||
location: AirportController.convertWaypoint<Waypoint, Coordinate>(
|
||||
location: WaypointConverter.convert<Waypoint, Coordinate>(
|
||||
airport.location,
|
||||
),
|
||||
elevation: airport.elevation,
|
||||
|
||||
Reference in New Issue
Block a user