mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Recent community wildlife observations, as a new Wildlife group in the layer panel. - Server: keyless iNaturalist proxy (v2 observations with only the projected fields; undocumented v1 UTFGrid density tiles, decoded on the server) sharing one paced queue (burst 4, ~1/s, 60/min, 8,000/day budget, up to four in flight), in-memory caches and upstream-only cooldowns; Acartia Salish Sea marine-mammal feed rounded to 0.01 degrees with comments dropped. - Layer: grid counts drawn as a soft view-ranked density glow; real sampled sightings as taxon badges at their true positions with ambient photo thumbnails and labels; obscured records stay privacy cells; a clicked sighting stays pinned through camera moves and refreshes. - Anchored photo card per selection with the single iNaturalist link; attribution in the layer row and the Data attribution popover. - Filters (CONFIRMED, taxa presets) round-trip in share links with token 9. Co-Authored-By: Claude Opus 5.5 <[email protected]>
80 lines
2.5 KiB
JavaScript
80 lines
2.5 KiB
JavaScript
/** Bottom-to-top order for near-plane-clamped contact sprite collections. */
|
|
export const SPRITE_LAYER_ORDER = Object.freeze([
|
|
'cctv',
|
|
'firms',
|
|
'wildlife-sightings',
|
|
'bikeshare',
|
|
'transit',
|
|
'transit-motion',
|
|
'directions',
|
|
'ais',
|
|
'military',
|
|
'flights',
|
|
]);
|
|
|
|
/** @type {Map<string, Object>} */
|
|
const _collections = new Map();
|
|
|
|
/**
|
|
* Register the current primitive collection for a sprite layer.
|
|
* @param {string} layerId - Stable sprite-order layer key.
|
|
* @param {Object} collection - Cesium billboard/point primitive collection.
|
|
* @returns {void}
|
|
*/
|
|
export function registerSpriteCollection(layerId, collection) {
|
|
if (!layerId || !collection) return;
|
|
_collections.set(layerId, collection);
|
|
}
|
|
|
|
/**
|
|
* Remove a registered collection (primarily useful to lifecycle tests).
|
|
* @param {string} layerId - Stable sprite-order layer key.
|
|
* @param {Object} [collection] - Optional identity guard against stale teardown.
|
|
* @returns {void}
|
|
*/
|
|
export function unregisterSpriteCollection(layerId, collection) {
|
|
if (collection && _collections.get(layerId) !== collection) return;
|
|
_collections.delete(layerId);
|
|
}
|
|
|
|
/**
|
|
* Reassert deterministic sprite stacking after any layer enable/init.
|
|
* Cesium's stable translucent sort otherwise preserves first-enable primitive
|
|
* order. Raising bottom-to-top makes flights the final/top collection.
|
|
* @param {Cesium.Viewer|Object} viewer - Active viewer.
|
|
* @returns {void}
|
|
*/
|
|
export function restoreSpriteOrder(viewer) {
|
|
if (!viewer || viewer.isDestroyed?.()) return;
|
|
const scene = viewer.scene;
|
|
const primitives = scene?.primitives;
|
|
if (!primitives || scene.isDestroyed?.() || primitives.isDestroyed?.())
|
|
return;
|
|
|
|
for (const layerId of SPRITE_LAYER_ORDER) {
|
|
const collection = _collections.get(layerId);
|
|
if (!collection || collection.isDestroyed?.()) continue;
|
|
if (primitives.contains?.(collection) === false) continue;
|
|
primitives.raiseToTop(collection);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Explicit layer-enable wiring seam. Production callers use the shared
|
|
* restorer by default; tests inject a spy to pin each enable path without
|
|
* constructing a WebGL viewer.
|
|
* @param {string} layerId - Sprite layer whose enable path is restoring order.
|
|
* @param {Cesium.Viewer|Object} viewer - Active viewer.
|
|
* @param {(viewer: Object) => void} [restore=restoreSpriteOrder] - Test seam.
|
|
* @returns {void}
|
|
*/
|
|
export function restoreSpriteOrderOnEnable(
|
|
layerId,
|
|
viewer,
|
|
restore = restoreSpriteOrder,
|
|
) {
|
|
if (!SPRITE_LAYER_ORDER.includes(layerId) || typeof restore !== 'function')
|
|
return;
|
|
restore(viewer);
|
|
}
|