Files
gods-eye-view/src/layers/earthquakes/render/cesium.js
T
German Khokhlov 7abf74518f Cut duplicated and dead code across the engines, the layers and the QA scripts
- src/geo drops the ported debug argument checks and the tests that
  bitExact already covers; package boundaries accept a directory entry,
  so src/geo/ is listed once per group.
- Cesium no longer carries movers and lines nobody draws with: they are
  optional engine capabilities. The fake engine and the Cesium camera use
  the shared cameraMath; unused contract tables, clock.ticked, the
  'finest' surface detail and Navara click statistics are gone.
- ALPR keeps one overlay core and one presentation model for both
  engines, bikeshare one station bookkeeping, the Navara ground effects
  one definition helper; image atlases, view centres, mover banks and
  colours are shared.
- The legacy switch route, the clock offset and rate controls and other
  unused exports are removed.
- The acceptance runs the Navara draw, geo import and scope checks;
  scenarios use the harness switch and page helpers; the main chunk
  check keeps the size budget only and runs once in CI.
2026-11-05 13:32:39 +04:00

84 lines
2.6 KiB
JavaScript

// Native earthquake entities: static CLAMP_TO_GROUND ellipses with the
// layer's properties and analyst snapshot semantics.
import * as Cesium from 'cesium';
export function createEarthquakesCesiumRenderer(_engine, { viewer }) {
if (!viewer?.dataSources)
throw new TypeError('Earthquakes require a native viewer');
const dataSource = new Cesium.CustomDataSource('earthquakes');
dataSource.show = false;
viewer.dataSources.add(dataSource);
let destroyed = false;
return {
kind: 'cesium',
setVisible(show) {
if (!destroyed) dataSource.show = show !== false;
},
replace(discs) {
if (destroyed) return;
const entities = discs.map(
({
stableId,
usgsId,
position,
baseRadius,
color,
isSignificant,
fillAlpha,
outlineAlpha,
mag,
place,
time,
depthKm,
}) =>
new Cesium.Entity({
id: `earthquake:${stableId}`,
position,
ellipse: {
semiMajorAxis: baseRadius,
semiMinorAxis: baseRadius,
material: new Cesium.ColorMaterialProperty(
color.withAlpha(fillAlpha),
),
outline: true,
outlineColor: color.withAlpha(outlineAlpha),
outlineWidth: isSignificant ? 3 : 2,
heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
},
properties: { usgsId, mag, place, time, depth: depthKm },
}),
);
dataSource.entities.removeAll();
for (const entity of entities) dataSource.entities.add(entity);
},
records(limit) {
if (destroyed || !dataSource.show) return [];
const now = Cesium.JulianDate.now();
const rows = [];
for (const entity of dataSource.entities.values) {
if (rows.length >= limit) break;
const position = entity.position?.getValue(now);
const carto = position
? Cesium.Cartographic.fromCartesian(position)
: null;
const p = entity.properties;
rows.push({
id: p?.usgsId?.getValue(now) ?? null,
mag: p?.mag?.getValue(now),
place: p?.place?.getValue(now),
time: p?.time?.getValue(now),
depth: p?.depth?.getValue(now),
lat: carto ? Cesium.Math.toDegrees(carto.latitude) : null,
lon: carto ? Cesium.Math.toDegrees(carto.longitude) : null,
});
}
return rows;
},
destroy() {
if (destroyed) return;
destroyed = true;
viewer.dataSources.remove(dataSource, true);
},
};
}