Files
gods-eye-view/src/data/modelEligibility.test.mjs
T
1fc795577a feat(sdr): local receivers — browser RTL-SDR, Local ADS-B layer and decoder feeds (#732)
Adds a Local ADS-B layer fed by your own receivers: a browser WebUSB
RTL-SDR (with FM listening) and local 1090/978 MHz decoder feeds
(LOCAL_RECEIVER_FEEDS, local and private addresses only). Local aircraft
draw in magenta with class, silhouettes, 3D models, trails and a position
sanity filter; the click card names the band and input that heard them.

Builds on Sameh Khamis's SDR prototype and the initial GEV port by
Mazeyar Moeini Feizabadi (#134); the decoder-feed design follows the
notes on #57. Closes #57.

Co-authored-by: Sameh Khamis <[email protected]>
Co-authored-by: Mazeyar Moeini Feizabadi <[email protected]>
2026-09-23 16:00:53 -05:00

49 lines
1.3 KiB
JavaScript

import assert from 'node:assert/strict';
import test from 'node:test';
import { selectModelEligible } from './modelEligibility.js';
const ADD_SQ = 100 * 100;
test('visible contacts win the cap before off-screen retained models', () => {
// Nearest first: an off-screen retained model, then two on-screen contacts.
const candidates = [
['off-kept', 10, false],
['on-new', 20, true],
['on-kept', 30, true],
];
const modeled = new Set(['off-kept', 'on-kept']);
const eligible = selectModelEligible(candidates, {
cap: 2,
addDistSq: ADD_SQ,
isModeled: (id) => modeled.has(id),
});
assert.deepEqual([...eligible], ['on-kept', 'on-new']);
});
test('retained models keep their slot beyond the add radius; new ones do not', () => {
const candidates = [
['near-new', 50, true],
['far-kept', ADD_SQ + 1, true],
['far-new', ADD_SQ + 2, true],
['off-new', 60, false],
];
const eligible = selectModelEligible(candidates, {
cap: 10,
addDistSq: ADD_SQ,
isModeled: (id) => id === 'far-kept',
});
assert.deepEqual([...eligible], ['far-kept', 'near-new', 'off-new']);
});
test('an empty cap admits nothing', () => {
assert.equal(
selectModelEligible([['a', 1, true]], {
cap: 0,
addDistSq: ADD_SQ,
isModeled: () => true,
}).size,
0,
);
});