Name the real gate altitude and repaint coverage rows at once

The Transit prompt said "Fly below 3,000 km", but the closed gate opens at
2,850 km; it now names the enter threshold, as Bike Share does. When the
camera changes coverage, Transit and Bike Share ask the Layers panel to
repaint instead of leaving the old prompt up until the next 15 s / 60 s tick.
This commit is contained in:
German Khokhlov committed 2026-11-05 21:21:03 +04:00
1 parent 25c33893f6
commit 90db4eb2c9
13 files changed
+233 -7

No files matched your search

+66
View File
@@ -0,0 +1,66 @@
// The Transit coverage prompt names the altitude the closed gate
// actually opens at. Descending over Boston to 2,900 km (below 3,000 km, above
// the 2,850 km enter threshold) loads nothing, so a prompt "Fly below 3,000 km"
// asks for something the camera has already done.
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { createState } from './state.js';
import { createViewport } from './viewport.js';
import { createQueries } from './queries.js';
import { ACTIVATION_ENTER_ALTITUDE_M } from './policy.js';
const BOSTON = { lat: 42.3601, lon: -71.0589 };
function makeLayer() {
const services = {
overlays: {
setOverlayEntries() {},
setOverlaySourceVisible() {},
clearOverlaySource() {},
},
render: { governorRequestRender() {} },
};
const state = createState({ services });
const polled = [];
const parts = {
ingestion: {
feedStatus: () => ({ count: 0 }),
pollFeed: (feed) => polled.push(feed.id),
removeFeedVehicles() {},
sweepAgedVehicles() {},
},
rendering: { requestVisibility() {}, syncRenderHold() {} },
};
parts.viewport = createViewport({ state, services, parts });
const queries = createQueries({ state, parts }).methods;
state._enabled = true;
const rad = Math.PI / 180;
state._viewer = {
camera: {
positionCartographic: {
height: 0,
latitude: BOSTON.lat * rad,
longitude: BOSTON.lon * rad,
},
computeViewRectangle: () => undefined,
},
scene: { globe: {} },
};
return { state, queries, viewport: parts.viewport, polled };
}
test('below the prompted altitude but above the gate, the prompt names the gate', () => {
const { state, queries, viewport, polled } = makeLayer();
state._viewer.camera.positionCartographic.height = 2_900_000;
viewport.runProximityCheck();
// Nothing loads at 2,900 km: the gate opens at the enter threshold.
assert.equal(state._altitudeGateOpen, false);
assert.deepEqual(polled, []);
const km = Math.round(ACTIVATION_ENTER_ALTITUDE_M / 1000).toLocaleString(
'en-US',
);
const { statusMessage } = queries.getStats();
assert.equal(statusMessage, `Fly below ${km} km to a covered region`);
});
+1 -1
View File
@@ -4018,6 +4018,6 @@ test('a view with no feed reads its coverage prompt, not an undated feed', async
app.advance(1_000);
assert.equal(
app.layer.getStats().statusMessage,
'Fly below 3,000 km to a covered region',
'Fly below 2,850 km to a covered region',
);
});
+2 -2
View File
@@ -1,5 +1,5 @@
import {
ACTIVATION_ALTITUDE_M,
ACTIVATION_ENTER_ALTITUDE_M,
FEED_STALE_AFTER_MS,
aggregateTransitFeedHealth,
transitDetectionClass,
@@ -245,7 +245,7 @@ export function createQueries({ state, parts }) {
// (ui/statusText.js).
const note = state._altitudeGateOpen
? `No feed here yet · ${TRANSIT_ENABLED_FEEDS.length} regions available`
: `Fly below ${Math.round(ACTIVATION_ALTITUDE_M / 1000).toLocaleString('en-US')} km to a covered region`;
: `Fly below ${Math.round(ACTIVATION_ENTER_ALTITUDE_M / 1000).toLocaleString('en-US')} km to a covered region`;
return {
count: 0,
lastUpdate: state._lastUpdate,
+7
View File
@@ -83,7 +83,9 @@ export function createViewport({ state, services, parts }) {
if (!state._enabled || !state._viewer) return;
refreshViewBounds();
const altitude = getCameraAltitude();
const wasGateOpen = state._altitudeGateOpen;
state._altitudeGateOpen = altitudeGateOpen(altitude);
let changed = state._altitudeGateOpen !== wasGateOpen;
const center = state._altitudeGateOpen ? getCameraCenterLatLon() : null;
const desired = new Map();
if (center) {
@@ -106,6 +108,7 @@ export function createViewport({ state, services, parts }) {
state._activeFeeds.delete(feedId);
state._feedStatus.delete(feedId);
parts.ingestion.removeFeedVehicles(feedId);
changed = true;
}
}
// Leaving coverage leaves nothing on the map to date: a row that read
@@ -115,11 +118,15 @@ export function createViewport({ state, services, parts }) {
if (!state._activeFeeds.has(feedId)) {
state._activeFeeds.set(feedId, feed);
void parts.ingestion.pollFeed(feed, state._generation);
changed = true;
}
}
parts.ingestion.sweepAgedVehicles(Date.now());
parts.rendering.syncRenderHold();
governorRequestRender('transit-proximity');
// The row's text follows the camera (coverage prompt, feed list), so it
// repaints now instead of at the next 15 s manager tick.
if (changed) state._dataManager?.refreshLayerStats?.();
}
function onCameraChanged() {