fix(flights): an aircraft with no track or true heading faces the way it moved, not north

Some feed rows carry neither a ground track nor a true heading for an
aircraft on the ground. Its course then fell back to 0, and an aircraft
taxiing south was drawn facing north, moving backwards or sideways. With
neither reported, the course is now read from its last fix to this one when
they are at least 30 m apart; nearer fixes are position noise and keep the
last course.
This commit is contained in:
Sameh Khamis committed 2026-11-15 11:11:35 -08:00
1 parent 967477ee0f
commit 537a5d6e0f
4 files changed
+98 -2

No files matched your search

+57 -1
View File
@@ -3,7 +3,7 @@ import assert from 'node:assert/strict';
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { FlightRecords } from './records.js';
import { FlightRecords, courseFromFixes } from './records.js';
const FLEET = path.resolve(
path.dirname(fileURLToPath(import.meta.url)),
@@ -319,3 +319,59 @@ test('a ground vehicle or station with no altitude stands on the ground; an airc
).meta;
assert.equal(unloaded.onGround, false);
});
test('a contact reported with no course faces the way it moved since its last fix', () => {
const store = records();
// Taxiing south along a runway with no track or true heading reported.
store.receive(
observation({
latitude: 30.1908,
longitude: -97.6588,
courseDeg: null,
onGround: true,
speedMps: 8,
}),
view(),
);
assert.equal(store.data.get('abc123').true_track, 0, 'nothing known yet');
store.receive(
observation({
latitude: 30.1885,
longitude: -97.6588,
courseDeg: null,
onGround: true,
speedMps: 8,
}),
view(),
);
assert.ok(Math.abs(store.data.get('abc123').true_track - 180) < 0.1);
// Standing still (a metre of position noise): the last course is kept.
store.receive(
observation({
latitude: 30.18849,
longitude: -97.6588,
courseDeg: null,
onGround: true,
speedMps: 0,
}),
view(),
);
assert.ok(Math.abs(store.data.get('abc123').true_track - 180) < 0.1);
// A reported course always wins.
store.receive(
observation({
latitude: 30.188,
longitude: -97.6588,
courseDeg: 175,
onGround: true,
}),
view(),
);
assert.equal(store.data.get('abc123').true_track, 175);
});
test('course from fixes ignores position noise and reads east as 90', () => {
assert.equal(courseFromFixes(30, -97, 30.0001, -97), null, 'about 11 m');
assert.ok(Math.abs(courseFromFixes(0, 0, 0, 0.01) - 90) < 1e-6);
assert.equal(courseFromFixes(null, 0, 0, 0.01), null);
});