mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-18 09:12:18 +00:00
Hand the host's live placement the ground under each aircraft
A landing is judged by its height above the ground, which the drawn height alone does not give at a high airport. Records keep the ground the warm cache already reads (the surface a grounded contact stands on, the floor under a low contact near the view or tracked) as groundM, in the render height's reference, and observeLiveAircraft passes it on; NaN where the layer does not know it.
This commit is contained in:
1 parent
4c90c065be
commit
46d8a19e98
4 files changed
+58
-8
No files matched your search
@@ -399,14 +399,20 @@ test('an aircraft fix is told to the placement live, with its drawn height', ()
|
||||
'aircraft',
|
||||
);
|
||||
const state = { timeline: { active: () => false } };
|
||||
const meta = { rawLat: 1, rawLon: 2, renderAltitudeM: 300, onGround: false };
|
||||
const meta = {
|
||||
rawLat: 1,
|
||||
rawLon: 2,
|
||||
renderAltitudeM: 300,
|
||||
groundM: 1656,
|
||||
onGround: false,
|
||||
};
|
||||
observeLiveAircraft(state, placement, 'abc123', 5000, meta, 80, 270);
|
||||
observeLiveAircraft(
|
||||
state,
|
||||
placement,
|
||||
'abc123',
|
||||
6000,
|
||||
{ ...meta, renderAltitudeInvented: true, onGround: true },
|
||||
{ ...meta, renderAltitudeInvented: true, groundM: null, onGround: true },
|
||||
null,
|
||||
undefined,
|
||||
);
|
||||
@@ -421,12 +427,15 @@ test('an aircraft fix is told to the placement live, with its drawn height', ()
|
||||
lat: 1,
|
||||
lon: 2,
|
||||
altitudeM: 300,
|
||||
groundM: 1656,
|
||||
speedMps: 80,
|
||||
courseDeg: 270,
|
||||
headingDeg: NaN,
|
||||
onGround: false,
|
||||
},
|
||||
]);
|
||||
// Where the layer does not know the ground, it says so.
|
||||
assert.ok(Number.isNaN(told[1][1].groundM));
|
||||
assert.ok(Number.isNaN(told[1][1].altitudeM));
|
||||
assert.ok(Number.isNaN(told[1][1].speedMps));
|
||||
assert.ok(Number.isNaN(told[1][1].courseDeg));
|
||||
|
||||
@@ -95,13 +95,15 @@ export function forgetPlacedAircraft(placement, ids) {
|
||||
* Tell the host-supplied placement an aircraft's fix as the layer took it
|
||||
* (nothing while the layer follows the world clock): its own time, its
|
||||
* position, the height the layer draws it at (NaN when that height is
|
||||
* invented), and its reported speed, course and ground state.
|
||||
* invented), the ground under it in that height's reference (NaN where the
|
||||
* layer does not know it), and its reported speed, course and ground state.
|
||||
* @param {object} flightState
|
||||
* @param {object|null|undefined} placement
|
||||
* @param {string} icao24
|
||||
* @param {number} fixEpochMs
|
||||
* @param {{rawLat: number, rawLon: number, renderAltitudeM: number,
|
||||
* renderAltitudeInvented?: boolean, onGround?: boolean}} meta
|
||||
* renderAltitudeInvented?: boolean, groundM?: number|null,
|
||||
* onGround?: boolean}} meta
|
||||
* @param {number|null|undefined} speedMps
|
||||
* @param {number|null|undefined} courseDeg
|
||||
*/
|
||||
@@ -121,6 +123,7 @@ export function observeLiveAircraft(
|
||||
lon: meta.rawLon,
|
||||
altitudeM:
|
||||
meta.renderAltitudeInvented === true ? NaN : meta.renderAltitudeM,
|
||||
groundM: Number.isFinite(meta.groundM) ? meta.groundM : NaN,
|
||||
speedMps: Number.isFinite(speedMps) ? speedMps : NaN,
|
||||
courseDeg: Number.isFinite(courseDeg) ? courseDeg : NaN,
|
||||
headingDeg: NaN,
|
||||
|
||||
@@ -283,6 +283,10 @@ export class FlightRecords {
|
||||
// within GROUND_FLOOR_CLAMP_RADIUS_KM of the viewer — the only ones
|
||||
// whose burial is visible. Cells warm in one batch after the loop.
|
||||
// Airborne only (grounded planes keep the surface-cache path above).
|
||||
// The ground under the contact in its render height's reference, where
|
||||
// the warm cache knows it: the surface it stands on, or the floor under a
|
||||
// low contact near the view. A landing is judged above it.
|
||||
let groundM = onGround ? surfaceM : null;
|
||||
if (
|
||||
!onGround &&
|
||||
renderAltitudeM < GROUND_FLOOR_WARM_MAX_ALT_M &&
|
||||
@@ -291,10 +295,8 @@ export class FlightRecords {
|
||||
approxDistanceKm(viewerLatDeg, viewerLonDeg, lat, lon) <=
|
||||
GROUND_FLOOR_CLAMP_RADIUS_KM))
|
||||
) {
|
||||
renderAltitudeM = floorAltitudeM(
|
||||
renderAltitudeM,
|
||||
cachedGroundFloor(lat, lon),
|
||||
);
|
||||
groundM = cachedGroundFloor(lat, lon);
|
||||
renderAltitudeM = floorAltitudeM(renderAltitudeM, groundM);
|
||||
floorWarmPoints.push({ lat, lon });
|
||||
}
|
||||
|
||||
@@ -334,6 +336,7 @@ export class FlightRecords {
|
||||
geoAltitudeM,
|
||||
renderAltitudeM,
|
||||
renderAltitudeInvented,
|
||||
groundM: Number.isFinite(groundM) ? groundM : null,
|
||||
onGround,
|
||||
// Round 7: sticky airborne history — the landed fast-cull only
|
||||
// applies to contacts that actually flew this session.
|
||||
|
||||
@@ -515,3 +515,38 @@ test('a contact reported with no course faces the way its newer fixes went', ()
|
||||
taxi(30.188, 20);
|
||||
assert.equal(course(), 0);
|
||||
});
|
||||
|
||||
test('a low contact near the view carries the ground under it; others carry none', () => {
|
||||
const store = new FlightRecords({
|
||||
geoidHeight: () => 40,
|
||||
cachedGroundFloor: () => 1656,
|
||||
floorAltitudeM: (altitude, ground) =>
|
||||
Math.max(altitude, ground ?? -Infinity),
|
||||
fleetModels: () => null,
|
||||
});
|
||||
const denver = { latitude: 39.85, longitude: -104.67 };
|
||||
const near = { ...view(), viewerLatDeg: 39.8, viewerLonDeg: -104.7 };
|
||||
// Landing at Denver: 1,900 m above the ellipsoid over 1,656 m ground.
|
||||
const landing = store.receive(
|
||||
observation({ id: 'l1', ...denver, ellipsoidAltitudeM: 1900 }),
|
||||
near,
|
||||
).meta;
|
||||
assert.equal(landing.groundM, 1656);
|
||||
// At cruise the ground is not read.
|
||||
const cruise = store.receive(
|
||||
observation({
|
||||
id: 'c1',
|
||||
...denver,
|
||||
ellipsoidAltitudeM: 11000,
|
||||
baroAltitudeM: 11000,
|
||||
}),
|
||||
near,
|
||||
).meta;
|
||||
assert.equal(cruise.groundM, null);
|
||||
// Nor without a view to be near.
|
||||
const away = store.receive(
|
||||
observation({ id: 'a1', ...denver, ellipsoidAltitudeM: 1900 }),
|
||||
view(),
|
||||
).meta;
|
||||
assert.equal(away.groundM, null);
|
||||
});
|
||||
Reference in new issue
Block a user