mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-04 10:24:02 +00:00
Knip, configured with the application, package exports, scripts, QA harnesses, workers, tools and tests as entry points, reports exports that no module imports. Each was checked by hand against string-based and namespace imports. - Symbols that are still used inside their own module lose only the `export` keyword (176 constants and helpers). - Unused re-exports are removed from barrel modules (flight, military, vessel, CCTV, directions, transit history, local ADS-B and street-level policy modules). - Declarations that nothing uses at all are deleted, among them AIS_WATCHDOG_STATUSES, applyFilter, isRadioCountryCode, compactText, DENSITY_STOPS, the unused CCTV endpoint constants, and the SDR band constants. - Default exports that nothing imports are removed. The ones in src/data/earthquakes.js, src/data/telegeographySubmarineCables.js, src/data/wind.js and src/data/bhoteKoshiLocator.js each constructed a layer instance at import time that nothing used; those instances are no longer created. Every export of a package.json entry stays, as does TOMTOM_CREDIT, which the traffic layer reads from the credits namespace it is given.
62 lines
2.2 KiB
JavaScript
62 lines
2.2 KiB
JavaScript
import * as Cesium from 'cesium';
|
|
import { resolvePickedContext } from '../data/pickedContext.js';
|
|
import { cameraPoseKey } from './pointerContext.js';
|
|
import * as defaultAnnotationResolver from '../annotations/annotationResolver.js';
|
|
|
|
/** "Around here" radius as a share of camera height, clamped to sane bounds. */
|
|
function pointerRadiusKm(cameraHeightM) {
|
|
const heightKm = Number(cameraHeightM) / 1000;
|
|
if (!Number.isFinite(heightKm) || heightKm <= 0) return 50;
|
|
return Math.round(Math.min(400, Math.max(5, heightKm * 0.75)));
|
|
}
|
|
|
|
/**
|
|
* The Cesium side of point-and-ask: one entity pick and one depth-aware world
|
|
* pick at canvas CSS pixels. Called lazily by the pointer tracker (dwell and
|
|
* snapshot only), never per mouse move.
|
|
* @param {object} options
|
|
* @param {object} options.viewer Cesium viewer.
|
|
* @param {object} [options.dataManager] Layer lifecycle.
|
|
* @param {Function} [options.pickWorldFromScreen] Normalized-pixel world pick.
|
|
* @returns {(x: number, y: number) => {entity: object|null, ground: object|null, radiusKm: number}|null}
|
|
*/
|
|
export function createPointerPicker({
|
|
viewer,
|
|
dataManager = null,
|
|
pickWorldFromScreen = defaultAnnotationResolver.pickWorldFromScreen,
|
|
}) {
|
|
return function pickPointer(x, y) {
|
|
const scene = viewer?.scene;
|
|
const canvas = scene?.canvas;
|
|
if (!scene || !canvas) return null;
|
|
const width = canvas.clientWidth || canvas.width || 0;
|
|
const height = canvas.clientHeight || canvas.height || 0;
|
|
if (!width || !height) return null;
|
|
let picked = null;
|
|
try {
|
|
picked = scene.pick(new Cesium.Cartesian2(x, y));
|
|
} catch {
|
|
picked = null;
|
|
}
|
|
const entity = resolvePickedContext(picked, { dataManager });
|
|
let ground = null;
|
|
try {
|
|
const hit = pickWorldFromScreen(viewer, x / width, y / height);
|
|
if (hit && Number.isFinite(hit.lat) && Number.isFinite(hit.lon))
|
|
ground = {
|
|
lat: hit.lat,
|
|
lon: hit.lon,
|
|
heightM: Number.isFinite(hit.height) ? Math.round(hit.height) : null,
|
|
};
|
|
} catch {
|
|
ground = null;
|
|
}
|
|
return {
|
|
entity,
|
|
ground,
|
|
radiusKm: pointerRadiusKm(viewer.camera?.positionCartographic?.height),
|
|
cameraKey: cameraPoseKey(viewer),
|
|
};
|
|
};
|
|
}
|