feat(satellites): file satellites under six classes with a toggle each

The satellites layer now sorts every object into Stations, Imaging,
Telecom, Starlink, Probes or Debris, each with a chip and a live count on
the layer row. Stations and Imaging show by default; the Starlink chip is
the former DENSE catalog switch. Hidden classes keep their points, so a
toggle needs no reload, and they leave the detection overlay and the voice
position lists.

A class comes, strongest evidence first, from CelesTrak SATCAT (object type
and status, served by a new /api/celestrak-satcat/<group> proxy route and
cached for a day), the bundled UCS Satellite Database pack (operator, owner
country and purpose), name patterns for later launches, and the CelesTrak
group. The core catalog also reads the resource, weather, planet, sar and
science groups. Payloads with no evidence of life launched 20 or more years
ago are filed as debris. The UCS pack, its build script and its data credit
are added.
This commit is contained in:
Denis Groshev committed 2026-11-08 23:34:55 +01:00
1 parent 1b9bb844e6
commit c56f098d07
44 files changed
+2530 -362

No files matched your search

+89 -3
View File
@@ -1,8 +1,9 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { parseTleText, tleLineLaunchYear } from '../../sources/tle.js';
import { createIngestion } from './ingestion.js';
import { SATCAT_WAIT_MS, createIngestion } from './ingestion.js';
import { createOrbits } from './orbits.js';
import { createControls } from './controls.js';
// The ISS set (1 January 2024) with its catalog field swapped per satellite.
const ISS_LINE1 =
@@ -18,7 +19,7 @@ function tleSet(name, field) {
].join('\n');
}
function ingestionFor(catalogText) {
function ingestionFor(catalogText, { source: sourceExtras = {} } = {}) {
const state = {
_trackingRefreshEpoch: 0,
_activeUpdateControllers: new Set(),
@@ -33,6 +34,8 @@ function ingestionFor(catalogText) {
_denseLoadToken: 0,
_catalogRevision: 0,
_params: { catalog: 'core', showOrbits: false },
_satcat: new Map(),
_ucs: null,
};
const parts = {
orbits: {
@@ -40,7 +43,16 @@ function ingestionFor(catalogText) {
propagatePosition: () => ({ longitude: 0, latitude: 0, altitude: 4e5 }),
},
labels: { _syncIssOverlay() {} },
controls: { _pointStyleFor: () => ({}) },
controls: {
_pointStyleFor: () => ({}),
_classVisible: () => true,
_applyClassVisibility() {
state.visibilityApplied = (state.visibilityApplied || 0) + 1;
},
_notifyRowControls() {
state.rowNotified = (state.rowNotified || 0) + 1;
},
},
rendering: { _showOrbitPath() {} },
tracking: {
async _reconcileTrackedSubjectContext() {},
@@ -52,6 +64,7 @@ function ingestionFor(catalogText) {
async readGroup() {
return { ok: true, text: catalogText };
},
...sourceExtras,
};
const { methods } = createIngestion({ state, services: {}, parts, source });
return { state, update: () => methods.update({ scene: {} }) };
@@ -119,3 +132,76 @@ test('a satellite with a blank designator keeps matching by name', async (t) =>
69728,
);
});
test('a hanging SATCAT read neither holds the catalog nor is lost when it lands', async (t) => {
t.mock.method(console, 'log', () => {});
t.mock.method(console, 'warn', () => {});
t.mock.timers.enable({ apis: ['setTimeout'] });
let answer;
const satcatAnswer = new Promise((resolve) => {
answer = resolve;
});
const { state, update } = ingestionFor(tleSet('OLD STAGE', '40115'), {
source: { readSatcat: () => satcatAnswer },
});
state._enabled = true;
const settle = async () => {
for (let turn = 0; turn < 20; turn += 1)
await new Promise((resolve) => setImmediate(resolve));
};
const rebuilt = update();
await settle();
t.mock.timers.tick(SATCAT_WAIT_MS);
await rebuilt;
// Built without SATCAT: neither name nor group says what it is (the
// stations group alone makes no station).
assert.equal(state._catalog.get(40115).satelliteClass, 'probes');
const revision = state._catalogRevision;
// SATCAT lands late: a rocket body.
answer({
ok: true,
stale: true,
text: 'OBJECT_NAME,OBJECT_ID,NORAD_CAT_ID,OBJECT_TYPE,OPS_STATUS_CODE,OWNER\nOLD STAGE,2014-048B,40115,R/B,,US',
});
await settle();
assert.equal(state._catalog.get(40115).satelliteClass, 'debris');
assert.equal(state._catalogRevision, revision + 1, 'the legend refreshes');
assert.ok(state.visibilityApplied >= 1 && state.rowNotified >= 1);
assert.equal(state._satcatState, 'stale', 'its staleness is kept');
});
test('a failed SATCAT read is told on the layer row, not only the console', async (t) => {
t.mock.method(console, 'log', () => {});
t.mock.method(console, 'warn', () => {});
const { state, update } = ingestionFor(tleSet('OLD STAGE', '40115'), {
source: { readSatcat: async () => ({ ok: false, text: '' }) },
});
await update();
assert.equal(state._satcatState, 'unavailable');
assert.ok(state.rowNotified >= 1, 'the row repaints');
const controls = createControls({
state: {
...state,
_params: { ...state._params, showPoints: true },
_classTallyCache: {},
},
services: { layerState: { isExplicitLayerStateOrigin: () => false } },
parts: {},
source: {},
});
const row = controls.methods.getRowControls();
assert.equal(row.info, 'Classes may lag: SATCAT unavailable');
assert.match(row.infoTitle, /SATCAT/);
const current = createControls({
state: {
...state,
_satcatState: 'current',
_params: { ...state._params, showPoints: true },
_classTallyCache: {},
},
services: { layerState: { isExplicitLayerStateOrigin: () => false } },
parts: {},
source: {},
});
assert.equal(current.methods.getRowControls().info, '');
});