@johnmorrisdotca/chikyu-earth 0.31.0 → 0.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/NOTICE.md +10 -1
- package/README.md +32 -2
- package/dist/catalogue/fleets.d.ts +70 -0
- package/dist/catalogue/fleets.js +66 -0
- package/dist/catalogue/index.d.ts +5 -0
- package/dist/catalogue/index.js +7 -0
- package/dist/catalogue/kinds.d.ts +143 -0
- package/dist/catalogue/kinds.js +121 -0
- package/dist/catalogue/omm.d.ts +44 -0
- package/dist/catalogue/omm.js +92 -0
- package/dist/catalogue/orbit.d.ts +95 -0
- package/dist/catalogue/orbit.js +91 -0
- package/dist/catalogue/pack.d.ts +193 -0
- package/dist/catalogue/pack.js +327 -0
- package/dist/data/meteor-iau.d.ts +79 -0
- package/dist/data/meteor-iau.js +77 -0
- package/dist/data/meteor-showers.js +24 -20
- package/dist/data-door.d.ts +2 -0
- package/dist/data-door.js +4 -2
- package/dist/door/index.d.ts +1 -0
- package/dist/door/index.js +1 -0
- package/dist/door/packed.d.ts +64 -0
- package/dist/door/packed.js +91 -0
- package/dist/meteors/index.d.ts +2 -0
- package/dist/meteors/index.js +2 -0
- package/dist/meteors/parents.d.ts +45 -0
- package/dist/meteors/parents.js +67 -0
- package/dist/realistic/body-label.d.ts +126 -0
- package/dist/realistic/body-label.js +187 -0
- package/dist/realistic/earth.d.ts +8 -0
- package/dist/realistic/earth.js +29 -0
- package/dist/realistic/element.d.ts +35 -0
- package/dist/realistic/element.js +78 -2
- package/dist/realistic/index.d.ts +1 -0
- package/dist/realistic/index.js +1 -0
- package/dist/realistic/textures.d.ts +8 -0
- package/dist/satellites/source.d.ts +4 -0
- package/dist/satellites/source.js +2 -2
- package/dist/sky/host.d.ts +55 -0
- package/dist/sky/host.js +382 -0
- package/dist/space/element.d.ts +35 -0
- package/dist/space/element.js +78 -2
- package/dist/space/scene.d.ts +8 -0
- package/dist/space/scene.js +34 -0
- package/package.json +12 -2
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// Catalogue records from what a source serves: OMM as JSON or CSV with the fields of Space-Track's GP class (OBJECT_TYPE, COUNTRY_CODE, LAUNCH_DATE, RCS_SIZE) beside the orbital elements. Pure.
|
|
2
|
+
import { cellsOf, toElementSet } from "../satellites/source.js";
|
|
3
|
+
import { readKind } from "./kinds.js";
|
|
4
|
+
/** The radar size a source writes (`SMALL`, `MEDIUM`, `LARGE`, or one letter), or undefined. */
|
|
5
|
+
function readSize(value) {
|
|
6
|
+
const letter = typeof value === "string" ? value.trim().toUpperCase().slice(0, 1) : "";
|
|
7
|
+
return letter === "S" || letter === "M" || letter === "L" ? letter : undefined;
|
|
8
|
+
}
|
|
9
|
+
const text = (value) => (typeof value === "string" ? value.trim() : "");
|
|
10
|
+
/** A launch date as `yyyy-mm-dd`, or the year when only that is given, or "" when the source says nothing usable. */
|
|
11
|
+
function readLaunch(value) {
|
|
12
|
+
const match = /^(\d{4})(?:-(\d\d)-(\d\d))?/.exec(text(value));
|
|
13
|
+
if (!match)
|
|
14
|
+
return "";
|
|
15
|
+
return match[2] ? `${match[1]}-${match[2]}-${match[3]}` : match[1];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Read catalogue records from OMM text, as JSON (a list of objects) or CSV (a header row, then a row for each object). Each row's elements are read as `parseElements` reads them, and `OBJECT_TYPE` (`PAYLOAD`, `ROCKET BODY`, `DEBRIS`,
|
|
19
|
+
* `UNKNOWN`, `TBA`), `COUNTRY_CODE`, `LAUNCH_DATE` and `RCS_SIZE` give the kind, owner, launch and radar size where the row has them. Six-digit and longer catalogue numbers are read as they are: OMM carries them where a TLE cannot.
|
|
20
|
+
* It throws if the text is neither JSON nor CSV with a header.
|
|
21
|
+
*
|
|
22
|
+
* @param input - What the source answered.
|
|
23
|
+
* @returns The records, and the count left out.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* import { readCatalogueRecords } from "@johnmorrisdotca/chikyu-earth/catalogue";
|
|
28
|
+
*
|
|
29
|
+
* const csv = [
|
|
30
|
+
* "OBJECT_NAME,OBJECT_ID,EPOCH,MEAN_MOTION,ECCENTRICITY,INCLINATION,RA_OF_ASC_NODE,ARG_OF_PERICENTER,MEAN_ANOMALY,NORAD_CAT_ID,BSTAR,MEAN_MOTION_DOT,MEAN_MOTION_DDOT,OBJECT_TYPE,COUNTRY_CODE,LAUNCH_DATE,RCS_SIZE",
|
|
31
|
+
* "MADE-UP DEB,2026-002B,2026-11-08T04:12:35,14.9,0.01,82,10,90,20,1000001,0.0001,0.00001,0,DEBRIS,US,2026-02-01,SMALL",
|
|
32
|
+
* ].join("\n");
|
|
33
|
+
* const { records } = readCatalogueRecords(csv);
|
|
34
|
+
* console.log(records[0]?.set.NORAD_CAT_ID, records[0]?.kind, records[0]?.owner, records[0]?.size);
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export function readCatalogueRecords(input) {
|
|
38
|
+
const body = input.replace(/^\uFEFF/, "").trim();
|
|
39
|
+
let rows;
|
|
40
|
+
if (body.startsWith("[") || body.startsWith("{")) {
|
|
41
|
+
let json;
|
|
42
|
+
try {
|
|
43
|
+
json = JSON.parse(body);
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
throw new Error("the text looks like JSON but is not");
|
|
47
|
+
}
|
|
48
|
+
rows = Array.isArray(json) ? json : [json];
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
const lines = body.split(/\r?\n/).filter((line) => line.trim() !== "");
|
|
52
|
+
const header = cellsOf(lines[0] ?? "").map((cell) => cell.trim());
|
|
53
|
+
if (!header.includes("NORAD_CAT_ID") || !header.includes("MEAN_MOTION"))
|
|
54
|
+
throw new Error("the text is not OMM JSON or OMM CSV");
|
|
55
|
+
rows = lines.slice(1).map((line) => Object.fromEntries(cellsOf(line).map((cell, index) => [header[index] ?? `#${index}`, cell])));
|
|
56
|
+
}
|
|
57
|
+
return catalogueRecordsFromRows(rows);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The records in rows already read from JSON: the same as `readCatalogueRecords` without the text step. Not part of the entry point; the refresh script uses it on Space-Track's answer.
|
|
61
|
+
*
|
|
62
|
+
* @param rows - OMM objects with their text or number fields.
|
|
63
|
+
* @returns The records and the count left out.
|
|
64
|
+
*/
|
|
65
|
+
export function catalogueRecordsFromRows(rows) {
|
|
66
|
+
const records = [];
|
|
67
|
+
let skipped = 0;
|
|
68
|
+
for (const row of rows) {
|
|
69
|
+
if (row === null || typeof row !== "object" || Array.isArray(row)) {
|
|
70
|
+
skipped += 1;
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
const fields = row;
|
|
74
|
+
const set = toElementSet(fields);
|
|
75
|
+
if (typeof set === "string") {
|
|
76
|
+
skipped += 1;
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
const record = { set, kind: readKind(text(fields["OBJECT_TYPE"])) };
|
|
80
|
+
const owner = text(fields["COUNTRY_CODE"]);
|
|
81
|
+
const launch = readLaunch(fields["LAUNCH_DATE"]);
|
|
82
|
+
const size = readSize(fields["RCS_SIZE"]);
|
|
83
|
+
if (owner)
|
|
84
|
+
record.owner = owner;
|
|
85
|
+
if (launch)
|
|
86
|
+
record.launch = launch;
|
|
87
|
+
if (size)
|
|
88
|
+
record.size = size;
|
|
89
|
+
records.push(record);
|
|
90
|
+
}
|
|
91
|
+
return { records, skipped };
|
|
92
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { OrbitClass } from "./kinds.ts";
|
|
2
|
+
/**
|
|
3
|
+
* The height of the geostationary orbit above the equator, in kilometres: the radius of a circular orbit that goes round once a sidereal day (42,164 km) less the equatorial radius (6,378 km). The heights in this module are above the mean Earth radius of 6,371 km, which differs by 7 km, well inside the 1,500 km band.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* import { GEO_ALTITUDE_KM } from "@johnmorrisdotca/chikyu-earth/catalogue";
|
|
8
|
+
*
|
|
9
|
+
* console.log(GEO_ALTITUDE_KM);
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export declare const GEO_ALTITUDE_KM = 35786;
|
|
13
|
+
/**
|
|
14
|
+
* The size and shape of an orbit.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* import type { OrbitShape } from "@johnmorrisdotca/chikyu-earth/catalogue";
|
|
19
|
+
*
|
|
20
|
+
* const show = (shape: OrbitShape): string => `${shape.perigeeKm.toFixed(0)} to ${shape.apogeeKm.toFixed(0)} km`;
|
|
21
|
+
* console.log(typeof show);
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export interface OrbitShape {
|
|
25
|
+
/** Half the longest width of the ellipse, kilometres from the Earth's centre. */
|
|
26
|
+
semiMajorKm: number;
|
|
27
|
+
/** One revolution, minutes. */
|
|
28
|
+
periodMinutes: number;
|
|
29
|
+
/** Height of the lowest point above the mean Earth radius (6371 km), kilometres. */
|
|
30
|
+
perigeeKm: number;
|
|
31
|
+
/** Height of the highest point, kilometres. */
|
|
32
|
+
apogeeKm: number;
|
|
33
|
+
eccentricity: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The shape of an orbit from the two numbers every element set has: its mean motion (revolutions a day) by Kepler's third law, and its eccentricity. Heights are above the mean Earth radius (6371 km), the same as the satellites' own readout.
|
|
37
|
+
*
|
|
38
|
+
* @param meanMotion - Revolutions a day, above 0.
|
|
39
|
+
* @param eccentricity - 0 up to (not including) 1.
|
|
40
|
+
* @returns The shape; `null` for a mean motion or an eccentricity that is not an orbit.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```ts
|
|
44
|
+
* import { orbitShape } from "@johnmorrisdotca/chikyu-earth/catalogue";
|
|
45
|
+
*
|
|
46
|
+
* const iss = orbitShape(15.4915, 0.0007139);
|
|
47
|
+
* console.log(iss && Math.round(iss.perigeeKm), iss && Math.round(iss.periodMinutes), orbitShape(0, 0));
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export declare function orbitShape(meanMotion: number, eccentricity: number): OrbitShape | null;
|
|
51
|
+
/**
|
|
52
|
+
* The numbers behind the classes: the highest point a low orbit may have (2,000 km), the eccentricity from which an orbit is highly elliptical (0.25), and how far from 35,786 km the lowest and highest points of a geostationary orbit may be (1,500 km).
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```ts
|
|
56
|
+
* import { CLASS_LIMITS } from "@johnmorrisdotca/chikyu-earth/catalogue";
|
|
57
|
+
*
|
|
58
|
+
* console.log(CLASS_LIMITS.leoApogeeKm, CLASS_LIMITS.heoEccentricity, CLASS_LIMITS.geoBandKm);
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export declare const CLASS_LIMITS: {
|
|
62
|
+
readonly leoApogeeKm: 2000;
|
|
63
|
+
readonly heoEccentricity: 0.25;
|
|
64
|
+
readonly geoBandKm: 1500;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* The class an orbit falls in. `heo` when the eccentricity is 0.25 or more; otherwise `leo` when the highest point is under 2,000 km, `geo` when both points are within 1,500 km of 35,786 km, `meo` when the lowest point is 2,000 km or more and the highest is under that band, and `other` for what is left (above the geostationary belt, or between the classes).
|
|
68
|
+
*
|
|
69
|
+
* @param shape - The orbit's shape, from `orbitShape`.
|
|
70
|
+
* @returns The class.
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```ts
|
|
74
|
+
* import { orbitClass, orbitShape } from "@johnmorrisdotca/chikyu-earth/catalogue";
|
|
75
|
+
*
|
|
76
|
+
* const of = (n: number, e: number): string => orbitClass(orbitShape(n, e)!);
|
|
77
|
+
* console.log(of(15.49, 0.0007), of(2.0056, 0.0001), of(1.0027, 0.0002), of(2.0, 0.72), of(0.9, 0.001));
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
export declare function orbitClass(shape: OrbitShape): OrbitClass;
|
|
81
|
+
/**
|
|
82
|
+
* The class of an orbit straight from the two numbers every element set has, its mean motion (revolutions a day) and its eccentricity; `null` when they are not an orbit.
|
|
83
|
+
*
|
|
84
|
+
* @param meanMotion - Revolutions a day, above 0.
|
|
85
|
+
* @param eccentricity - 0 up to (not including) 1.
|
|
86
|
+
* @returns The class, or `null`.
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```ts
|
|
90
|
+
* import { classOfElements } from "@johnmorrisdotca/chikyu-earth/catalogue";
|
|
91
|
+
*
|
|
92
|
+
* console.log(classOfElements(15.49, 0.0007), classOfElements(1.0027, 0.0002), classOfElements(0, 0));
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
export declare function classOfElements(meanMotion: number, eccentricity: number): OrbitClass | null;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
const MU = 398_600.4418;
|
|
2
|
+
const EARTH_RADIUS_KM = 6371;
|
|
3
|
+
/**
|
|
4
|
+
* The height of the geostationary orbit above the equator, in kilometres: the radius of a circular orbit that goes round once a sidereal day (42,164 km) less the equatorial radius (6,378 km). The heights in this module are above the mean Earth radius of 6,371 km, which differs by 7 km, well inside the 1,500 km band.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { GEO_ALTITUDE_KM } from "@johnmorrisdotca/chikyu-earth/catalogue";
|
|
9
|
+
*
|
|
10
|
+
* console.log(GEO_ALTITUDE_KM);
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export const GEO_ALTITUDE_KM = 35_786;
|
|
14
|
+
/**
|
|
15
|
+
* The shape of an orbit from the two numbers every element set has: its mean motion (revolutions a day) by Kepler's third law, and its eccentricity. Heights are above the mean Earth radius (6371 km), the same as the satellites' own readout.
|
|
16
|
+
*
|
|
17
|
+
* @param meanMotion - Revolutions a day, above 0.
|
|
18
|
+
* @param eccentricity - 0 up to (not including) 1.
|
|
19
|
+
* @returns The shape; `null` for a mean motion or an eccentricity that is not an orbit.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* import { orbitShape } from "@johnmorrisdotca/chikyu-earth/catalogue";
|
|
24
|
+
*
|
|
25
|
+
* const iss = orbitShape(15.4915, 0.0007139);
|
|
26
|
+
* console.log(iss && Math.round(iss.perigeeKm), iss && Math.round(iss.periodMinutes), orbitShape(0, 0));
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export function orbitShape(meanMotion, eccentricity) {
|
|
30
|
+
if (!(meanMotion > 0) || !(eccentricity >= 0) || !(eccentricity < 1) || !Number.isFinite(meanMotion))
|
|
31
|
+
return null;
|
|
32
|
+
const n = (meanMotion * 2 * Math.PI) / 86_400;
|
|
33
|
+
const a = Math.cbrt(MU / (n * n));
|
|
34
|
+
return { semiMajorKm: a, periodMinutes: 1440 / meanMotion, perigeeKm: a * (1 - eccentricity) - EARTH_RADIUS_KM, apogeeKm: a * (1 + eccentricity) - EARTH_RADIUS_KM, eccentricity };
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The numbers behind the classes: the highest point a low orbit may have (2,000 km), the eccentricity from which an orbit is highly elliptical (0.25), and how far from 35,786 km the lowest and highest points of a geostationary orbit may be (1,500 km).
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* import { CLASS_LIMITS } from "@johnmorrisdotca/chikyu-earth/catalogue";
|
|
42
|
+
*
|
|
43
|
+
* console.log(CLASS_LIMITS.leoApogeeKm, CLASS_LIMITS.heoEccentricity, CLASS_LIMITS.geoBandKm);
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export const CLASS_LIMITS = { leoApogeeKm: 2_000, heoEccentricity: 0.25, geoBandKm: 1_500 };
|
|
47
|
+
/**
|
|
48
|
+
* The class an orbit falls in. `heo` when the eccentricity is 0.25 or more; otherwise `leo` when the highest point is under 2,000 km, `geo` when both points are within 1,500 km of 35,786 km, `meo` when the lowest point is 2,000 km or more and the highest is under that band, and `other` for what is left (above the geostationary belt, or between the classes).
|
|
49
|
+
*
|
|
50
|
+
* @param shape - The orbit's shape, from `orbitShape`.
|
|
51
|
+
* @returns The class.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```ts
|
|
55
|
+
* import { orbitClass, orbitShape } from "@johnmorrisdotca/chikyu-earth/catalogue";
|
|
56
|
+
*
|
|
57
|
+
* const of = (n: number, e: number): string => orbitClass(orbitShape(n, e)!);
|
|
58
|
+
* console.log(of(15.49, 0.0007), of(2.0056, 0.0001), of(1.0027, 0.0002), of(2.0, 0.72), of(0.9, 0.001));
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export function orbitClass(shape) {
|
|
62
|
+
if (shape.eccentricity >= CLASS_LIMITS.heoEccentricity)
|
|
63
|
+
return "heo";
|
|
64
|
+
if (shape.apogeeKm < CLASS_LIMITS.leoApogeeKm)
|
|
65
|
+
return "leo";
|
|
66
|
+
const low = GEO_ALTITUDE_KM - CLASS_LIMITS.geoBandKm;
|
|
67
|
+
const high = GEO_ALTITUDE_KM + CLASS_LIMITS.geoBandKm;
|
|
68
|
+
if (shape.perigeeKm >= low && shape.apogeeKm <= high)
|
|
69
|
+
return "geo";
|
|
70
|
+
if (shape.perigeeKm >= CLASS_LIMITS.leoApogeeKm && shape.apogeeKm < low)
|
|
71
|
+
return "meo";
|
|
72
|
+
return "other";
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* The class of an orbit straight from the two numbers every element set has, its mean motion (revolutions a day) and its eccentricity; `null` when they are not an orbit.
|
|
76
|
+
*
|
|
77
|
+
* @param meanMotion - Revolutions a day, above 0.
|
|
78
|
+
* @param eccentricity - 0 up to (not including) 1.
|
|
79
|
+
* @returns The class, or `null`.
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```ts
|
|
83
|
+
* import { classOfElements } from "@johnmorrisdotca/chikyu-earth/catalogue";
|
|
84
|
+
*
|
|
85
|
+
* console.log(classOfElements(15.49, 0.0007), classOfElements(1.0027, 0.0002), classOfElements(0, 0));
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
export function classOfElements(meanMotion, eccentricity) {
|
|
89
|
+
const shape = orbitShape(meanMotion, eccentricity);
|
|
90
|
+
return shape ? orbitClass(shape) : null;
|
|
91
|
+
}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import type { ElementSet } from "../satellites/types.ts";
|
|
2
|
+
import type { ObjectKind } from "./kinds.ts";
|
|
3
|
+
/**
|
|
4
|
+
* The radar size class Space-Track gives an object: small (under 0.1 square metres), medium or large (over 1).
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* import type { RadarSize } from "@johnmorrisdotca/chikyu-earth/catalogue";
|
|
9
|
+
*
|
|
10
|
+
* const size: RadarSize = "L";
|
|
11
|
+
* console.log(size);
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export type RadarSize = "S" | "M" | "L";
|
|
15
|
+
/**
|
|
16
|
+
* One object of the catalogue: its element set (the OMM numbers every source serves), what kind of object it is, and what the catalogue says of its owner and launch. Anything the catalogue leaves blank is left out, never guessed.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* import type { CatalogueRecord } from "@johnmorrisdotca/chikyu-earth/catalogue";
|
|
21
|
+
*
|
|
22
|
+
* const record: CatalogueRecord = {
|
|
23
|
+
* 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: 900001, BSTAR: 0.0001, MEAN_MOTION_DOT: 0.00001, MEAN_MOTION_DDOT: 0 },
|
|
24
|
+
* kind: "PAY",
|
|
25
|
+
* owner: "US",
|
|
26
|
+
* launch: "2026-01-05",
|
|
27
|
+
* };
|
|
28
|
+
* console.log(record.set.NORAD_CAT_ID, record.kind);
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export interface CatalogueRecord {
|
|
32
|
+
set: ElementSet;
|
|
33
|
+
kind: ObjectKind;
|
|
34
|
+
/** The owner's country or organisation code, as the catalogue writes it ("US", "PRC", "CIS"), up to 8 characters. */
|
|
35
|
+
owner?: string;
|
|
36
|
+
/** The launch date, `yyyy-mm-dd`, or just the year. */
|
|
37
|
+
launch?: string;
|
|
38
|
+
size?: RadarSize;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The most records one packed file holds: the data door's own limit, 200,000.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
* import { MAX_PACKED } from "@johnmorrisdotca/chikyu-earth/catalogue";
|
|
46
|
+
*
|
|
47
|
+
* console.log(MAX_PACKED);
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export declare const MAX_PACKED = 200000;
|
|
51
|
+
/**
|
|
52
|
+
* The most bytes a packed file may unpack to (64 MB): a file that claims more is refused before it is read.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```ts
|
|
56
|
+
* import { MAX_PACKED_BYTES } from "@johnmorrisdotca/chikyu-earth/catalogue";
|
|
57
|
+
*
|
|
58
|
+
* console.log(MAX_PACKED_BYTES / 1_048_576);
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export declare const MAX_PACKED_BYTES: number;
|
|
62
|
+
/**
|
|
63
|
+
* A packed file that cannot be read: it is not a packed file, it is cut short, it holds more than `MAX_PACKED` records, or it unpacks to more than `MAX_PACKED_BYTES`.
|
|
64
|
+
*
|
|
65
|
+
* @param message - What is wrong with the file, in a sentence.
|
|
66
|
+
* @example
|
|
67
|
+
* ```ts
|
|
68
|
+
* import { PackError, unpackCatalogue } from "@johnmorrisdotca/chikyu-earth/catalogue";
|
|
69
|
+
*
|
|
70
|
+
* try {
|
|
71
|
+
* unpackCatalogue(new Uint8Array(4));
|
|
72
|
+
* } catch (error) {
|
|
73
|
+
* console.log(error instanceof PackError);
|
|
74
|
+
* }
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
export declare class PackError extends Error {
|
|
78
|
+
constructor(message: string);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* 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.
|
|
82
|
+
* 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).
|
|
83
|
+
* 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`.
|
|
84
|
+
*
|
|
85
|
+
* @param records - The records, in the order the file keeps them (at most `MAX_PACKED`).
|
|
86
|
+
* @param meta - Words to keep with the file (read back as `meta`).
|
|
87
|
+
* @returns The bytes. Gzip them with `gzipBytes` for a file a site hosts.
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```ts
|
|
91
|
+
* import { packCatalogue, unpackCatalogue, type CatalogueRecord } from "@johnmorrisdotca/chikyu-earth/catalogue";
|
|
92
|
+
*
|
|
93
|
+
* const record: CatalogueRecord = {
|
|
94
|
+
* 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 },
|
|
95
|
+
* kind: "DEB",
|
|
96
|
+
* };
|
|
97
|
+
* const bytes = packCatalogue([record], { group: "debris" });
|
|
98
|
+
* const back = unpackCatalogue(bytes);
|
|
99
|
+
* console.log(bytes.length, back.count, back.setAt(0).NORAD_CAT_ID, back.meta["group"]);
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
export declare function packCatalogue(records: readonly CatalogueRecord[], meta?: Readonly<Record<string, string>>): Uint8Array;
|
|
103
|
+
/**
|
|
104
|
+
* A packed file, read: the columns as typed arrays (nothing is copied into objects until you ask) and the names.
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```ts
|
|
108
|
+
* import { packCatalogue, unpackCatalogue, type PackedCatalogue } from "@johnmorrisdotca/chikyu-earth/catalogue";
|
|
109
|
+
*
|
|
110
|
+
* const empty: PackedCatalogue = unpackCatalogue(packCatalogue([], { group: "none" }));
|
|
111
|
+
* console.log(empty.count, empty.sets().length);
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
export interface PackedCatalogue {
|
|
115
|
+
/** The words kept with the file. */
|
|
116
|
+
meta: Readonly<Record<string, string>>;
|
|
117
|
+
count: number;
|
|
118
|
+
/** The catalogue numbers, 32-bit. */
|
|
119
|
+
norad: Uint32Array;
|
|
120
|
+
/** Mean motion, revolutions a day. */
|
|
121
|
+
meanMotion: Float64Array;
|
|
122
|
+
eccentricity: Float32Array;
|
|
123
|
+
/** Degrees. */
|
|
124
|
+
inclination: Float32Array;
|
|
125
|
+
/** Degrees. */
|
|
126
|
+
raan: Float32Array;
|
|
127
|
+
/** Degrees. */
|
|
128
|
+
argPerigee: Float32Array;
|
|
129
|
+
/** Degrees. */
|
|
130
|
+
meanAnomaly: Float32Array;
|
|
131
|
+
/** Index into `OBJECT_KINDS`: 0 payload, 1 rocket body, 2 debris, 3 unknown. */
|
|
132
|
+
kind: Uint8Array;
|
|
133
|
+
/** The epoch of record `i`, milliseconds since 1970 (the file keeps microseconds). */
|
|
134
|
+
epochMs(i: number): number;
|
|
135
|
+
/** The kind of record `i`. */
|
|
136
|
+
kindAt(i: number): ObjectKind;
|
|
137
|
+
/** The name of record `i`. */
|
|
138
|
+
nameAt(i: number): string;
|
|
139
|
+
/** Record `i` as an element set the satellites code reads. */
|
|
140
|
+
setAt(i: number): ElementSet;
|
|
141
|
+
/** Record `i` with what the catalogue says of it. */
|
|
142
|
+
recordAt(i: number): CatalogueRecord;
|
|
143
|
+
/** Every record as an element set. */
|
|
144
|
+
sets(): ElementSet[];
|
|
145
|
+
/** Every record. */
|
|
146
|
+
records(): CatalogueRecord[];
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Read a packed file (not gzipped: see `unpackAny`). The header is checked against the length, so a cut or wrong file is a `PackError` and never a wrong number; a file of more than `MAX_PACKED` records is refused.
|
|
150
|
+
*
|
|
151
|
+
* @param bytes - What `packCatalogue` made.
|
|
152
|
+
* @returns The records, by column.
|
|
153
|
+
*
|
|
154
|
+
* @example
|
|
155
|
+
* ```ts
|
|
156
|
+
* import { packCatalogue, unpackCatalogue } from "@johnmorrisdotca/chikyu-earth/catalogue";
|
|
157
|
+
*
|
|
158
|
+
* const set = { OBJECT_NAME: "MADE-UP 2", EPOCH: "2026-11-08T00:00:00", MEAN_MOTION: 14.1, ECCENTRICITY: 0.001, INCLINATION: 98, RA_OF_ASC_NODE: 1, ARG_OF_PERICENTER: 2, MEAN_ANOMALY: 3, NORAD_CAT_ID: 123_456, BSTAR: 0, MEAN_MOTION_DOT: 0, MEAN_MOTION_DDOT: 0 };
|
|
159
|
+
* const file = unpackCatalogue(packCatalogue([{ set, kind: "RB", size: "M" }]));
|
|
160
|
+
* console.log(file.nameAt(0), file.kindAt(0), file.norad[0], file.recordAt(0).size);
|
|
161
|
+
* ```
|
|
162
|
+
*/
|
|
163
|
+
export declare function unpackCatalogue(bytes: Uint8Array): PackedCatalogue;
|
|
164
|
+
/**
|
|
165
|
+
* Gzip bytes, with the web's own `CompressionStream`: the form a site hosts a packed file in.
|
|
166
|
+
*
|
|
167
|
+
* @param bytes - What `packCatalogue` made.
|
|
168
|
+
* @returns The gzipped bytes.
|
|
169
|
+
*
|
|
170
|
+
* @example
|
|
171
|
+
* ```ts
|
|
172
|
+
* import { gzipBytes } from "@johnmorrisdotca/chikyu-earth/catalogue";
|
|
173
|
+
*
|
|
174
|
+
* const small = await gzipBytes(new Uint8Array(10_000));
|
|
175
|
+
* console.log(small.length < 100, small[0], small[1]);
|
|
176
|
+
* ```
|
|
177
|
+
*/
|
|
178
|
+
export declare function gzipBytes(bytes: Uint8Array): Promise<Uint8Array>;
|
|
179
|
+
/**
|
|
180
|
+
* Read a packed file whether or not it is gzipped (gzip is found from its first two bytes). The unpacked size is capped at `MAX_PACKED_BYTES`, so a small file that unpacks to a huge one is refused.
|
|
181
|
+
*
|
|
182
|
+
* @param bytes - A packed file, or a gzipped one.
|
|
183
|
+
* @returns The records, by column.
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* ```ts
|
|
187
|
+
* import { gzipBytes, packCatalogue, unpackAny } from "@johnmorrisdotca/chikyu-earth/catalogue";
|
|
188
|
+
*
|
|
189
|
+
* const file = await unpackAny(await gzipBytes(packCatalogue([], { group: "empty" })));
|
|
190
|
+
* console.log(file.count, file.meta["group"]);
|
|
191
|
+
* ```
|
|
192
|
+
*/
|
|
193
|
+
export declare function unpackAny(bytes: Uint8Array): Promise<PackedCatalogue>;
|