feat: Wildlife Sightings layer from iNaturalist and Acartia

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]>
This commit is contained in:
Yehe LiuandClaude Opus 5.5 committed 2026-11-05 16:17:12 -05:00
1 parent edd6212793
commit 14f88b3e08
120 files changed
+21260 -285

No files matched your search

@@ -0,0 +1,82 @@
import assert from 'node:assert/strict';
import { createWildlifeBillboardModel } from '../layers/wildlifeSightings/billboardModel.js';
import { buildWildlifeIconModel } from '../layers/wildlifeSightings/model.js';
export const WILDLIFE_BENCHMARK_REFRESHES = 10;
const ICONICS = ['Aves', 'Mammalia', 'Reptilia', 'Plantae', 'Unknown'];
export function syntheticRows(n) {
return Array.from({ length: n }, (_, i) => ({
stableId: `synthetic:${i}`,
lat: -60 + (i % 1000) * 0.12,
lon: -179 + (i % 2000) * 0.179,
iconic: ICONICS[i % ICONICS.length],
quality: 'research',
count: null,
obscured: false,
cell: null,
}));
}
export function harness() {
const points = new Set();
const counters = { created: 0, destroyed: 0, writes: 0, positions: 0 };
const collection = {
add(options) {
const point = new Proxy(
{ show: true, ...options },
{
set(target, key, value) {
counters.writes += 1;
target[key] = value;
return true;
},
},
);
points.add(point);
counters.created += 1;
return point;
},
remove(point) {
assert.equal(points.delete(point), true);
counters.destroyed += 1;
},
removeAll() {
throw new Error('A refresh must never clear the billboard collection');
},
};
const appearance = new Map(
ICONICS.map((iconic) => [
iconic,
{
image: `cached:${iconic}`,
color: iconic,
scale: 1,
},
]),
);
const pointById = new Map();
const model = createWildlifeBillboardModel({
collection,
pointById,
positions: new Map(),
positionForRow(row) {
counters.positions += 1;
return { x: row.lon, y: row.lat };
},
appearanceForGroup: (group) => appearance.get(group),
});
const apply = (rows) => {
const population = buildWildlifeIconModel({ rows });
return model.update(population.rows);
};
return { apply, counters, model, pointById, points };
}
export function changePositions(rows, refresh) {
return rows.map((row, i) =>
i % 10 === 0
? { ...row, lat: row.lat + (refresh % 2 ? 0.001 : -0.001) }
: row,
);
}