mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
Brings in the wildlife sightings layer (#1591, iNaturalist and Acartia sightings). Its badges, density glow and privacy cells draw through the draw port: the badges and the glow are icons sets (iconCollection.js batches point writes into one upsert per task), and the privacy cells are ground-clamped shapes and lines sets swapped whole. The eye, the view rectangle, clicks, projection, ground readiness and frames come from the camera, query, input, globe and frame ports, so the layer, its card and its placement no longer import Cesium. Differences from main: the density glow is drawn as pixel-sized splats (56 px) instead of metre-sized ones with a near fade; the card's pan eases with cubicOut, the contract's nearest ease-out; ground heights are resampled when the globe's load progress settles or its surface changes, rather than on tileset load events. Also fixes two things the last merge left: a double-click that starts on the followed track and ends off it reaches the renderer's own follow again (a press that cannot end a double-click on the track gives its hold back at its release), and the Active Fires heat drapes under the weather imagery, so weather turned on after it stacks above. CURRENT-STATE notes that the 2D and Columbus scene-mode checks are gone.
79 lines
2.1 KiB
JavaScript
79 lines
2.1 KiB
JavaScript
import {
|
|
WILDLIFE_MAX_VIEW_DEGREES,
|
|
WILDLIFE_RETRY_MIN_MS,
|
|
WILDLIFE_RETRY_MAX_MS,
|
|
} from './policy.js';
|
|
|
|
export { snapWildlifeBox } from './bounds.js';
|
|
|
|
const cleanDegree = (value) => Math.round(value * 1e8) / 1e8;
|
|
|
|
function validBox(box) {
|
|
return (
|
|
!!box &&
|
|
['south', 'west', 'north', 'east'].every((key) =>
|
|
Number.isFinite(box[key]),
|
|
) &&
|
|
box.south >= -90 &&
|
|
box.north <= 90 &&
|
|
box.north >= box.south &&
|
|
box.west >= -180 &&
|
|
box.west <= 180 &&
|
|
box.east >= -180 &&
|
|
box.east <= 180
|
|
);
|
|
}
|
|
|
|
function longitudeRanges(box) {
|
|
return box.west <= box.east
|
|
? [[box.west, box.east]]
|
|
: [
|
|
[box.west, 180],
|
|
[-180, box.east],
|
|
];
|
|
}
|
|
|
|
/** Test geographic overlap, including boxes that cross the antimeridian. */
|
|
export function boxIntersects(a, b) {
|
|
if (!validBox(a) || !validBox(b) || a.south > b.north || a.north < b.south)
|
|
return false;
|
|
return longitudeRanges(a).some(([aw, ae]) =>
|
|
longitudeRanges(b).some(([bw, be]) => aw <= be && ae >= bw),
|
|
);
|
|
}
|
|
|
|
/** Split a local camera rectangle into noncrossing observation query boxes. */
|
|
export function wildlifeViewportBoxes(rectangle) {
|
|
// `rectangle`: the camera's view rectangle in degrees, or null.
|
|
if (!rectangle) return null;
|
|
const box = Object.fromEntries(
|
|
['south', 'west', 'north', 'east'].map((key) => [
|
|
key,
|
|
cleanDegree(rectangle[key]),
|
|
]),
|
|
);
|
|
if (!validBox(box) || box.north <= box.south) return null;
|
|
const width =
|
|
box.east >= box.west ? box.east - box.west : 360 - box.west + box.east;
|
|
if (
|
|
width <= 0 ||
|
|
Math.max(box.north - box.south, width) > WILDLIFE_MAX_VIEW_DEGREES
|
|
)
|
|
return null;
|
|
return longitudeRanges(box)
|
|
.filter(([west, east]) => east > west)
|
|
.map(([west, east]) => ({
|
|
south: box.south,
|
|
west,
|
|
north: box.north,
|
|
east,
|
|
}));
|
|
}
|
|
|
|
/** 30 seconds, doubling to a four-minute ceiling, for local retry guidance. */
|
|
export function retryDelayMs(previousMs) {
|
|
return Number.isFinite(previousMs) && previousMs > 0
|
|
? Math.min(WILDLIFE_RETRY_MAX_MS, previousMs * 2)
|
|
: WILDLIFE_RETRY_MIN_MS;
|
|
}
|