ADSB debugging
This commit is contained in:
@@ -16,7 +16,7 @@ let interval: ReturnType<typeof setInterval>;
|
|||||||
let rafId: number;
|
let rafId: number;
|
||||||
let drawProgress = 0;
|
let drawProgress = 0;
|
||||||
let lastTimestamp = 0;
|
let lastTimestamp = 0;
|
||||||
const ANIM_DURATION = 1100;
|
const ANIM_DURATION = 1000;
|
||||||
|
|
||||||
let pointBuffer: { x: number; y: number }[] = [];
|
let pointBuffer: { x: number; y: number }[] = [];
|
||||||
let prevMax = 1.0;
|
let prevMax = 1.0;
|
||||||
@@ -26,13 +26,13 @@ function buildBuffer(pts: number[]) {
|
|||||||
const mid = H / 2, amp = H / 2 - 6;
|
const mid = H / 2, amp = H / 2 - 6;
|
||||||
const newMax = Math.max(...pts, 1.0);
|
const newMax = Math.max(...pts, 1.0);
|
||||||
prevMax = prevMax + (newMax - prevMax) * 0.15;
|
prevMax = prevMax + (newMax - prevMax) * 0.15;
|
||||||
const max = prevMax;
|
|
||||||
const buf: { x: number; y: number }[] = [];
|
const buf: { x: number; y: number }[] = [];
|
||||||
|
|
||||||
pts.forEach((v, i) => {
|
pts.forEach((v, i) => {
|
||||||
const prev = pts[i - 1] ?? v;
|
const prev = pts[i - 1] ?? v;
|
||||||
const prevNorm = (prev / max) * amp;
|
const max = prevMax;
|
||||||
const norm = (v / max) * amp;
|
const prevNorm = prev === 0 ? 0 : (prev / max) * amp;
|
||||||
|
const norm = v === 0 ? 0 : (v / max) * amp;
|
||||||
const baseX = i * SEG_W;
|
const baseX = i * SEG_W;
|
||||||
const s = SEG_W / SUB;
|
const s = SEG_W / SUB;
|
||||||
|
|
||||||
|
|||||||
@@ -229,14 +229,18 @@ export async function enrichAircraft(a) {
|
|||||||
|
|
||||||
// 1. Check own DB first
|
// 1. Check own DB first
|
||||||
const row = db.prepare('SELECT * FROM aircraft WHERE icao24 = ?').get(icao);
|
const row = db.prepare('SELECT * FROM aircraft WHERE icao24 = ?').get(icao);
|
||||||
if (row?.manufacturer && row?.model) {
|
if(row?.manufacturer && row?.model) return { ...a, ...row, type: classifyAircraft(row) };
|
||||||
return { ...a, ...row, type: classifyAircraft(row) };
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2. Race the two external sources
|
// 2. Race the two external sources
|
||||||
let found = await Promise.any([
|
let found = await Promise.any([
|
||||||
fetchHexDb(icao),
|
fetchHexDb(icao).then(resp => {
|
||||||
scrapeHexDatabase(icao),
|
console.log(`source1: ${icao}`, resp);
|
||||||
|
return resp;
|
||||||
|
}),
|
||||||
|
scrapeHexDatabase(icao).then(resp => {
|
||||||
|
console.log(`source2: ${icao}`, resp);
|
||||||
|
return resp;
|
||||||
|
}),
|
||||||
]).catch(() => null);
|
]).catch(() => null);
|
||||||
|
|
||||||
// Merge with any partial DB row we already have
|
// Merge with any partial DB row we already have
|
||||||
@@ -248,6 +252,8 @@ export async function enrichAircraft(a) {
|
|||||||
Object.assign(merged, { ...similar, ...merged }); // don't overwrite fetched data
|
Object.assign(merged, { ...similar, ...merged }); // don't overwrite fetched data
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(`Backfilling: ${icao}`, merged);
|
||||||
|
|
||||||
// 4. Save back to DB
|
// 4. Save back to DB
|
||||||
if (found) {
|
if (found) {
|
||||||
db.prepare(`
|
db.prepare(`
|
||||||
|
|||||||
Reference in New Issue
Block a user