packCataloguefunction
Pack catalogue records into one file: a small header (the format, how many records, and meta, a few words of text such as where the data is from and when it was retrieved), a column for each number and, last, the names.
The epoch is kept to the microsecond and the mean motion in full; the angles, the eccentricity and the drag terms are kept as 32-bit floats (an angle to about 0.00003 degrees, well inside what the elements are good to).
A record whose numbers are not finite, or whose catalogue number is not a whole number from 0 up to 4,294,967,295, is refused with a PackError.
Import it
import { packCatalogue } from "@johnmorrisdotca/chikyu-earth/catalogue";
Definition
function packCatalogue(records: readonly CatalogueRecord[], meta?: Readonly<Record<string, string>>): Uint8Array
Parameters
| Name | Type | Description |
|---|---|---|
records | readonly CatalogueRecord[] | The records, in the order the file keeps them (at most |
meta (optional) | Readonly<Record<string, string>> | Words to keep with the file (read back as |
Returns
Uint8Array<ArrayBufferLike>
The bytes. Gzip them with gzipBytes for a file a site hosts.
Examples
import { packCatalogue, unpackCatalogue, type CatalogueRecord } from "@johnmorrisdotca/chikyu-earth/catalogue";
const record: CatalogueRecord = {
set: { OBJECT_NAME: "MADE-UP 1", OBJECT_ID: "2026-001A", EPOCH: "2026-11-08T04:12:35.430048", MEAN_MOTION: 15.2, ECCENTRICITY: 0.0002, INCLINATION: 53, RA_OF_ASC_NODE: 10, ARG_OF_PERICENTER: 90, MEAN_ANOMALY: 20, NORAD_CAT_ID: 1_000_001, BSTAR: 0.0001, MEAN_MOTION_DOT: 0.00001, MEAN_MOTION_DDOT: 0 },
kind: "DEB",
};
const bytes = packCatalogue([record], { group: "debris" });
const back = unpackCatalogue(bytes);
console.log(bytes.length, back.count, back.setAt(0).NORAD_CAT_ID, back.meta["group"]);165 1 1000001 debrisWhat it prints (run when this page was built)