Tracked aircraft keep moving when reports give no speed or a stale one

A fix that moves while the reported speed is 0 or stale used to leave the
aircraft frozen, then jump it kilometres at once. The step between fixes now
measures a jump, and the drawn speed bounds the recovery.
This commit is contained in:
Sameh Khamis committed 2026-11-14 01:06:21 -08:00
1 parent 22952f8f16
commit e3cfdcf44e
7 files changed
+131 -12

No files matched your search

+29 -5
View File
@@ -78,6 +78,8 @@ import {
fixSpeedMps,
fixTrackDeg,
staleCoastSeconds,
rawPositionJumped,
rawStepSpeedMps,
} from '../../data/aircraftMotionRegime.js';
/** Whether two ECEF points are the same point, component for component. */
@@ -453,12 +455,18 @@ export function createMotion({
(worldMs - flightState._drPrevWorldMs) / 1000,
);
let snapped = false;
let jumpedThisFrame = false;
if (sameTrack) {
const speed = (info && info.velocity) || 0;
// Plausible single-frame motion (m): its speed × frame Δt, half again
// for slack, plus 5 m. More is a jump (a new report put it elsewhere).
const plausible = speed * dtSec * 1.5 + 5;
if (distance(raw, flightState._drPrevRaw) > plausible) {
// A jump: a new report moved the path the raw position is on.
const jumped = rawPositionJumped(
raw,
flightState._drPrevRaw,
flightState._drPrevRawStep,
flightState._drPrevRawStepSec,
dtSec,
);
if (jumped) {
// Discontinuity — re-anchor so the DISPLAYED position stays continuous,
// then ease onto the new path no faster than a little over its speed;
// farther off than RECOVER_SNAP_M it is a break, and it jumps.
@@ -476,12 +484,22 @@ export function createMotion({
)
: flightState._drPrevDisplay;
const errorM = distance(anchor, raw);
jumpedThisFrame = true;
snapped = errorM >= RECOVER_SNAP_M;
copyInto(snapped ? vec() : sub(anchor, raw), flightState._drCorrection);
flightState._drCorrectionStartMs = nowMs;
flightState._drCorrectionMs = Math.max(
DR_CORRECTION_MS,
recoveryMs(errorM, speed),
// As fast as the path it was drawn on moves: the newest report's
// speed can be stale or 0 minutes ahead of it.
recoveryMs(
errorM,
rawStepSpeedMps(
flightState._drPrevRawStep,
flightState._drPrevRawStepSec,
speed,
),
),
);
}
} else {
@@ -523,6 +541,12 @@ export function createMotion({
);
flightState._drPrevStepSec = dtSec;
} else flightState._drPrevStepSec = 0;
// The raw step, to judge the next frame by; none after a jump (its
// step is the jump) or a track switch.
if (sameTrack && !jumpedThisFrame) {
copyInto(sub(raw, flightState._drPrevRaw), flightState._drPrevRawStep);
flightState._drPrevRawStepSec = dtSec;
} else flightState._drPrevRawStepSec = 0;
copyInto(raw, flightState._drPrevRaw);
copyInto(display, flightState._drPrevDisplay);
flightState._drPrevMs = nowMs;
+3
View File
@@ -340,6 +340,9 @@ export function createFlightState({ source, services }) {
/** How the tracked icon moved over the last frame, and that frame's length (s; 0 for none). */
flightState._drPrevStep = { x: 0, y: 0, z: 0 };
flightState._drPrevStepSec = 0;
/** The raw position's last step, and that frame's length (s; 0 for none). */
flightState._drPrevRawStep = { x: 0, y: 0, z: 0 };
flightState._drPrevRawStepSec = 0;
flightState._drPrevMs = 0;
+29 -5
View File
@@ -61,6 +61,8 @@ import {
fixSpeedMps,
fixTrackDeg,
staleCoastSeconds,
rawPositionJumped,
rawStepSpeedMps,
} from '../../data/aircraftMotionRegime.js';
/** Where a military record carries its reported speed and track. */
@@ -355,12 +357,18 @@ export function createMotion({
(worldMs - flightState._drPrevWorldMs) / 1000,
);
let snapped = false;
let jumpedThisFrame = false;
if (sameTrack) {
const speed = (info && info.speedMps) || 0;
// Plausible single-frame motion (m): its speed × frame Δt, half again
// for slack, plus 5 m. More is a jump (a new report put it elsewhere).
const plausible = speed * dtSec * 1.5 + 5;
if (distance(raw, flightState._drPrevRaw) > plausible) {
// A jump: a new report moved the path the raw position is on.
const jumped = rawPositionJumped(
raw,
flightState._drPrevRaw,
flightState._drPrevRawStep,
flightState._drPrevRawStepSec,
dtSec,
);
if (jumped) {
// Discontinuity — re-anchor so the DISPLAYED position stays continuous,
// then ease onto the new path no faster than a little over its speed;
// farther off than RECOVER_SNAP_M it is a break, and it jumps.
@@ -378,12 +386,22 @@ export function createMotion({
)
: flightState._drPrevDisplay;
const errorM = distance(anchor, raw);
jumpedThisFrame = true;
snapped = errorM >= RECOVER_SNAP_M;
copyInto(snapped ? vec() : sub(anchor, raw), flightState._drCorrection);
flightState._drCorrectionStartMs = nowMs;
flightState._drCorrectionMs = Math.max(
DR_CORRECTION_MS,
recoveryMs(errorM, speed),
// As fast as the path it was drawn on moves: the newest report's
// speed can be stale or 0 minutes ahead of it.
recoveryMs(
errorM,
rawStepSpeedMps(
flightState._drPrevRawStep,
flightState._drPrevRawStepSec,
speed,
),
),
);
}
} else {
@@ -408,6 +426,12 @@ export function createMotion({
);
flightState._drPrevStepSec = dtSec;
} else flightState._drPrevStepSec = 0;
// The raw step, to judge the next frame by; none after a jump (its
// step is the jump) or a track switch.
if (sameTrack && !jumpedThisFrame) {
copyInto(sub(raw, flightState._drPrevRaw), flightState._drPrevRawStep);
flightState._drPrevRawStepSec = dtSec;
} else flightState._drPrevRawStepSec = 0;
copyInto(raw, flightState._drPrevRaw);
copyInto(display, flightState._drPrevDisplay);
flightState._drPrevMs = nowMs;
+3
View File
@@ -272,6 +272,9 @@ export function createFlightState({ source, services }) {
/** How the tracked icon moved over the last frame, and that frame's length (s; 0 for none). */
flightState._drPrevStep = { x: 0, y: 0, z: 0 };
flightState._drPrevStepSec = 0;
/** The raw position's last step, and that frame's length (s; 0 for none). */
flightState._drPrevRawStep = { x: 0, y: 0, z: 0 };
flightState._drPrevRawStepSec = 0;
flightState._drPrevMs = 0;