diff --git a/src/data/aircraftIconLayer.js b/src/data/aircraftIconLayer.js index b7c92809d..b098d783f 100644 --- a/src/data/aircraftIconLayer.js +++ b/src/data/aircraftIconLayer.js @@ -7,6 +7,7 @@ import { import { createIconSet, ICON_CULL_LIFT, + ICON_CULL_LIFT_BELOW_M, ICON_RECEDES, ICON_ROTATES, } from './iconSet.js'; @@ -42,9 +43,6 @@ const COCKPIT_SCALE_BY_DISTANCE = new Cesium.NearFarScalar( 8000000, 0.65, ); -/** Contacts drawn below this height (m) are judged for the horizon a little - * above the ellipsoid (ICON_CULL_LIFT). */ -const CULL_LIFT_BELOW_M = 10; /** * An aircraft layer's contacts as one icon set: each row's motion segment @@ -333,7 +331,7 @@ export function createAircraftIcons({ row, ICON_CULL_LIFT, Number.isFinite(info?.renderAltitudeM) && - info.renderAltitudeM < CULL_LIFT_BELOW_M, + info.renderAltitudeM < ICON_CULL_LIFT_BELOW_M, ); set.setAlpha(row, state.records.missingPolls.get(icao24) ? 0.45 : 1); } diff --git a/src/data/iconSet.js b/src/data/iconSet.js index 811014610..e77865689 100644 --- a/src/data/iconSet.js +++ b/src/data/iconSet.js @@ -65,6 +65,22 @@ export const ICON_RECEDES = 4; export const ICON_CULL_LIFT = 8; /** The ellipsoid height a CULL_LIFT row is raised to for the horizon test. */ export const ICON_CULL_HEIGHT_M = HORIZON_LIFT_M; +/** + * Contacts whose fix is below this height (m) get CULL_LIFT in the aircraft + * layers' icon sets; theirs are the only rows flagged by height. + * + * Through the draw port a `horizonCull` set flags every row, so every row + * drawn below ICON_CULL_HEIGHT_M is lifted. The two agree on every row this + * rule flags (lifted either way) and every row drawn at or above + * ICON_CULL_HEIGHT_M (no lift either way). They differ only on rows this + * rule leaves unflagged (fix at or above 10 m) while drawn below 12 m: a + * contact between 10 and 12 m (judged up to 2 m higher), or one whose drawn + * position sits lower than its fix (a climb-out from a lower earlier fix, a + * dead-reckoned ground drift). The port judges those higher, so it never + * hides what this rule shows, and shows near-ground contacts at the limb that + * this rule culled, which is what the lift is for. + */ +export const ICON_CULL_LIFT_BELOW_M = 10; /** Move the epoch once render times are this many seconds from it. */ const REBASE_AFTER_SEC = 1800; diff --git a/src/data/iconSet.test.mjs b/src/data/iconSet.test.mjs index 4a8e1859e..c4c8c9141 100644 --- a/src/data/iconSet.test.mjs +++ b/src/data/iconSet.test.mjs @@ -9,6 +9,7 @@ import { ICON_CULL_LIFT, ICON_ROTATES, ICON_SHOWN, + ICON_CULL_LIFT_BELOW_M, } from './iconSet.js'; import { writeArcSegment, @@ -334,3 +335,40 @@ test('removing a row moves its switch, proxy and depth-test columns too', () => assert.equal(set.pickProxyHeight(moved), 33); assert.equal(set.depthTestDistance(moved), 0); }); + +test('a horizon-culled draw set lifts what the aircraft layers lift, and lifts the rest no lower', () => { + const set = createIconSet(); + const row = set.add('a'); + set.setFlag(row, ICON_CULL_LIFT, true); + const heightOf = (p) => Cesium.Cartographic.fromCartesian(p).height; + // The aircraft layers' rule, by fix height h for a row drawn at d. + const aircraft = (h, d) => + h < ICON_CULL_LIFT_BELOW_M ? Math.max(d, ICON_CULL_HEIGHT_M) : d; + for (const [h, d] of [ + [-31, -31], + [5, 5], + [9.99, 9.99], + [12, 12], + [400, 400], + [9, 15], + [20, 20], + ]) { + const at = Cesium.Cartesian3.fromDegrees(-97.04, 32.9, d); + const judged = heightOf(set.cullPoint(row, at)); + assert.ok( + Math.abs(judged - aircraft(h, d)) < 1e-3, + `${h}/${d} m: ${judged}`, + ); + } + // Unflagged by the aircraft rule, drawn below 12 m: judged higher, never lower. + for (const [h, d] of [ + [10, 10], + [11, 11], + [20, 5], + ]) { + const at = Cesium.Cartesian3.fromDegrees(4.1, 51.95, d); + const judged = heightOf(set.cullPoint(row, at)); + assert.ok(Math.abs(judged - ICON_CULL_HEIGHT_M) < 1e-3, `${h}/${d} m`); + assert.ok(judged > aircraft(h, d), 'judged higher'); + } +});