Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
daniluk4000 committed Jan 9, 2025
1 parent fcc3ea1 commit 3f42baa
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"dependencies": {
"@influxdata/influxdb-client": "^1.35.0",
"@influxdata/influxdb-client-apis": "^1.35.0",
"@navigraph/amdb": "^1.1.0",
"@pinia/nuxt": "^0.9.0",
"@prisma/client": "^6.2.1",
"@turf/difference": "^7.2.0",
Expand Down Expand Up @@ -67,6 +66,7 @@
"ws": "^8.18.0"
},
"devDependencies": {
"@navigraph/amdb": "^1.1.0",
"@nuxt/devtools": "^1.7.0",
"@nuxt/eslint": "^0.7.4",
"@nuxtjs/stylelint-module": "^5.2.0",
Expand Down
44 changes: 22 additions & 22 deletions src/server/api/data/navigraph/airport/[...icao]/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type { AmdbLayerName, AmdbResponseStructure } from '@navigraph/amdb';
import type { PartialRecord } from '~/types';
import { multiLineString } from '@turf/helpers';
import type { Point } from 'geojson';
import nearestPointOnLine from '@turf/nearest-point-on-line'
import nearestPointOnLine from '@turf/nearest-point-on-line';
import { fromServerLonLat } from '~/utils/backend/vatsim';

const allowedProperties: PartialRecord<AmdbLayerName, string[]> = {
Expand Down Expand Up @@ -70,55 +70,55 @@ export default defineEventHandler(async (event): Promise<NavigraphAirportData |
}

else {
gates = layout.parkingstandarea.features.flatMap((area) => {
const { centroid } = (area.properties as unknown as { centroid: Point })
gates = layout.parkingstandarea.features.flatMap(area => {
const { centroid } = (area.properties as unknown as { centroid: Point });

const subGates = area.properties.idstd?.split('_')
const subGates = area.properties.idstd?.split('_');

if(!subGates) {
if (!subGates) {
// TODO: Handle parkingstandareas with a null idstd

return []
return [];
}

// Generate stands for subgates which have associated standguidancelines
const guidanceLineGates = subGates.flatMap((ident) => {
const applicableStandLines = layout.standguidanceline!.features.filter((line) => line.properties.termref === area.properties.termref && line.properties.idstd?.split('_').includes(ident))
const guidanceLineGates = subGates.flatMap(ident => {
const applicableStandLines = layout.standguidanceline!.features.filter(line => line.properties.termref === area.properties.termref && line.properties.idstd?.split('_').includes(ident));

if(applicableStandLines.length === 0) {
return []
if (applicableStandLines.length === 0) {
return [];
}

const geometry = multiLineString(applicableStandLines.map((line) => line.geometry.coordinates))
const geometry = multiLineString(applicableStandLines.map(line => line.geometry.coordinates));

const nearestPoint = nearestPointOnLine(geometry, centroid)
const nearestPoint = nearestPointOnLine(geometry, centroid);

const coords = fromServerLonLat(nearestPoint.geometry.coordinates)
const coords = fromServerLonLat(nearestPoint.geometry.coordinates);

return [{
gate_identifier: `${ ident }:${ area.properties.termref }`,
gate_longitude: coords[0],
gate_latitude: coords[1],
name: ident,
airport_identifier: area.properties.idarpt,
}]
})
}];
});

const remainingGates = subGates.filter((ident) => !guidanceLineGates.find((item) => item.name === ident))
const remainingGates = subGates.filter(ident => !guidanceLineGates.find(item => item.name === ident));

const coords = fromServerLonLat(centroid.coordinates)
const coords = fromServerLonLat(centroid.coordinates);

// For all subGates which have no associated standguidancelines, place a gate at the centroid of the parkingstandarea
const centroidGates = remainingGates.map((ident) => ({
const centroidGates = remainingGates.map(ident => ({
gate_identifier: `${ ident }:${ area.properties.termref }`,
gate_longitude: coords[0],
gate_latitude: coords[1],
name: ident,
airport_identifier: area.properties.idarpt,
}))
}));

return [...guidanceLineGates, ...centroidGates]
})
return [...guidanceLineGates, ...centroidGates];
});

const _layout = layout as NavigraphLayout;

Expand Down

0 comments on commit 3f42baa

Please sign in to comment.