Draw imported files through the draw port, off Cesium

Import no longer loads KML, KMZ, GeoJSON and GPX through Cesium's data
source loaders. geoImportFeatures.js reads the sanitized file into plain
pins, lines, walls, polygons and ground overlays with the looks those
loaders gave them: icon, scale, colour, heading and hot spot, the shared
and inline style precedence, line and polygon colours and widths,
extruded and clamped geometry, rotated boxes and quads, and GeoJSON's
48 px pins, draped lines along rhumb lines and quarter-opacity fills.
geoImportPins.js draws them in three draw sets per file, places ground
pins through the height service (0 on the bare ellipsoid, whose coarse
tiles sag below it; the mesh nearby on photoreal maps), follows a
double-clicked pin, frames Fly-to, and shows, hides and removes them.

The Cesium adapter now draws two members the contract already had: an
icon's pixel offset and the wall shape. Image fills draw in the
translucent pass, so an overlay's own alpha blends as it did.

The Cesium allow-list is now empty; the ratchet test checks that its
scan still sees each way of reaching Cesium. The QA scripts read what a
file drew through the import's drawn(id), and the large-file check
compares it with Cesium's own reading of the same KML. A file the
renderer refuses to draw is refused by itself, without stopping its
batch. Two translations no longer used are dropped.
This commit is contained in:
Sameh Khamis committed 2026-11-09 15:50:53 -08:00
1 parent c073064507
commit 6c1f91014c
33 files changed
+2608 -1177

No files matched your search

+62 -21
View File
@@ -1,6 +1,6 @@
// Behavioral tests for DISPLAY ▸ Import: the controller is driven against
// fake DOM and viewer doubles with an injected loader, and its observable
// effects are asserted — data sources added and removed, the rows and hint it
// effects are asserted — drawings mounted and removed, the rows and hint it
// publishes, drop handling, the file limit, and what destroy() gives back.
// The Display panel renders the published list (`displayPanel.test.mjs`);
// real parsing and rendering run in `scripts/qa-geo-import.mjs`.
@@ -85,16 +85,6 @@ function setup({
const viewer = {
container: new FakeElement('div', 'cesiumContainer'),
scene: { requestRender: () => (renders += 1) },
dataSources: {
add: async (ds) => {
added.push(ds);
return ds;
},
remove: (ds, destroy) => {
removed.push({ ds, destroy });
return true;
},
},
flyTo: (target) => flights.push(target),
};
// The renderer's ports, when the test gives them, bound before the import
@@ -107,7 +97,7 @@ function setup({
if (file.fail) throw new GeoImportError(file.fail);
if (file.crash) throw new Error('boom');
return {
dataSource: { show: true },
drawing: { show: true },
name: file.name,
format: 'geojson',
entityCount: 3,
@@ -115,9 +105,24 @@ function setup({
revoke: () => revoked.push(file.name),
};
};
// Each loaded file's drawing, recorded when the import mounts it and when
// it takes it off the globe.
const recorded = async (file, opts) => {
const loaded = await (load || defaultLoad)(file, opts);
const drawing = loaded.drawing ?? {};
drawing.destroy = () => removed.push({ ds: drawing, destroy: true });
return {
...loaded,
drawing,
mount() {
loaded.mount?.();
added.push(drawing);
},
};
};
const tool = initGeoFileImport({
viewer,
load: load || defaultLoad,
load: recorded,
document,
...(navigation ? { navigation } : {}),
...(subscribeMapSource ? { subscribeMapSource } : {}),
@@ -201,10 +206,19 @@ test('row buttons hide, show, fly to and remove a file', async () => {
await t.tool.importFiles([file('a.gpx')]);
const [{ id }] = t.tool.list();
const ds = t.added[0];
ds.ids = { icons: 'i', lines: 'l', shapes: 's' };
ds.items = () => ({ icons: [{ id: 'p0' }], lines: [], shapes: [] });
const glyphClick = (name) => press(t, rows(t)[0], name);
assert.equal(ds.show, true);
glyphClick('toggle');
assert.equal(ds.show, false);
assert.deepEqual(t.tool.drawn(id), {
sets: { icons: 'i', lines: 'l', shapes: 's' },
show: false,
icons: [{ id: 'p0' }],
lines: [],
shapes: [],
});
assert.equal(t.tool.list()[0].visible, false);
assert.equal(action(rows(t)[0], 'toggle').pressed, 'false');
assert.equal(action(rows(t)[0], 'toggle').icon, 'visibility_off');
@@ -217,6 +231,7 @@ test('row buttons hide, show, fly to and remove a file', async () => {
assert.deepEqual(t.revoked, ['a.gpx']);
assert.equal(t.tool.list().length, 0);
assert.deepEqual(rows(t), []);
assert.equal(t.tool.drawn(id), null);
assert.equal(t.tool.remove(id), false);
});
@@ -240,6 +255,32 @@ test('a refused file says why and does not stop the rest of the batch', async ()
assert.equal(t.tool.list().length, 1);
});
test('a file the renderer will not draw is refused and released, and the batch goes on', async () => {
const t = setup({
load: async (file) => ({
drawing: { show: true },
name: file.name,
format: 'kml',
entityCount: 1,
revoke: () => t.revoked.push(file.name),
mount() {
if (file.name === 'odd.kml') throw new Error('refused');
},
}),
});
const out = await t.tool.importFiles([file('odd.kml'), file('good.kml')]);
assert.deepEqual(
out.map((o) => o.ok),
[false, true],
);
assert.match(out[0].error, /could not be read\./);
assert.deepEqual(t.revoked, ['odd.kml']);
assert.deepEqual(
t.tool.list().map((f) => f.name),
['good.kml'],
);
});
test('the number of files on the globe is bounded', async () => {
const t = setup();
const many = Array.from({ length: MAX_IMPORTED_FILES + 2 }, (_, i) =>
@@ -314,7 +355,7 @@ test('a file that finishes loading after destroy is released, not added', async
load: async () => {
await gate;
return {
dataSource: {},
drawing: {},
name: 'late',
format: 'kml',
entityCount: 1,
@@ -418,7 +459,7 @@ test('a direct camera gesture cancels the fly-to of a file still being read', as
name: 'slow.geojson',
format: 'geojson',
entityCount: 1,
dataSource: {},
drawing: {},
};
},
});
@@ -464,7 +505,7 @@ test('ground refresh coalesces map changes and releases its subscription on tear
name: 'point.geojson',
format: 'geojson',
entityCount: 1,
dataSource: {},
drawing: {},
refreshGround: async () => refreshed++,
}),
});
@@ -500,7 +541,7 @@ test('the camera settling and the terrain queue running dry refresh the ground,
name: 'point.geojson',
format: 'geojson',
entityCount: 1,
dataSource: {},
drawing: {},
refreshGround: async () => refreshed++,
}),
});
@@ -569,7 +610,7 @@ test('a slow import does not fly once something newer took the camera', async ()
load: async (f) => {
await gate;
return {
dataSource: {},
drawing: {},
name: f.name,
format: 'geojson',
entityCount: 1,
@@ -603,7 +644,7 @@ test('a queued import cannot fly over navigation that happened while it waited',
load: async (f) => {
if (f.name === 'first.geojson') await gate;
return {
dataSource: {},
drawing: {},
name: f.name,
format: 'geojson',
entityCount: 1,
@@ -638,7 +679,7 @@ test('a refused deferred stamp (Cockpit) imports without flying', async () => {
test('KML and KMZ rows say they keep their own styles instead of showing a color', async () => {
const t = setup({
load: async (f) => ({
dataSource: {},
drawing: {},
name: f.name,
format: f.name.endsWith('.kml') ? 'kml' : 'gpx',
entityCount: 2,
@@ -657,7 +698,7 @@ test('KML and KMZ rows say they keep their own styles instead of showing a color
test('the map-object count in a row title keeps digit grouping', async () => {
const t = setup({
load: async (f) => ({
dataSource: {},
drawing: {},
name: f.name,
format: 'geojson',
entityCount: 12345,