Build aircraft shapes

This commit is contained in:
2026-06-25 21:43:56 -04:00
parent f6f8a252dc
commit b87bcbabb7
5 changed files with 1322 additions and 44 deletions

View File

@@ -4,6 +4,7 @@ import { fileURLToPath } from 'url';
import * as fs from 'node:fs';
import Database from 'better-sqlite3';
import { fromCsv } from '@ztimson/utils';
import {getIcon} from './adsb-shapes.mjs';
const DIR = dirname(fileURLToPath(import.meta.url));
const DATA = resolve(DIR, '../data');
@@ -182,10 +183,6 @@ export async function enrichAircraft(a) {
return { ...a, ...row, type: classifyAircraft(row) };
}
export async function getShapes() {
return JSON.parse(await fs.promises.readFile(SHAPES_PATH, 'utf8'));
}
export async function getADSB() {
const { ADSB_URL } = cfg();
if (!ADSB_URL) return [];
@@ -203,7 +200,11 @@ export async function getADSB() {
if (trail.length > MAX_HISTORY) trail.shift();
}
return Promise.all(aircraft.map(enrichAircraft));
return Promise.all(aircraft.map(async a => {
a = await enrichAircraft(a);
a.icon = getIcon(a);
return a;
}));
}
export async function getADSBHistory(icao) {