Files
corescope-rx/test/hexgrid.test.mjs
efitenandClaude Opus 4.8 9f2ff0b7d9 feat(app): real-time local coverage hex map (follows GPS, keeps zoom)
- src/hexgrid.js: JS port of the server hex grid (same cells as the analyzer)
- src/localmap.js: Leaflet map aggregating this session's receptions into live
  hexes (best SNR colour); follows GPS with zoom preserved, drag to inspect +
  📍 button to re-follow; hexes persist until reload
- wired into the capture flow; Leaflet via CDN

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-10 10:41:43 +02:00

23 lines
759 B
JavaScript

import { test } from 'node:test';
import assert from 'node:assert';
import { hexCellAt, hexBoundary, hexResForZoom } from '../src/hexgrid.js';
test('hexCellAt is stable and distinct', () => {
const a = hexCellAt(51.05, 3.72, 9);
assert.strictEqual(a, hexCellAt(51.05, 3.72, 9));
assert.notStrictEqual(hexCellAt(51.20, 3.72, 9), a); // ~17 km away
});
test('hexBoundary is a closed 7-point ring', () => {
const r = hexBoundary(hexCellAt(51.05, 3.72, 9));
assert.strictEqual(r.length, 7);
assert.deepStrictEqual(r[0], r[6]);
assert.strictEqual(hexBoundary('garbage'), null);
});
test('hexResForZoom', () => {
assert.strictEqual(hexResForZoom(16), 11);
assert.strictEqual(hexResForZoom(8), 7);
assert.strictEqual(hexResForZoom(3), 6);
});