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

1299
server/src/adsb-shapes.mjs Normal file

File diff suppressed because it is too large Load Diff

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) {

View File

@@ -9,7 +9,7 @@ import {apiReference} from '@scalar/express-api-reference';
import {spec} from './spec.mjs';
import {existsSync} from 'fs';
import {getAIS} from './ais.mjs';
import {getADSB, getADSBHistory, getADSBRange, getShapes, initAircraftDb} from './adsb.mjs';
import {getADSB, getADSBHistory, getADSBRange, initAircraftDb} from './adsb.mjs';
import {getWeatherCondition} from './openweather.mjs';
import {lastForecast, getForecast, forecastTTL} from './forecast.mjs';
import {dailyWeather, hourlyWeather} from './openmeteo.mjs';
@@ -159,7 +159,6 @@ app.get('/api/adsb', async (req, res) => res.json(await getADSB()));
app.get('/api/adsb/:icao', async (req, res) => res.json(await getADSBHistory(req.params.icao)));
app.get('/api/ais', async (req, res) => res.json(await getAIS()));
app.get('/api/range', async (req, res) => res.json(await getADSBRange()));
app.get('/api/vehicles', async (req, res) => res.json(await getShapes()));
// ── DOCS ──────────────────────────────────────────────────────────────────────