fix(flights): panels show the reported ground speed while a placement waits

A host-supplied placement's speed is how fast the marker is drawn. While it
waits for its fixes to catch up it stands still at 0, so tracked-aircraft
panels and the cockpit readout showed 0 m/s for an aircraft in flight.

displayedKinematics now takes derivedFromPlacement: when the drawn speed is a
placement's, the reported ground speed is shown, and the placement's only when
nothing is reported. The placement speed still drives motion and dead
reckoning. Civil and military tracked descriptors pass it from the new
_drSpeedPlaced scratch, which placeLiveAircraft sets.
This commit is contained in:
Sameh Khamis committed 2026-11-17 16:31:03 -08:00
1 parent 953af60e1d
commit d79494ac89
8 files changed
+98 -6

No files matched your search

+13 -5
View File
@@ -127,19 +127,27 @@ export function courseSlewCapDps(speedMps, maxDps, minDps = COURSE_MIN_DPS) {
* fixes still describe clear movement. The delayed renderer already derives a
* matching segment speed and course from those fixes, so tracking and cockpit
* consumers should prefer that pair over stale poll fields.
*
* A host-supplied placement's speed (`derivedFromPlacement`) is how fast the
* marker is drawn, not how fast the aircraft goes: a placement waiting for its
* fixes to catch up stands still at 0. The reported ground speed is shown
* then, and the placement's only when nothing is reported.
*/
export function displayedKinematics({
derivedSpeedMps,
derivedTrackDeg,
reportedSpeedMps,
reportedTrackDeg,
derivedFromPlacement = false,
} = {}) {
const reported = Number.isFinite(reportedSpeedMps);
return {
speedMps: Number.isFinite(derivedSpeedMps)
? Math.max(0, derivedSpeedMps)
: Number.isFinite(reportedSpeedMps)
? Math.max(0, reportedSpeedMps)
: null,
speedMps:
Number.isFinite(derivedSpeedMps) && !(derivedFromPlacement && reported)
? Math.max(0, derivedSpeedMps)
: reported
? Math.max(0, reportedSpeedMps)
: null,
trackDeg: Number.isFinite(derivedTrackDeg)
? derivedTrackDeg
: Number.isFinite(reportedTrackDeg)
+7
View File
@@ -43,6 +43,13 @@ test('displayedKinematics preserves a derived stop and falls back when unavailab
}), { speedMps: 80, trackDeg: 180 });
});
test('displayedKinematics shows the reported speed over a placement standing still', () => {
const placed = { derivedSpeedMps: 0, derivedTrackDeg: 90, derivedFromPlacement: true };
assert.deepEqual(displayedKinematics({ ...placed, reportedSpeedMps: 230, reportedTrackDeg: 88 }),
{ speedMps: 230, trackDeg: 90 });
assert.deepEqual(displayedKinematics(placed), { speedMps: 0, trackDeg: 90 });
});
test('stale coasting follows last source contact without allowing indefinite drift', () => {
const fix = 1_000_000;
assert.equal(staleCoastLimitSeconds({ fixEpochMs: fix }), 60);