mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
Merge main through #1591 into the renderer seam
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.
This commit is contained in:
commit
020a433b51
129 files changed
+22143
-336
No files matched your search
@@ -1,21 +1,26 @@
|
||||
/** Bounded per-key and aggregate request admission. */
|
||||
const RATE_LIMITER_MAX_KEYS = 2000;
|
||||
|
||||
export function makeRateLimiter({ windowMs, max, globalMax }) {
|
||||
export function makeRateLimiter({
|
||||
windowMs,
|
||||
max,
|
||||
globalMax,
|
||||
now = () => Date.now(),
|
||||
}) {
|
||||
const hits = new Map(); // key -> number[] (timestamps within window)
|
||||
let globalTimes = []; // all hits in window, for the global backstop
|
||||
return function allow(key) {
|
||||
const now = Date.now();
|
||||
globalTimes = globalTimes.filter((t) => now - t < windowMs);
|
||||
const at = now();
|
||||
globalTimes = globalTimes.filter((t) => at - t < windowMs);
|
||||
if (globalMax && globalTimes.length >= globalMax) return false; // global backstop
|
||||
const recent = (hits.get(key) || []).filter((t) => now - t < windowMs);
|
||||
const recent = (hits.get(key) || []).filter((t) => at - t < windowMs);
|
||||
if (recent.length >= max) {
|
||||
hits.set(key, recent);
|
||||
return false;
|
||||
}
|
||||
recent.push(now);
|
||||
recent.push(at);
|
||||
hits.set(key, recent);
|
||||
globalTimes.push(now);
|
||||
globalTimes.push(at);
|
||||
// Hard key cap so a key-rotating caller can't grow the map without bound.
|
||||
if (hits.size > RATE_LIMITER_MAX_KEYS) {
|
||||
const oldest = hits.keys().next().value;
|
||||
@@ -23,7 +28,7 @@ export function makeRateLimiter({ windowMs, max, globalMax }) {
|
||||
}
|
||||
if (hits.size > 256) {
|
||||
for (const [k, v] of hits) {
|
||||
if (!v.length || now - v[v.length - 1] > windowMs) hits.delete(k);
|
||||
if (!v.length || at - v[v.length - 1] > windowMs) hits.delete(k);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { makeRateLimiter } from './rateLimit.js';
|
||||
|
||||
test('injected time drives per-client and global rolling limits', () => {
|
||||
let at = 1000;
|
||||
const allow = makeRateLimiter({
|
||||
windowMs: 60_000,
|
||||
max: 2,
|
||||
globalMax: 3,
|
||||
now: () => at,
|
||||
});
|
||||
assert.equal(allow('a'), true);
|
||||
assert.equal(allow('a'), true);
|
||||
assert.equal(allow('a'), false);
|
||||
assert.equal(allow('b'), true);
|
||||
assert.equal(allow('c'), false);
|
||||
at += 59_999;
|
||||
assert.equal(allow('a'), false);
|
||||
at += 1;
|
||||
assert.equal(allow('a'), true);
|
||||
assert.equal(allow('c'), true);
|
||||
});
|
||||
@@ -4,6 +4,7 @@ import { createWfigsPerimeterSource } from '../layers/perimeters/source.js';
|
||||
import { createDroneAirspaceSource } from '../layers/droneAirspace/source.js';
|
||||
import { createBundledCableSource } from '../layers/submarineCables/bundledSource.js';
|
||||
import { createAdsbGnssSource } from '../layers/gnss/source.js';
|
||||
import { createWildlifeSightingsSource } from '../layers/wildlifeSightings/source.js';
|
||||
|
||||
/** Construct the existing reference feeds independently of application setup. */
|
||||
export function createReferenceSources() {
|
||||
@@ -12,6 +13,7 @@ export function createReferenceSources() {
|
||||
'air-quality': createEcccAirQualitySource(),
|
||||
'fire-perimeters': createWfigsPerimeterSource(),
|
||||
'drone-airspace': createDroneAirspaceSource(),
|
||||
'wildlife-sightings': createWildlifeSightingsSource(),
|
||||
cables: createBundledCableSource(),
|
||||
'gnss-integrity': createAdsbGnssSource(),
|
||||
};
|
||||
|
||||
@@ -17,6 +17,7 @@ test('reference factories retain compatibility without starting acquisition or s
|
||||
'air-quality',
|
||||
'fire-perimeters',
|
||||
'drone-airspace',
|
||||
'wildlife-sightings',
|
||||
'cables',
|
||||
'gnss-integrity',
|
||||
]);
|
||||
@@ -24,12 +25,14 @@ test('reference factories retain compatibility without starting acquisition or s
|
||||
assert.notEqual(first['air-quality'], second['air-quality']);
|
||||
assert.notEqual(first['fire-perimeters'], second['fire-perimeters']);
|
||||
assert.notEqual(first['drone-airspace'], second['drone-airspace']);
|
||||
assert.notEqual(first['wildlife-sightings'], second['wildlife-sightings']);
|
||||
assert.notEqual(first.cables, second.cables);
|
||||
assert.notEqual(first['gnss-integrity'], second['gnss-integrity']);
|
||||
assert.equal(typeof first.earthquakes.getSnapshot, 'function');
|
||||
assert.equal(typeof first['air-quality'].getSnapshot, 'function');
|
||||
assert.equal(typeof first['fire-perimeters'].getSnapshot, 'function');
|
||||
assert.equal(typeof first['drone-airspace'].getSnapshot, 'function');
|
||||
assert.equal(typeof first['wildlife-sightings'].getSnapshot, 'function');
|
||||
assert.equal(typeof first.cables.fetch, 'function');
|
||||
assert.equal(typeof first['gnss-integrity'].getSnapshot, 'function');
|
||||
assert.equal(requests, 0);
|
||||
|
||||
Reference in new issue
Block a user