mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-18 17:22:19 +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.
138 lines
4.4 KiB
JavaScript
138 lines
4.4 KiB
JavaScript
import test from 'node:test';
|
||
import assert from 'node:assert/strict';
|
||
import {
|
||
chooseWildlifeGridZoom,
|
||
wildlifeGridTiles,
|
||
wildlifeGridViewportBoxes,
|
||
wildlifeGridCellBounds,
|
||
wildlifeGridCellId,
|
||
WILDLIFE_GRID_LOGICAL_SIZE,
|
||
WILDLIFE_GRID_TILE_CAP,
|
||
} from './gridViewport.js';
|
||
|
||
const globe = [
|
||
{ south: -85.0511287798066, west: -180, north: 85.0511287798066, east: 180 },
|
||
];
|
||
const regional = [{ south: 0, west: 0, north: 40.979898069620134, east: 45 }];
|
||
|
||
test('glow sampling uses roughly 8–14px cells independently of the 28px icon buckets', () => {
|
||
for (const [boxes, width, height, expected] of [
|
||
[globe, 448, 448, 0],
|
||
[regional, 448, 448, 3],
|
||
[
|
||
[{ south: 0, west: 0, north: 0.08789059053082508, east: 0.087890625 }],
|
||
448,
|
||
448,
|
||
12,
|
||
],
|
||
]) {
|
||
const zoom = chooseWildlifeGridZoom({ boxes, width, height });
|
||
assert.equal(zoom, expected);
|
||
const worldPixels = (width * 360) / (boxes[0].east - boxes[0].west);
|
||
const spacing = worldPixels / 2 ** zoom / WILDLIFE_GRID_LOGICAL_SIZE;
|
||
assert.ok(spacing >= 8 && spacing <= 14, `${zoom}: ${spacing}px`);
|
||
assert.ok(
|
||
wildlifeGridTiles({ boxes, z: zoom }).length <= WILDLIFE_GRID_TILE_CAP,
|
||
);
|
||
}
|
||
});
|
||
|
||
test('the named six-tile budget preserves complete coverage for common views', () => {
|
||
for (const [boxes, width, height, expected] of [
|
||
[globe, 896, 896, 1],
|
||
[regional, 896, 896, 4],
|
||
[[{ south: 7, west: -168, north: 72, east: -48 }], 1400, 900, 2],
|
||
[globe, 4000, 4000, 1],
|
||
[globe, 30_000, 400, 0],
|
||
]) {
|
||
const z = chooseWildlifeGridZoom({ boxes, width, height });
|
||
assert.equal(z, expected);
|
||
const tiles = wildlifeGridTiles({ boxes, z });
|
||
assert.ok(tiles.length > 0 && tiles.length <= WILDLIFE_GRID_TILE_CAP);
|
||
}
|
||
});
|
||
|
||
test('tile ranges contain only intersecting tiles, no offscreen neighbors or duplicate boundary tiles', () => {
|
||
assert.deepEqual(wildlifeGridTiles({ boxes: regional, z: 3 }), [
|
||
{ z: 3, x: 4, y: 3 },
|
||
]);
|
||
assert.deepEqual(wildlifeGridTiles({ boxes: globe, z: 0 }), [
|
||
{ z: 0, x: 0, y: 0 },
|
||
]);
|
||
const crossing = [{ south: 10, west: 179, north: 12, east: -178 }];
|
||
const split = [
|
||
{ south: 10, west: 179, north: 12, east: 180 },
|
||
{ south: 10, west: -180, north: 12, east: -178 },
|
||
];
|
||
const z = chooseWildlifeGridZoom({
|
||
boxes: crossing,
|
||
width: 896,
|
||
height: 600,
|
||
});
|
||
assert.deepEqual(
|
||
wildlifeGridTiles({ boxes: crossing, z }),
|
||
wildlifeGridTiles({ boxes: split, z }),
|
||
);
|
||
assert.ok(
|
||
wildlifeGridTiles({ boxes: crossing, z }).every(
|
||
(tile) =>
|
||
((tile.x + 1) / 2 ** z) * 360 - 180 > 179 ||
|
||
(tile.x / 2 ** z) * 360 - 180 < -178,
|
||
),
|
||
);
|
||
});
|
||
|
||
test('tile cap degrades zoom to preserve complete coverage and oversized direct requests fail closed', () => {
|
||
const z = chooseWildlifeGridZoom({
|
||
boxes: globe,
|
||
width: 30_000,
|
||
height: 400,
|
||
});
|
||
assert.ok(
|
||
wildlifeGridTiles({ boxes: globe, z }).length <= WILDLIFE_GRID_TILE_CAP,
|
||
);
|
||
assert.deepEqual(wildlifeGridTiles({ boxes: globe, z: 12 }), []);
|
||
assert.equal(chooseWildlifeGridZoom({ boxes: [], width: 0, height: 0 }), 0);
|
||
assert.deepEqual(wildlifeGridTiles({ boxes: [], z: 2 }), []);
|
||
});
|
||
|
||
test('grid camera viewport supports globe and antimeridian without detail-query degree limits', () => {
|
||
// The camera port's view rectangle, in degrees.
|
||
const boxes = wildlifeGridViewportBoxes({
|
||
south: -80,
|
||
west: 120,
|
||
north: 80,
|
||
east: -120,
|
||
});
|
||
assert.equal(boxes.length, 2);
|
||
assert.ok(Math.abs(boxes[0].west - 120) < 1e-8);
|
||
assert.equal(boxes[0].east, 180);
|
||
assert.equal(boxes[1].west, -180);
|
||
assert.deepEqual(wildlifeGridViewportBoxes(null), []);
|
||
});
|
||
|
||
test('logical cell ids and bounds share geographic coverage and wrap antimeridian', () => {
|
||
const id = wildlifeGridCellId(65.94004866768753, -18.28125, 2);
|
||
assert.equal(id, 'grid:2/1/1:1:51');
|
||
const bounds = wildlifeGridCellBounds(id);
|
||
assert.equal(bounds.west, -19.6875);
|
||
assert.equal(bounds.east, -16.875);
|
||
assert.ok(bounds.south < 65.94 && bounds.north > 65.94);
|
||
assert.equal(
|
||
wildlifeGridCellId(
|
||
(bounds.south + bounds.north) / 2,
|
||
(bounds.west + bounds.east) / 2,
|
||
2,
|
||
),
|
||
id,
|
||
);
|
||
assert.equal(wildlifeGridCellId(0, 180, 2), wildlifeGridCellId(0, -180, 2));
|
||
for (const invalid of [
|
||
'bad',
|
||
'grid:23/0/0:1:1',
|
||
'grid:2/4/0:1:1',
|
||
'grid:2/0/0:64:1',
|
||
])
|
||
assert.equal(wildlifeGridCellBounds(invalid), null);
|
||
});
|