Take the camera viewshed colours and volume builder off Cesium

The viewshed palette is renderer colours from a new hslColor in
render/color, which computes as the renderer's own fromHsl does (the CSS
HSL reading now goes through it). The volume primitive builder moves,
unchanged, into the camera layer's rendering part, which converts each
record's palette to Cesium colours once and draws the lines and volumes
with them as before. Tests check the palette against the renderer's
colours exactly.

cctvViewshed leaves the allow-list.
This commit is contained in:
Sameh Khamis committed 2026-11-06 23:47:17 -08:00
1 parent 0f496b9ae8
commit 2443028d0f
6 files changed
+130 -73

No files matched your search

+18 -6
View File
@@ -62,14 +62,26 @@ test('cameraHue: consecutive indices separated by >= 80 degrees', () => {
test('viewshedColors: fill/line pairs with the designed alphas', () => {
const colors = viewshedColors(210);
for (const key of ['fill', 'fillActive', 'line', 'lineActive']) {
assert.ok(colors[key] instanceof Cesium.Color, `${key} must be a Cesium.Color`);
assert.ok(Array.isArray(colors[key]) && colors[key].length === 4, `${key} must be a renderer colour`);
}
assert.ok(Math.abs(colors.fill.alpha - 0.12) < 1e-6);
assert.ok(Math.abs(colors.fillActive.alpha - 0.22) < 1e-6);
assert.ok(Math.abs(colors.line.alpha - 0.85) < 1e-6);
assert.ok(Math.abs(colors.lineActive.alpha - 1.0) < 1e-6);
assert.ok(Math.abs(colors.fill[3] - 0.12) < 1e-6);
assert.ok(Math.abs(colors.fillActive[3] - 0.22) < 1e-6);
assert.ok(Math.abs(colors.line[3] - 0.85) < 1e-6);
assert.ok(Math.abs(colors.lineActive[3] - 1.0) < 1e-6);
// Same hue family: fill and line of the same hue must not be gray.
assert.ok(colors.line.red !== colors.line.green || colors.line.green !== colors.line.blue);
assert.ok(colors.line[0] !== colors.line[1] || colors.line[1] !== colors.line[2]);
});
test('viewshedColors: the same colours the renderer derived from the hue', () => {
const asArray = (c) => [c.red, c.green, c.blue, c.alpha];
for (const hueDeg of [0, 137.5, 210, 359.9, -30]) {
const hue = (((hueDeg % 360) + 360) % 360) / 360;
const colors = viewshedColors(hueDeg);
assert.deepEqual(colors.fill, asArray(Cesium.Color.fromHsl(hue, 0.85, 0.6, 0.12)));
assert.deepEqual(colors.fillActive, asArray(Cesium.Color.fromHsl(hue, 0.85, 0.6, 0.22)));
assert.deepEqual(colors.line, asArray(Cesium.Color.fromHsl(hue, 0.9, 0.65, 0.85)));
assert.deepEqual(colors.lineActive, asArray(Cesium.Color.fromHsl(hue, 0.9, 0.7, 1.0)));
}
});
/** Minimal frustumCartesians-shaped fixture. */