mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
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:
1 parent
1b9bb844e6
commit
c56f098d07
44 files changed
+2530
-362
No files matched your search
@@ -0,0 +1,64 @@
|
||||
/**
|
||||
* @file The bundled UCS Satellite Database pack: operator, owner country and
|
||||
* purpose for active satellites, keyed by NORAD catalog number.
|
||||
*
|
||||
* Data: `local_data/ucs_satellites/ucs_satellites.json`, built by
|
||||
* `scripts/build-ucs-satellites.py` from UCS-Satellite-Database 5-1-2023
|
||||
* (https://www.ucsusa.org/satellite_database; free, unrestricted use, with an
|
||||
* acknowledgement). Loaded once, on demand, by the satellites layer; a failed
|
||||
* load is retried after a cooldown rather than remembered for the session.
|
||||
*
|
||||
* @module data/ucsSatellites
|
||||
*/
|
||||
|
||||
import { loadBundledJson } from './bundledJson.js';
|
||||
import { createRetryableLoader } from './retryableLoad.js';
|
||||
|
||||
const PACK_URL = new URL(
|
||||
'./local_data/ucs_satellites/ucs_satellites.json',
|
||||
import.meta.url,
|
||||
);
|
||||
|
||||
/**
|
||||
* One UCS row: what UCS says about a satellite's operator and purpose.
|
||||
* @typedef {{noradId: number, operator: string|null,
|
||||
* operatorCountry: string|null, purpose: string|null,
|
||||
* detailedPurpose: string|null, users: string|null,
|
||||
* orbitClass: string|null}} UcsSatellite
|
||||
*/
|
||||
|
||||
/**
|
||||
* Expand the pack's string-table rows into records keyed by NORAD number.
|
||||
* A pack of the wrong shape throws: read as an empty pack it would be kept
|
||||
* for the session, and every satellite would quietly lose its UCS evidence.
|
||||
* A malformed row is skipped.
|
||||
* @param {{fields: string[], strings: Record<string, string[]>,
|
||||
* records: Array<number[]>}} pack Parsed `ucs_satellites.json`.
|
||||
* @returns {Map<number, UcsSatellite>}
|
||||
*/
|
||||
export function indexUcsPack(pack) {
|
||||
const byNorad = new Map();
|
||||
const fields = pack?.fields;
|
||||
if (
|
||||
!Array.isArray(fields) ||
|
||||
fields[0] !== 'noradId' ||
|
||||
!Array.isArray(pack.records)
|
||||
)
|
||||
throw new TypeError('UCS pack has an unexpected shape');
|
||||
for (const row of pack.records) {
|
||||
const noradId = row?.[0];
|
||||
if (!Number.isInteger(noradId) || noradId <= 0) continue;
|
||||
const record = { noradId };
|
||||
for (let i = 1; i < fields.length; i++) {
|
||||
const text = pack.strings?.[fields[i]]?.[row[i]];
|
||||
record[fields[i]] = text ? text : null;
|
||||
}
|
||||
byNorad.set(noradId, record);
|
||||
}
|
||||
return byNorad;
|
||||
}
|
||||
|
||||
/** The pack, loaded and indexed once. */
|
||||
export const loadUcsSatellites = createRetryableLoader(async () =>
|
||||
indexUcsPack(await loadBundledJson(PACK_URL)),
|
||||
);
|
||||
Reference in new issue
Block a user