Keep a landed aircraft on the ground, not at its approach height

A grounded row with no altitude fell back to the aircraft's sticky
altitude, which straight after a landing is still the approach height.
Military contacts then hung there for as long as they stayed on the
ground (the grounded floor only ever raises a height); civil contacts
held it until the ground cell under them warmed, which for a contact far
from the viewer is never. The 3D model is ground-snapped on its own, so
the plane dropped when the model took over.

A grounded contact with no altitude now uses only an altitude it gave
on the ground, else the ground fallback. Labels, the tracked readout
and the follow distance read "On the ground" / no flight level instead
of the approach altitude.
This commit is contained in:
Sameh Khamis committed 2026-11-19 20:22:33 -08:00
1 parent 20620e89bf
commit 9b10489454
8 files changed
+145 -26

No files matched your search

+3 -1
View File
@@ -546,7 +546,9 @@ export function createQueries({
object._labelCallsign = callsign;
object._labelRegistration = registration;
}
const altitude = info?.altitude;
// A grounded contact shows no flight level: its sticky `altitude` may
// still be the approach height.
const altitude = info?.onGround ? 0 : info?.altitude;
if (object._altitude !== altitude) {
object._altitude = altitude;
object.metric = formatFlightLevel(altitude); // altitude is metres
+14 -3
View File
@@ -232,7 +232,13 @@ export class FlightRecords {
surfaceM = geoidSurfaceLastResortM({
geoAltM: geo_alt,
baroAltM: baro_alt,
priorRenderM: prevMeta?.renderAltitudeM,
// Only a height held ON THE GROUND counts as prior: straight after a
// landing the previous render height is the approach height, and
// holding it left the plane hanging there until a cell warmed —
// forever for a contact far from the viewer, whose cell is never
// queued (HAL-1032).
priorRenderM:
prevMeta?.onGround === true ? prevMeta.renderAltitudeM : null,
geoidN,
});
}
@@ -266,10 +272,15 @@ export class FlightRecords {
let renderAltitudeM;
if (pickedAltM != null) {
renderAltitudeM = pickedAltM;
} else if (Number.isFinite(prevMeta?.renderAltitudeM)) {
} else if (
Number.isFinite(prevMeta?.renderAltitudeM) &&
(!onGround || prevMeta.onGround === true)
) {
renderAltitudeM = prevMeta.renderAltitudeM;
} else {
renderAltitudeM = alt;
// A grounded contact with nothing better sits at 0 m: `alt` is sticky,
// so after a landing it still holds the approach altitude.
renderAltitudeM = onGround ? 0 : alt;
}
// Field-test fix (WAKE01/RS46 class, 2026-07-06; widened round 3):
// floor a low airborne contact's render height at the local coarse
+40 -4
View File
@@ -112,16 +112,52 @@ test('civil record owners isolate state and preserve partial, missing-poll and l
);
});
test('ground transitions preserve last render height while a surface cell is cold', () => {
test('a landing with a cold surface cell sits on the geoid, not at its approach height', () => {
const store = records();
store.geoidReady = true;
store.receive(observation({ ellipsoidAltitudeM: 1040 }), view());
// Every grounded poll, not just the first: a contact far from the viewer
// never has its cell warmed (HAL-1032).
for (let poll = 0; poll < 3; poll += 1) {
const next = store.receive(
observation({
onGround: true,
baroAltitudeM: null,
positionTimeMs: 1700000010000 + poll * 10000,
}),
view(),
);
assert.equal(next.groundFlipped, poll === 0);
assert.equal(next.meta.renderAltitudeM, 40);
assert.equal(next.meta.wasAirborne, true);
}
});
test('a landing before the geoid loads sits at 0 m, not at its approach height', () => {
const store = records();
store.receive(observation({ baroAltitudeM: 1539 }), view());
const next = store.receive(
observation({ onGround: true, baroAltitudeM: null }),
view(),
);
assert.equal(next.groundFlipped, true);
assert.equal(next.meta.renderAltitudeM, 1040);
assert.equal(next.meta.wasAirborne, true);
assert.equal(next.meta.renderAltitudeM, 0);
});
test('a parked contact whose surface cell goes cold holds its ground height', () => {
let floor = 312;
const store = new FlightRecords({
geoidHeight: () => 40,
cachedGroundFloor: () => floor,
floorAltitudeM: (altitude) => altitude,
approxDistanceKm: () => 0,
fleetModels: () => null,
});
store.geoidReady = true;
const grounded = () =>
store.receive(observation({ onGround: true, baroAltitudeM: null }), view());
assert.equal(grounded().meta.renderAltitudeM, 312);
floor = null;
assert.equal(grounded().meta.renderAltitudeM, 312);
});
test('complete snapshots age out vanished aircraft and retain position-less ones unless landed', () => {
+9 -3
View File
@@ -900,13 +900,19 @@ export function createTracking({
// the ICAO hex, so a callsign-less enriched contact heads its readout with
// the tail number rather than raw hex.
const cs = parts.queries._contactLabel(icao24, info);
const altFt = Math.round((info.altitude || 0) * 3.28084);
const altFt = info.onGround
? null
: Math.round((info.altitude || 0) * 3.28084);
// Flight levels are an aviation code; feet and knots read in the active
// language ("0 фт · 1 уз").
const quantity = (value, unit) =>
`${formatNumber(value, { useGrouping: false })} ${unitLabel(unit)}`;
const fl =
altFt >= 18000 ? `FL${Math.round(altFt / 100)}` : quantity(altFt, 'ft');
altFt == null
? t('On the ground')
: altFt >= 18000
? `FL${Math.round(altFt / 100)}`
: quantity(altFt, 'ft');
const spd = info.velocity
? quantity(Math.round(info.velocity * 1.944), 'kts')
: '';
@@ -1164,7 +1170,7 @@ export function createTracking({
// viewFrom — behind + above, distance scaled to altitude — for a readable
// initial frame with surrounding context. (ENU: east=+X, north=+Y, up=+Z.)
const followRange = Math.min(
Math.max((info.altitude || 1500) * 1.1 + 2500, 3000),
Math.max((info.onGround ? 0 : info.altitude || 1500) * 1.1 + 2500, 3000),
30000,
);
const viewFrom = vec(0, -followRange * 0.8, followRange * 0.55);