mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-18 01:02:23 +00:00
Fix the review findings across the engines, layers, data and QA
Navara now matches Cesium where the review found it diverging: a flight holds the camera inputs, camera.changed counts turns as Cesium does, render requests made during a frame survive it, follow pinches zoom, ground widths follow the pixel ratio and Cyber sonar reaches glyph caches and models. On Cesium, a staged imagery swap keeps loading tiles, setView replaces a running flight, and a cleared weather detail goes away. The contract gains MoverSet.failed, maps.terrainRevision, render.maxTextureSize and surface.sampleTerrainMostDetailed on every engine, so layers retry failed models, key road heights by terrain, size weather textures to the GPU and place Bhote Koshi cards on detailed terrain. Engine switches keep the live view, follows, focus, layer options and cards: a pick hands over the exact pose, applies no address options and pans no carried-over card; a history visit still applies its entry. Layers put GhostMaps pins, cable landings, OSM Places and directions on the measured surface without per-frame sampling, draw the Cockpit contact dot, hide disabled CCTV on attach, and keep ALPR running outside secure contexts. KML imports draw raised polygon fills, rotated and coloured ground overlays and north-referenced icon headings, and report files with nothing to draw. QA scripts read the contract instead of Cesium internals (test:track is 109/109 again), wait for the camera to rest before clicking, and give cold switches and parked engines realistic time. Docs follow the code.
This commit is contained in:
1 parent
69fbf5b38d
commit
0ef29781e5
276 files changed
+7217
-1517
No files matched your search
@@ -4,7 +4,7 @@ import * as Cesium from 'cesium';
|
||||
import * as geo from '../geo/index.js';
|
||||
import { GROUND_HARNESSES } from '../testSupport/groundDisplayEngines.mjs';
|
||||
import { drawImportedFile } from './geoImportDisplay.js';
|
||||
import { geoJsonRecords } from './geoImportRecords.js';
|
||||
import { emptyRecords, geoJsonRecords } from './geoImportRecords.js';
|
||||
|
||||
// A 2D context that only records what draws.
|
||||
const createCanvas = () => ({
|
||||
@@ -191,6 +191,8 @@ for (const make of GROUND_HARNESSES) {
|
||||
viewer.scene.clampToHeightSupported = true;
|
||||
} else engine.imagery.surface = () => 'tiles';
|
||||
engine.camera.height = () => 1000;
|
||||
engine.projector.worldToWindow = () => ({ x: 1, y: 1 });
|
||||
engine.projector.horizonVisible = () => true;
|
||||
const excluded = [];
|
||||
engine.surface.clampToHeight = (position, exclude) => {
|
||||
excluded.push(exclude);
|
||||
@@ -270,8 +272,9 @@ for (const make of GROUND_HARNESSES) {
|
||||
visible: false,
|
||||
});
|
||||
const fill = set(engine.ground.list()[0].id);
|
||||
assert.equal(fill.items.length, 2);
|
||||
assert.equal(fill.items[0].rings.length, 2);
|
||||
assert.equal(fill.items.length, 1);
|
||||
assert.equal(engine.meshes.list().length, 1);
|
||||
assert.equal(fill.items[0].rings.length, 1);
|
||||
assert.ok(fill.items[0].rings.flat().every((p) => p.length === 2));
|
||||
assert.equal(fill.shown, false);
|
||||
assert.equal(engine.lines.list().length, 2);
|
||||
@@ -339,6 +342,222 @@ for (const make of GROUND_HARNESSES) {
|
||||
},
|
||||
);
|
||||
|
||||
displayTest(
|
||||
'KML headings follow north as the camera rotates',
|
||||
async ({ engine, pins }) => {
|
||||
let heading = 0;
|
||||
engine.camera.pose = () => ({ heading });
|
||||
const records = geoJsonRecords(
|
||||
{ type: 'Point', coordinates: [1, 2] },
|
||||
'#39d0ff',
|
||||
);
|
||||
records.points[0].icon.rotation = -Math.PI / 4;
|
||||
const drawing = await drawImportedFile(engine, records, { createCanvas });
|
||||
assert.equal(pins[0].items[0].rotation, -Math.PI / 4);
|
||||
heading = Math.PI / 2;
|
||||
engine.frames.preRender.raiseEvent();
|
||||
assert.equal(pins[0].items[0].rotation, Math.PI / 4);
|
||||
drawing.destroy();
|
||||
},
|
||||
);
|
||||
|
||||
// A canvas whose context records the transform and holds one pixel.
|
||||
const recordingCanvas = () => {
|
||||
const calls = [];
|
||||
const pixels = { data: new Uint8ClampedArray([128, 64, 32, 128]) };
|
||||
const context = {
|
||||
translate: (...args) => calls.push(['translate', ...args]),
|
||||
rotate: (angle) => calls.push(['rotate', angle]),
|
||||
drawImage: (_image, ...args) => calls.push(['drawImage', ...args]),
|
||||
getImageData: () => pixels,
|
||||
putImageData: (value) => calls.push(['putImageData', value]),
|
||||
};
|
||||
return { calls, pixels, canvas: { getContext: () => context } };
|
||||
};
|
||||
const overlayLayer = (engine) => {
|
||||
const layers = [];
|
||||
const create = engine.imagery.createLayer;
|
||||
engine.imagery.createLayer = (options) => {
|
||||
layers.push(options);
|
||||
return create(options);
|
||||
};
|
||||
return layers;
|
||||
};
|
||||
|
||||
displayTest(
|
||||
'colored overlays multiply image RGB and retain layer alpha',
|
||||
async ({ engine }) => {
|
||||
const { calls, pixels, canvas } = recordingCanvas();
|
||||
const layers = overlayLayer(engine);
|
||||
const records = emptyRecords();
|
||||
records.overlays.push({
|
||||
url: 'blob:overlay',
|
||||
color: [1, 0, 0, 0.5],
|
||||
rectangle: { west: 0, south: 0, east: 1, north: 1 },
|
||||
rotation: 0,
|
||||
});
|
||||
const drawing = await drawImportedFile(engine, records, {
|
||||
createCanvas: () => canvas,
|
||||
loadImage: async () => ({ width: 32, height: 16 }),
|
||||
});
|
||||
assert.equal(layers[0].source.image, canvas);
|
||||
assert.deepEqual(
|
||||
{ ...layers[0].source.rectangle },
|
||||
{ west: 0, south: 0, east: 1, north: 1 },
|
||||
);
|
||||
assert.equal(layers[0].alpha, 0.5);
|
||||
assert.deepEqual([canvas.width, canvas.height], [32, 16]);
|
||||
assert.ok(
|
||||
calls.some(
|
||||
([name, value]) => name === 'putImageData' && value === pixels,
|
||||
),
|
||||
);
|
||||
assert.deepEqual([...pixels.data], [128, 0, 0, 128]);
|
||||
drawing.destroy();
|
||||
},
|
||||
);
|
||||
|
||||
displayTest(
|
||||
'a rotated overlay turns its image counter-clockwise onto the box around it',
|
||||
async ({ engine }) => {
|
||||
const { calls, canvas } = recordingCanvas();
|
||||
const layers = overlayLayer(engine);
|
||||
const records = emptyRecords();
|
||||
records.overlays.push({
|
||||
url: 'blob:overlay',
|
||||
color: [1, 1, 1, 1],
|
||||
// Two degrees by one, across 180°, turned a quarter.
|
||||
rectangle: { west: 179, south: 10, east: -179, north: 11 },
|
||||
rotation: 90,
|
||||
});
|
||||
const drawing = await drawImportedFile(engine, records, {
|
||||
createCanvas: () => canvas,
|
||||
loadImage: async () => ({ width: 200, height: 100 }),
|
||||
});
|
||||
assert.equal(drawing.report.drawn, 1);
|
||||
assert.equal(drawing.report.undrawn, 0);
|
||||
const { rectangle } = layers[0].source;
|
||||
assert.ok(Math.abs(rectangle.west - 179.5) < 1e-9);
|
||||
assert.ok(Math.abs(rectangle.east + 179.5) < 1e-9);
|
||||
assert.ok(Math.abs(rectangle.south - 9.5) < 1e-9);
|
||||
assert.ok(Math.abs(rectangle.north - 11.5) < 1e-9);
|
||||
// 100 pixels a degree on both axes: the turned box is 1° by 2°.
|
||||
assert.deepEqual([canvas.width, canvas.height], [100, 200]);
|
||||
assert.deepEqual(
|
||||
calls.find(([name]) => name === 'rotate'),
|
||||
['rotate', -Math.PI / 2],
|
||||
);
|
||||
assert.deepEqual(
|
||||
calls.find(([name]) => name === 'drawImage'),
|
||||
['drawImage', -100, -50, 200, 100],
|
||||
);
|
||||
assert.equal(
|
||||
calls.some(([name]) => name === 'putImageData'),
|
||||
false,
|
||||
);
|
||||
drawing.destroy();
|
||||
},
|
||||
);
|
||||
|
||||
displayTest(
|
||||
'a rotated overlay whose box passes a pole is reported undrawn',
|
||||
async ({ engine }) => {
|
||||
const records = emptyRecords();
|
||||
records.overlays.push({
|
||||
url: 'blob:overlay',
|
||||
color: [1, 1, 1, 1],
|
||||
rectangle: { west: 0, south: 80, east: 30, north: 89 },
|
||||
rotation: 45,
|
||||
});
|
||||
const drawing = await drawImportedFile(engine, records, { createCanvas });
|
||||
assert.deepEqual(drawing.report, {
|
||||
drawn: 0,
|
||||
undrawn: 1,
|
||||
kinds: { rotatedOverlay: 1 },
|
||||
});
|
||||
assert.equal(engine.imagery.list().length, 0);
|
||||
drawing.destroy();
|
||||
},
|
||||
);
|
||||
|
||||
displayTest(
|
||||
'a rotated plain-colour overlay fills its turned corners',
|
||||
async ({ engine, set }) => {
|
||||
const records = emptyRecords();
|
||||
records.overlays.push({
|
||||
url: null,
|
||||
color: [0, 1, 0, 0.5],
|
||||
rectangle: { west: 0, south: 0, east: 2, north: 2 },
|
||||
rotation: 90,
|
||||
});
|
||||
const drawing = await drawImportedFile(engine, records, { createCanvas });
|
||||
const fill = set(engine.ground.list()[0].id);
|
||||
const [ring] = fill.items[0].rings;
|
||||
const near = (a, b) => a.every((v, i) => Math.abs(v - b[i]) < 1e-9);
|
||||
assert.ok(near(ring[0], [2, 0]), JSON.stringify(ring));
|
||||
assert.ok(near(ring[1], [2, 2]), JSON.stringify(ring));
|
||||
assert.ok(near(ring[2], [0, 2]), JSON.stringify(ring));
|
||||
drawing.destroy();
|
||||
},
|
||||
);
|
||||
|
||||
displayTest(
|
||||
'an absolute overlay is raised to its altitude, a relative one drapes',
|
||||
async ({ engine }) => {
|
||||
const layers = overlayLayer(engine);
|
||||
const records = emptyRecords();
|
||||
for (const altitudeMode of ['absolute', 'relative'])
|
||||
records.overlays.push({
|
||||
url: 'blob:overlay',
|
||||
altitudeMode,
|
||||
altitude: 1000,
|
||||
color: [1, 1, 1, 1],
|
||||
rectangle: { west: 0, south: 0, east: 1, north: 1 },
|
||||
rotation: 0,
|
||||
});
|
||||
const drawing = await drawImportedFile(engine, records, { createCanvas });
|
||||
assert.deepEqual(drawing.report, { drawn: 2, undrawn: 0, kinds: {} });
|
||||
assert.equal(layers[0].raise, 1000);
|
||||
assert.equal(layers[1].raise, undefined);
|
||||
drawing.destroy();
|
||||
},
|
||||
);
|
||||
|
||||
displayTest(
|
||||
'tile clamps only sample visible pins and yield between batches',
|
||||
async ({ engine }) => {
|
||||
engine.imagery.surface = () => 'tiles';
|
||||
engine.camera.height = () => 1000;
|
||||
engine.projector.horizonVisible = () => true;
|
||||
let visible = false;
|
||||
engine.projector.worldToWindow = () => (visible ? { x: 1, y: 1 } : null);
|
||||
let clamps = 0;
|
||||
engine.surface.clampToHeight = (position) => {
|
||||
clamps++;
|
||||
return position;
|
||||
};
|
||||
const records = geoJsonRecords(
|
||||
{
|
||||
type: 'MultiPoint',
|
||||
coordinates: Array.from({ length: 600 }, () => [1, 2]),
|
||||
},
|
||||
'#39d0ff',
|
||||
);
|
||||
const drawing = await drawImportedFile(engine, records, { createCanvas });
|
||||
assert.equal(clamps, 0);
|
||||
visible = true;
|
||||
let beforeYield;
|
||||
const heartbeat = setTimeout(() => {
|
||||
beforeYield = clamps;
|
||||
}, 0);
|
||||
await drawing.refreshGround();
|
||||
clearTimeout(heartbeat);
|
||||
assert.equal(beforeYield, 256);
|
||||
assert.equal(clamps, 600);
|
||||
drawing.destroy();
|
||||
},
|
||||
);
|
||||
|
||||
displayTest(
|
||||
'an aborted ground refresh leaves the existing drawing owned',
|
||||
async ({ engine }) => {
|
||||
|
||||
Reference in new issue
Block a user