From 693faae44ea88536035809ef9ecca9a13f3ece45 Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Fri, 13 Nov 2026 11:50:05 -0800 Subject: [PATCH] fix(flights): an adsb.lol aircraft with no ground track faces its true heading, not north --- CHANGELOG.md | 3 +++ src/data/adsbLolFallback.js | 6 +++++- src/data/adsbLolFallback.test.mjs | 12 ++++++++++++ src/sources/live/aircraft.js | 3 ++- 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c7acc5b4..3fe6c88be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## [Unreleased] +- Aircraft from adsb.lol that report no ground track (parked or taxiing + slowly) now face their reported true heading instead of north, so parked + models line up with their gates (samehkhamis). - A renderer can draw weather: the `weather` capability adds `globe.weather`, with clouds, fog, haze, rain and snow (each 0 to 1) and the wind they drift on. Where the renderer lists it, the view shows the conditions observed diff --git a/src/data/adsbLolFallback.js b/src/data/adsbLolFallback.js index 61d07387f..a9d5cbbdf 100644 --- a/src/data/adsbLolFallback.js +++ b/src/data/adsbLolFallback.js @@ -64,7 +64,11 @@ export function normalizeAdsbLolAircraftState(aircraft, nowSeconds) { const geometricFeet = finiteNumber(aircraft?.alt_geom); const groundSpeedKnots = finiteNumber(aircraft?.gs); const verticalRateFpm = readAdsbVerticalRateFpm(aircraft); - const track = finiteNumber(aircraft?.track); + // A parked or slow aircraft reports no ground track, but often its true + // heading (surface messages): the way its nose points, which is what an + // aircraft standing still is drawn by. Magnetic heading is not true north. + const track = + finiteNumber(aircraft?.track) ?? finiteNumber(aircraft?.true_heading); return [ hex, diff --git a/src/data/adsbLolFallback.test.mjs b/src/data/adsbLolFallback.test.mjs index 873a8bbe2..a99d273de 100644 --- a/src/data/adsbLolFallback.test.mjs +++ b/src/data/adsbLolFallback.test.mjs @@ -49,3 +49,15 @@ test('keeps grounded fallback contacts and rejects rows without positions', () = assert.equal(normalized.states[0][7], null); assert.equal(normalized.states[0][8], true); }); + +test('an aircraft with no track takes its true heading, never its magnetic one', () => { + const at = (extra) => + normalizeAdsbLolAircraftState( + { hex: 'abc123', lat: 37.7, lon: -122.2, alt_baro: 'ground', ...extra }, + 1000, + )[10]; + assert.equal(at({ track: 56.25, true_heading: 40 }), 56.25, 'track first'); + assert.equal(at({ true_heading: 244.69 }), 244.69, 'true heading'); + assert.equal(at({ mag_heading: 278.44 }), null, 'not magnetic'); + assert.equal(at({}), null, 'none'); +}); diff --git a/src/sources/live/aircraft.js b/src/sources/live/aircraft.js index 481bb6113..85b3acdc5 100644 --- a/src/sources/live/aircraft.js +++ b/src/sources/live/aircraft.js @@ -71,7 +71,8 @@ export function normalizeReadsbAircraft(row, snapshotTimeMs) { ellipsoidAltitudeM: geoFt == null ? null : geoFt * 0.3048, onGround: cleanText(row.alt_baro).toLowerCase() === 'ground', speedMps: speedKts == null ? null : speedKts * 0.514444, - courseDeg: finite(row.track), + // No track (parked, slow): the true heading, where the nose points. + courseDeg: finite(row.track) ?? finite(row.true_heading), verticalRateMps: rateFtMin == null ? null : rateFtMin * 0.00508, category: row.category ?? null, typeCode: cleanText(row.t),