Preserve fire incident geometry and selection across both globes

This commit is contained in:
German Khokhlov committed 2026-11-03 02:40:36 +04:00
1 parent b7431d7823
commit 1bda760763
16 files changed
+408 -140

No files matched your search

+8 -54
View File
@@ -1,3 +1,4 @@
import { createNavaraPolygonDisplay } from '../../shared/render/navaraPolygons.js';
import * as geo from '../../../geo/index.js';
function stationFeature(reading, radius) {
@@ -33,68 +34,21 @@ function stationFeature(reading, radius) {
/** One native GeoJSON layer per AQHI colour, independent of station count. */
export function createAirQualityNavaraRenderer(engine, { view }) {
let visible = false;
let batches = [];
function release(items) {
for (const { layer, source } of items) {
layer?.delete();
source.delete();
}
}
const display = createNavaraPolygonDisplay(engine, view, (color, show) => ({
polygon: {color, show, transparent: true, opacity: 0.35, clampToGround: true,
outline: true, outlineShow: true, outlineColor: color, outlineWidth: 2},
}));
return {
viewRectangle: () => engine.camera.viewRectangle(),
setVisible(show) {
if (visible === show) return;
visible = show;
for (const { layer, source, paint } of batches) {
layer.update({ type: 'vector', source, polygon: { ...paint, show } });
}
engine.render.request('air-quality-visibility');
},
setVisible: display.setVisible,
destroy: display.destroy,
replace(rows, radius) {
const groups = new Map();
for (const row of rows) {
if (!groups.has(row.color)) groups.set(row.color, []);
groups.get(row.color).push(stationFeature(row, radius));
}
const next = [];
try {
for (const [css, features] of groups) {
const color = Number.parseInt(css.slice(1), 16);
const paint = {
color,
transparent: true,
opacity: 0.35,
clampToGround: true,
outline: true,
outlineShow: true,
outlineColor: color,
outlineWidth: 2,
};
const source = view.addSource({
type: 'geojson',
data: { type: 'FeatureCollection', features },
});
const batch = { source, paint };
next.push(batch);
batch.layer = view.addLayer({
type: 'vector',
source,
polygon: { ...paint, show: visible },
});
}
} catch (error) {
release(next);
throw error;
}
release(batches);
batches = next;
engine.render.request('air-quality-readings');
},
destroy() {
release(batches);
batches = [];
engine.render.request('air-quality-destroy');
display.replace(groups);
},
};
}