Move the bikeshare layer onto the renderer's draw and camera ports

Station dots and the selected-station highlight are now two point draw
sets, picked through the draw hit, and the layer follows the camera
through the camera port at its own threshold instead of the shared
percentageChanged ledger. Altitude and view centre come from the camera
pose and view rectangle. All five bikeshare files leave the Cesium
allow-list.

The Cesium draw port now keeps a rebuilt host in its place in the scene
instead of re-adding it on top, tags hosts with their set id so sprite
order can raise a draw set (registerSpriteSet), and restyles unclamped
points in place when they have not moved, so a status poll or selection
no longer rebuilds every station. Other draw-port layers (cyclone
markers, earthquake discs) now also keep their first-build slot rather
than jumping above the sprite layers on each rebuild.
This commit is contained in:
Sameh Khamis committed 2026-11-06 20:26:35 -08:00
1 parent 2b66c46a30
commit 8c6fa6258b
22 files changed
+732 -249

No files matched your search

+25 -15
View File
@@ -1,6 +1,7 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import * as Cesium from 'cesium';
import { fromDegrees } from '../geo/ellipsoid.js';
import { bindFakeDraw } from '../testSupport/fakeDrawPort.mjs';
import {
BIKESHARE_SELECTED_OVERLAY_SOURCE_OPTIONS,
_clearBikeshareSelectionForTest,
@@ -19,17 +20,17 @@ function makeRecord() {
isInstalled: true,
isRenting: false,
isReturning: true,
point: {
position: Cesium.Cartesian3.fromDegrees(-97.7431, 30.2672, 2),
show: true,
},
key: 'austin-capmetro:3790',
position: fromDegrees(-97.7431, 30.2672, 2),
pixelSize: 8,
color: [0, 1, 0, 1],
};
}
test('selected bikeshare entry preserves source copy and protected-lane policy', () => {
const record = makeRecord();
const entry = createBikeshareSelectedOverlayEntry('austin-capmetro:3790', record);
assert.equal(entry.position, record.point.position);
assert.equal(entry.position, record.position);
assert.equal(entry.title, 'Congress & 6th');
assert.deepEqual(entry.details, [
'🚲 7 avail · 4 docks · 11 cap',
@@ -44,7 +45,7 @@ test('selected bikeshare entry preserves source copy and protected-lane policy',
assert.equal(entry.horizonCull, true);
});
test('real station select/clear path publishes one card and creates no native label graphic', () => {
test('real station select/clear path publishes one card and draws no native label', () => {
const calls = [];
const overlayHost = {
setEntries: (...args) => calls.push(['entries', ...args]),
@@ -53,27 +54,36 @@ test('real station select/clear path publishes one card and creates no native la
};
const key = 'austin-capmetro:3790';
const record = makeRecord();
const viewer = { entities: new Cesium.EntityCollection() };
const viewer = {};
const { draw, unbind } = bindFakeDraw(viewer);
_setBikeshareSelectionStateForTest({ viewer, key, record, overlayHost });
const live = (suffix) =>
[...draw.sets.values()].find((set) => !set.disposed && set.spec.id.endsWith(suffix));
const stations = live(':stations');
const selected = live(':selected');
try {
_selectBikeshareStationForTest(key);
assert.equal(record.point.show, false);
assert.equal(viewer.entities.values.length, 1, 'runtime guard requires a real selected entity');
assert.equal(viewer.entities.values[0].label, undefined);
assert.ok(viewer.entities.values[0].point, 'selected point highlight remains native');
assert.equal(stations.items.get(key).show, false, 'the station’s own dot is hidden');
assert.equal(selected.items.size, 1, 'one highlight dot replaces it');
const [highlight] = selected.items.values();
assert.equal(highlight.pos, record.position);
assert.deepEqual(highlight.color, [0, 1, 1, 1], 'cyan');
assert.equal(highlight.pixelSize, 14);
assert.equal(highlight.disableDepthTest, Infinity);
const publication = calls.find(([type]) => type === 'entries');
assert.ok(publication);
assert.equal(publication[1], 'bikeshare-selected');
assert.equal(publication[2].length, 1);
assert.equal(publication[2][0].position, record.point.position);
assert.equal(publication[2][0].position, record.position);
assert.deepEqual(publication[3], BIKESHARE_SELECTED_OVERLAY_SOURCE_OPTIONS);
_clearBikeshareSelectionForTest();
assert.equal(record.point.show, true);
assert.equal(viewer.entities.values.length, 0);
assert.equal(stations.items.get(key).show, true);
assert.equal(selected.items.size, 0);
assert.deepEqual(calls.at(-1), ['clear', 'bikeshare-selected']);
} finally {
_clearBikeshareSelectionForTest();
unbind();
}
});