@johnmorrisdotca/chikyu-earth 0.35.0 → 0.37.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 +21 -0
- package/NOTICE.md +27 -1
- package/README.md +20 -2
- package/dist/borders/layer.d.ts +75 -0
- package/dist/borders/layer.js +136 -0
- package/dist/borders/lines.d.ts +138 -0
- package/dist/borders/lines.js +227 -0
- package/dist/catalogue/index.d.ts +1 -0
- package/dist/catalogue/index.js +3 -2
- package/dist/catalogue/pack.js +3 -0
- package/dist/cities/host.d.ts +9 -0
- package/dist/cities/host.js +51 -9
- package/dist/country-names/geometry.d.ts +264 -0
- package/dist/country-names/geometry.js +372 -0
- package/dist/country-names/host.d.ts +82 -0
- package/dist/country-names/host.js +212 -0
- package/dist/grid/layer.d.ts +45 -0
- package/dist/grid/layer.js +66 -0
- package/dist/grid/lines.d.ts +85 -0
- package/dist/grid/lines.js +113 -0
- package/dist/markers/go-to-place.d.ts +27 -0
- package/dist/markers/go-to-place.js +35 -0
- package/dist/markers/index.d.ts +2 -1
- package/dist/markers/index.js +2 -1
- package/dist/markers/layer.d.ts +7 -0
- package/dist/markers/layer.js +7 -0
- package/dist/markers/place-layer.d.ts +58 -7
- package/dist/markers/place-layer.js +326 -64
- package/dist/markers/place-sprites.d.ts +33 -0
- package/dist/markers/place-sprites.js +161 -0
- package/dist/markers/places.d.ts +91 -6
- package/dist/markers/places.js +135 -6
- package/dist/realistic/earth.d.ts +11 -0
- package/dist/realistic/earth.js +55 -1
- package/dist/realistic/element.d.ts +75 -6
- package/dist/realistic/element.js +221 -33
- package/dist/realistic/immersive.d.ts +7 -0
- package/dist/realistic/immersive.js +17 -0
- package/dist/realistic/index.d.ts +6 -0
- package/dist/realistic/index.js +3 -0
- package/dist/realistic/textures.d.ts +5 -0
- package/dist/satellites/index.d.ts +1 -0
- package/dist/satellites/index.js +1 -0
- package/dist/satellites/limits.d.ts +1 -1
- package/dist/satellites/limits.js +1 -1
- package/dist/satellites/owners.d.ts +26 -0
- package/dist/satellites/owners.js +164 -0
- package/dist/satellites/source.js +3 -0
- package/dist/satellites/track.d.ts +5 -0
- package/dist/satellites/track.js +128 -0
- package/dist/satellites/types.d.ts +19 -1
- package/dist/space/element.d.ts +111 -12
- package/dist/space/element.js +360 -26
- package/dist/space/index.d.ts +2 -2
- package/dist/space/index.js +1 -1
- package/dist/space/ride.d.ts +42 -0
- package/dist/space/ride.js +45 -3
- package/dist/space/satellite-layer.d.ts +8 -2
- package/dist/space/satellite-layer.js +138 -19
- package/dist/space/scene.d.ts +56 -6
- package/dist/space/scene.js +97 -15
- package/package.json +3 -3
|
@@ -12,3 +12,9 @@ export type { SkyLabelStyle } from "../sky/style.ts";
|
|
|
12
12
|
export type { SkyKeepClear } from "../sky/keep-clear.ts";
|
|
13
13
|
export { CITY_NAMES_DEFAULT, CITY_NAMES_MAX, TIER_RADIUS, cityNameText, cityRank, cityTiersFor, layoutCities, nameWidth, readCityNames, type CityFrame, type CityLayoutOptions, type CityName, type CityNameTier, type NamedCity } from "../cities/geometry.ts";
|
|
14
14
|
export { CITY_NAMES_ATTRIBUTES, type CityNamesStyle } from "../cities/host.ts";
|
|
15
|
+
export { BORDER_ATTRIBUTES, BORDER_REGIONS_RADIUS, codesNear, readBorders, shapeBoxes, sharedEdges, type BorderFeature, type BorderSets, type BorderShapes } from "../borders/lines.ts";
|
|
16
|
+
export type { BorderData, BorderStats } from "../borders/layer.ts";
|
|
17
|
+
export { EARTH_TILT, GRID_ATTRIBUTES, GRID_FINE_RADIUS, gridLines, readGrid, type GridLines } from "../grid/lines.ts";
|
|
18
|
+
export type { GridStats } from "../grid/layer.ts";
|
|
19
|
+
export { COUNTRY_LETTER_SPACING, COUNTRY_NAMES_ATTRIBUTES, COUNTRY_NAMES_DEFAULT, COUNTRY_NAMES_MAX, countryNameBox, countryNameText, countrySpots, layoutCountryNames, readCountryNames, type CountryFrame, type CountryLayoutOptions, type CountryName, type CountrySpots, type NamedShape } from "../country-names/geometry.ts";
|
|
20
|
+
export type { CountryNamesStats, CountryNamesStyle } from "../country-names/host.ts";
|
package/dist/realistic/index.js
CHANGED
|
@@ -11,3 +11,6 @@ export { AIR_QUALITY, AIR_THICKNESS_DEFAULT, AIR_THICKNESS_MAX, AIR_TOP, AIR_VER
|
|
|
11
11
|
export { AIR_NOTE } from "./air-note.js";
|
|
12
12
|
export { CITY_NAMES_DEFAULT, CITY_NAMES_MAX, TIER_RADIUS, cityNameText, cityRank, cityTiersFor, layoutCities, nameWidth, readCityNames } from "../cities/geometry.js";
|
|
13
13
|
export { CITY_NAMES_ATTRIBUTES } from "../cities/host.js";
|
|
14
|
+
export { BORDER_ATTRIBUTES, BORDER_REGIONS_RADIUS, codesNear, readBorders, shapeBoxes, sharedEdges } from "../borders/lines.js";
|
|
15
|
+
export { EARTH_TILT, GRID_ATTRIBUTES, GRID_FINE_RADIUS, gridLines, readGrid } from "../grid/lines.js";
|
|
16
|
+
export { COUNTRY_LETTER_SPACING, COUNTRY_NAMES_ATTRIBUTES, COUNTRY_NAMES_DEFAULT, COUNTRY_NAMES_MAX, countryNameBox, countryNameText, countrySpots, layoutCountryNames, readCountryNames } from "../country-names/geometry.js";
|
|
@@ -17,6 +17,8 @@ export type ThreeParts = {
|
|
|
17
17
|
} & {
|
|
18
18
|
/** Only the satellites use it, so a loader that hands over a subset of three.js without it still draws everything else. */
|
|
19
19
|
Points?: typeof THREE.Points;
|
|
20
|
+
/** Only the satellites above 60 times real time use it, for their streaks: without it they are dots alone there, and one warning is written to the console. */
|
|
21
|
+
LineSegments?: typeof THREE.LineSegments;
|
|
20
22
|
} & {
|
|
21
23
|
/** Only the name written on the Earth (`body-label`) uses these, so a subset of three.js without them still draws everything else. */
|
|
22
24
|
CanvasTexture?: typeof THREE.CanvasTexture;
|
|
@@ -25,6 +27,9 @@ export type ThreeParts = {
|
|
|
25
27
|
SRGBColorSpace?: typeof THREE.SRGBColorSpace;
|
|
26
28
|
NormalBlending?: typeof THREE.NormalBlending;
|
|
27
29
|
AdditiveBlending?: typeof THREE.AdditiveBlending;
|
|
30
|
+
} & {
|
|
31
|
+
/** Only the borders (`borders`) use it, so a subset of three.js without it still draws everything else. */
|
|
32
|
+
LineSegments?: typeof THREE.LineSegments;
|
|
28
33
|
};
|
|
29
34
|
/** Milliseconds a lower texture size must be enough before the larger one is let go. */
|
|
30
35
|
export declare const DOWNGRADE_AFTER_MS = 4000;
|
|
@@ -2,6 +2,7 @@ export { createSatellites, type SatellitesOptions } from "./track.ts";
|
|
|
2
2
|
export { DEFAULT_DIM_AFTER_DAYS, DEFAULT_MAX_AGE_DAYS, MAX_SATELLITE_SPEED } from "./limits.ts";
|
|
3
3
|
export type { ElementSet, RefusedElementSet, SatelliteInfo, SatelliteRef, Satellites } from "./types.ts";
|
|
4
4
|
export { SHORT_NAMES } from "./names.ts";
|
|
5
|
+
export { OWNER_COUNTRIES, ownerCountry } from "./owners.ts";
|
|
5
6
|
export { CATALOGUE, SATELLITE_GROUPS, catalogueEntry, findInCatalogue, type CatalogueEntry, type OrbitKind, type SatelliteGroupInfo } from "./catalogue.ts";
|
|
6
7
|
export { ElementSourceError, fetchElements, forgetElements, parseElements, type ElementFormat, type ElementSource, type FetchElementsOptions, type ParsedElements } from "./source.ts";
|
|
7
8
|
export { missionElements, missionOf, missionPosition, missions, type HubbleVisit, type Mission, type MissionFile, type MissionPosition, type Orbiter } from "./missions.ts";
|
package/dist/satellites/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
export { createSatellites } from "./track.js";
|
|
3
3
|
export { DEFAULT_DIM_AFTER_DAYS, DEFAULT_MAX_AGE_DAYS, MAX_SATELLITE_SPEED } from "./limits.js";
|
|
4
4
|
export { SHORT_NAMES } from "./names.js";
|
|
5
|
+
export { OWNER_COUNTRIES, ownerCountry } from "./owners.js";
|
|
5
6
|
export { CATALOGUE, SATELLITE_GROUPS, catalogueEntry, findInCatalogue } from "./catalogue.js";
|
|
6
7
|
export { ElementSourceError, fetchElements, forgetElements, parseElements } from "./source.js";
|
|
7
8
|
export { missionElements, missionOf, missionPosition, missions } from "./missions.js";
|
|
@@ -21,7 +21,7 @@ export declare const DEFAULT_MAX_AGE_DAYS = 30;
|
|
|
21
21
|
*/
|
|
22
22
|
export declare const DEFAULT_DIM_AFTER_DAYS = 14;
|
|
23
23
|
/**
|
|
24
|
-
* The fastest clock, in game seconds a second, at which
|
|
24
|
+
* The fastest clock, in game seconds a second, at which a group of satellites is still placed by interpolating two SGP4 samples. Above it those two moments would be too far apart, so each satellite is drawn as a short streak along its orbit instead: one SGP4 sample about once a second, turned along the orbit by its mean motion, covering the stretch one frame spans. Nothing is hidden. A satellite chosen with `selectSatellite` or ridden along is still placed exactly, one SGP4 call a frame.
|
|
25
25
|
*
|
|
26
26
|
* @example
|
|
27
27
|
* ```ts
|
|
@@ -22,7 +22,7 @@ export const DEFAULT_MAX_AGE_DAYS = 30;
|
|
|
22
22
|
*/
|
|
23
23
|
export const DEFAULT_DIM_AFTER_DAYS = 14;
|
|
24
24
|
/**
|
|
25
|
-
* The fastest clock, in game seconds a second, at which
|
|
25
|
+
* The fastest clock, in game seconds a second, at which a group of satellites is still placed by interpolating two SGP4 samples. Above it those two moments would be too far apart, so each satellite is drawn as a short streak along its orbit instead: one SGP4 sample about once a second, turned along the orbit by its mean motion, covering the stretch one frame spans. Nothing is hidden. A satellite chosen with `selectSatellite` or ridden along is still placed exactly, one SGP4 call a frame.
|
|
26
26
|
*
|
|
27
27
|
* @example
|
|
28
28
|
* ```ts
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every owner code of the satellite catalogue with its country as an ISO 3166-1 alpha-2 code, or `null` where the owner is not one country: an organisation (`ESA`, `ISS`, `ITSO`, `SES`, `GLOB`, ...),
|
|
3
|
+
* several countries (`FGER`, France and Germany; `PRES`, China and ESA), not known (`UNK`, `TBD`), or not one country (`CIS`, the former Soviet registration). `ISRO`, India's space agency, is `IN`.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* import { OWNER_COUNTRIES } from "@johnmorrisdotca/chikyu-earth/satellites";
|
|
8
|
+
*
|
|
9
|
+
* console.log(OWNER_COUNTRIES["PRC"], OWNER_COUNTRIES["ESA"], Object.keys(OWNER_COUNTRIES).length);
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export declare const OWNER_COUNTRIES: Readonly<Record<string, string | null>>;
|
|
13
|
+
/**
|
|
14
|
+
* The country of a satellite's owner code as an ISO 3166-1 alpha-2 code (`PRC` is `CN`, `PAKI` is `PK`, `US` is `US`), or `undefined` for an organisation, several countries, an ambiguous owner or a code that is not in the list.
|
|
15
|
+
*
|
|
16
|
+
* @param code - The owner code as the catalogue writes it (`COUNTRY_CODE` or `OWNER`): case and spaces round it do not matter.
|
|
17
|
+
* @returns The two-letter country code, or `undefined`.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* import { ownerCountry } from "@johnmorrisdotca/chikyu-earth/satellites";
|
|
22
|
+
*
|
|
23
|
+
* console.log(ownerCountry("PRC"), ownerCountry("PAKI"), ownerCountry("ESA"), ownerCountry("XYZ"));
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare function ownerCountry(code: string | null | undefined): string | undefined;
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
// The owner codes of the satellite catalogue and the country each stands for, as an ISO 3166-1 alpha-2 code, for a page that shows a flag or a country beside a satellite.
|
|
2
|
+
// Typed from the catalogue's published list of owner sources, read 2026-11-12 (credited in NOTICE.md): a code, and what it stands for. Pure data: no flag, no name.
|
|
3
|
+
/**
|
|
4
|
+
* Every owner code of the satellite catalogue with its country as an ISO 3166-1 alpha-2 code, or `null` where the owner is not one country: an organisation (`ESA`, `ISS`, `ITSO`, `SES`, `GLOB`, ...),
|
|
5
|
+
* several countries (`FGER`, France and Germany; `PRES`, China and ESA), not known (`UNK`, `TBD`), or not one country (`CIS`, the former Soviet registration). `ISRO`, India's space agency, is `IN`.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { OWNER_COUNTRIES } from "@johnmorrisdotca/chikyu-earth/satellites";
|
|
10
|
+
*
|
|
11
|
+
* console.log(OWNER_COUNTRIES["PRC"], OWNER_COUNTRIES["ESA"], Object.keys(OWNER_COUNTRIES).length);
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export const OWNER_COUNTRIES = {
|
|
15
|
+
AB: null, // Arab Satellite Communications Organization
|
|
16
|
+
ABS: null, // Asia Broadcast Satellite
|
|
17
|
+
AC: null, // Asia Satellite Telecommunications Company (ASIASAT)
|
|
18
|
+
ALG: "DZ", // Algeria
|
|
19
|
+
ANG: "AO", // Angola
|
|
20
|
+
ARGN: "AR", // Argentina
|
|
21
|
+
ARM: "AM", // Republic of Armenia
|
|
22
|
+
ASRA: "AT", // Austria
|
|
23
|
+
AUS: "AU", // Australia
|
|
24
|
+
AZER: "AZ", // Azerbaijan
|
|
25
|
+
BEL: "BE", // Belgium
|
|
26
|
+
BELA: "BY", // Belarus
|
|
27
|
+
BERM: "BM", // Bermuda
|
|
28
|
+
BGD: "BD", // Peoples Republic of Bangladesh
|
|
29
|
+
BHR: "BH", // The Kingdom of Bahrain
|
|
30
|
+
BHUT: "BT", // The Kingdom of Bhutan
|
|
31
|
+
BOL: "BO", // Bolivia
|
|
32
|
+
BRAZ: "BR", // Brazil
|
|
33
|
+
BUL: "BG", // Bulgaria
|
|
34
|
+
BWA: "BW", // Republic of Botswana
|
|
35
|
+
CA: "CA", // Canada
|
|
36
|
+
CHBZ: null, // China/Brazil
|
|
37
|
+
CHTU: null, // China/Türkiye
|
|
38
|
+
CHLE: "CL", // Chile
|
|
39
|
+
CIS: null, // Commonwealth of Independent States (former USSR): the list names no one country, so none
|
|
40
|
+
COL: "CO", // Colombia
|
|
41
|
+
CRI: "CR", // Republic of Costa Rica
|
|
42
|
+
CZCH: "CZ", // Czech Republic (former Czechoslovakia)
|
|
43
|
+
DEN: "DK", // Denmark
|
|
44
|
+
DJI: "DJ", // Republic of Djibouti
|
|
45
|
+
ECU: "EC", // Ecuador
|
|
46
|
+
EGYP: "EG", // Egypt
|
|
47
|
+
ESA: null, // European Space Agency
|
|
48
|
+
ESRO: null, // European Space Research Organization
|
|
49
|
+
EST: "EE", // Estonia
|
|
50
|
+
ETH: "ET", // Ethiopia
|
|
51
|
+
EUME: null, // European Organization for the Exploitation of Meteorological Satellites (EUMETSAT)
|
|
52
|
+
EUTE: null, // European Telecommunications Satellite Organization (EUTELSAT)
|
|
53
|
+
FGER: null, // France/Germany
|
|
54
|
+
FIN: "FI", // Finland
|
|
55
|
+
FR: "FR", // France
|
|
56
|
+
FRIT: null, // France/Italy
|
|
57
|
+
GER: "DE", // Germany
|
|
58
|
+
GHA: "GH", // Republic of Ghana
|
|
59
|
+
GLOB: null, // Globalstar
|
|
60
|
+
GREC: "GR", // Greece
|
|
61
|
+
GRSA: null, // Greece/Saudi Arabia
|
|
62
|
+
GUAT: "GT", // Guatemala
|
|
63
|
+
HRV: "HR", // Republic of Croatia
|
|
64
|
+
HUN: "HU", // Hungary
|
|
65
|
+
IM: null, // International Mobile Satellite Organization (INMARSAT)
|
|
66
|
+
IND: "IN", // India
|
|
67
|
+
INDO: "ID", // Indonesia
|
|
68
|
+
IRAN: "IR", // Iran
|
|
69
|
+
IRAQ: "IQ", // Iraq
|
|
70
|
+
IRID: null, // Iridium
|
|
71
|
+
IRL: "IE", // Ireland
|
|
72
|
+
ISRA: "IL", // Israel
|
|
73
|
+
ISRO: "IN", // Indian Space Research Organisation: one country's agency
|
|
74
|
+
ISS: null, // International Space Station
|
|
75
|
+
IT: "IT", // Italy
|
|
76
|
+
ITSO: null, // International Telecommunications Satellite Organization (INTELSAT)
|
|
77
|
+
JPN: "JP", // Japan
|
|
78
|
+
KAZ: "KZ", // Kazakhstan
|
|
79
|
+
KEN: "KE", // Republic of Kenya
|
|
80
|
+
LAOS: "LA", // Laos
|
|
81
|
+
LKA: "LK", // Democratic Socialist Republic of Sri Lanka
|
|
82
|
+
LTU: "LT", // Lithuania
|
|
83
|
+
LUXE: "LU", // Luxembourg
|
|
84
|
+
MA: "MA", // Morocco
|
|
85
|
+
MALA: "MY", // Malaysia
|
|
86
|
+
MCO: "MC", // Principality of Monaco
|
|
87
|
+
MDA: "MD", // Republic of Moldova
|
|
88
|
+
MEX: "MX", // Mexico
|
|
89
|
+
MMR: "MM", // Republic of the Union of Myanmar
|
|
90
|
+
MNE: "ME", // Montenegro
|
|
91
|
+
MNG: "MN", // Mongolia
|
|
92
|
+
MUS: "MU", // Mauritius
|
|
93
|
+
NATO: null, // North Atlantic Treaty Organization
|
|
94
|
+
NETH: "NL", // Netherlands
|
|
95
|
+
NICO: null, // New ICO
|
|
96
|
+
NIG: "NG", // Nigeria
|
|
97
|
+
NKOR: "KP", // Democratic People's Republic of Korea
|
|
98
|
+
NOR: "NO", // Norway
|
|
99
|
+
NPL: "NP", // Federal Democratic Republic of Nepal
|
|
100
|
+
NZ: "NZ", // New Zealand
|
|
101
|
+
O3B: null, // O3b Networks
|
|
102
|
+
ORB: null, // ORBCOMM
|
|
103
|
+
PAKI: "PK", // Pakistan
|
|
104
|
+
PERU: "PE", // Peru
|
|
105
|
+
POL: "PL", // Poland
|
|
106
|
+
POR: "PT", // Portugal
|
|
107
|
+
PRC: "CN", // People's Republic of China
|
|
108
|
+
PRY: "PY", // Republic of Paraguay
|
|
109
|
+
PRES: null, // People's Republic of China/European Space Agency
|
|
110
|
+
QAT: "QA", // State of Qatar
|
|
111
|
+
RASC: null, // RascomStar-QAF
|
|
112
|
+
ROC: "TW", // Taiwan (Republic of China)
|
|
113
|
+
ROM: "RO", // Romania
|
|
114
|
+
RP: "PH", // Philippines (Republic of the Philippines)
|
|
115
|
+
RWA: "RW", // Republic of Rwanda
|
|
116
|
+
SAFR: "ZA", // South Africa
|
|
117
|
+
SAUD: "SA", // Saudi Arabia
|
|
118
|
+
SDN: "SD", // Republic of Sudan
|
|
119
|
+
SEAL: null, // Sea Launch
|
|
120
|
+
SEN: "SN", // Republic of Senegal
|
|
121
|
+
SES: null, // SES
|
|
122
|
+
SGJP: null, // Singapore/Japan
|
|
123
|
+
SING: "SG", // Singapore
|
|
124
|
+
SKOR: "KR", // Republic of Korea
|
|
125
|
+
SLB: "SB", // Solomon Islands
|
|
126
|
+
SPN: "ES", // Spain
|
|
127
|
+
STCT: null, // Singapore/Taiwan
|
|
128
|
+
SVN: "SI", // Slovenia
|
|
129
|
+
SWED: "SE", // Sweden
|
|
130
|
+
SWTZ: "CH", // Switzerland
|
|
131
|
+
TBD: null, // To Be Determined
|
|
132
|
+
THAI: "TH", // Thailand
|
|
133
|
+
TMMC: null, // Turkmenistan/Monaco
|
|
134
|
+
TUN: "TN", // Republic of Tunisia
|
|
135
|
+
TURK: "TR", // Türkiye
|
|
136
|
+
UAE: "AE", // United Arab Emirates
|
|
137
|
+
UK: "GB", // United Kingdom
|
|
138
|
+
UKR: "UA", // Ukraine
|
|
139
|
+
UNK: null, // Unknown
|
|
140
|
+
URY: "UY", // Uruguay
|
|
141
|
+
US: "US", // United States
|
|
142
|
+
USBZ: null, // United States/Brazil
|
|
143
|
+
VAT: "VA", // Vatican City State
|
|
144
|
+
VENZ: "VE", // Venezuela
|
|
145
|
+
VTNM: "VN", // Vietnam
|
|
146
|
+
ZWE: "ZW", // Republic of Zimbabwe
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* The country of a satellite's owner code as an ISO 3166-1 alpha-2 code (`PRC` is `CN`, `PAKI` is `PK`, `US` is `US`), or `undefined` for an organisation, several countries, an ambiguous owner or a code that is not in the list.
|
|
150
|
+
*
|
|
151
|
+
* @param code - The owner code as the catalogue writes it (`COUNTRY_CODE` or `OWNER`): case and spaces round it do not matter.
|
|
152
|
+
* @returns The two-letter country code, or `undefined`.
|
|
153
|
+
*
|
|
154
|
+
* @example
|
|
155
|
+
* ```ts
|
|
156
|
+
* import { ownerCountry } from "@johnmorrisdotca/chikyu-earth/satellites";
|
|
157
|
+
*
|
|
158
|
+
* console.log(ownerCountry("PRC"), ownerCountry("PAKI"), ownerCountry("ESA"), ownerCountry("XYZ"));
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
161
|
+
export function ownerCountry(code) {
|
|
162
|
+
const key = (code ?? "").trim().toUpperCase();
|
|
163
|
+
return (Object.hasOwn(OWNER_COUNTRIES, key) ? OWNER_COUNTRIES[key] : undefined) ?? undefined;
|
|
164
|
+
}
|
|
@@ -9,6 +9,9 @@ export function toElementSet(record) {
|
|
|
9
9
|
out["OBJECT_ID"] = record["OBJECT_ID"];
|
|
10
10
|
if (typeof record["CLASSIFICATION_TYPE"] === "string" && record["CLASSIFICATION_TYPE"])
|
|
11
11
|
out["CLASSIFICATION_TYPE"] = record["CLASSIFICATION_TYPE"];
|
|
12
|
+
for (const key of ["COUNTRY_CODE", "OWNER"])
|
|
13
|
+
if (typeof record[key] === "string" && record[key].trim())
|
|
14
|
+
out[key] = record[key].trim();
|
|
12
15
|
const epoch = record["EPOCH"];
|
|
13
16
|
if (typeof epoch !== "string" || !Number.isFinite(Date.parse(/[zZ]|[+-]\d\d:?\d\d$/.test(epoch) ? epoch : `${epoch}Z`)))
|
|
14
17
|
return "the epoch is missing or is not a date";
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import type { ElementSet, Satellites } from "./types.ts";
|
|
2
|
+
/**
|
|
3
|
+
* From this eccentricity up, a satellite is not turned about its orbit's axis at the mean motion above the interpolation limit, because it does not go round at a steady rate or stay at one height
|
|
4
|
+
* (a Molniya orbit is 10 times quicker at its lowest point than its mean): its place and its streak are SGP4 itself, two calls a frame, for the few that are this eccentric.
|
|
5
|
+
*/
|
|
6
|
+
export declare const ECCENTRIC_FROM = 0.02;
|
|
2
7
|
/**
|
|
3
8
|
* What `createSatellites` can be told.
|
|
4
9
|
*
|
package/dist/satellites/track.js
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
// SGP4 for a group of satellites, kept cheap: the whole group is run at two moments a step apart and every position in between is an interpolation, so the cost is one batch a step
|
|
2
2
|
// (about once a second), never one a frame. satellite.js (MIT) does the SGP4 itself; this file never touches the screen and imports on a server.
|
|
3
3
|
import { json2satrec, sgp4 } from "satellite.js";
|
|
4
|
+
import { CLASS_COLOURS } from "../catalogue/kinds.js";
|
|
5
|
+
import { classOfElements } from "../catalogue/orbit.js";
|
|
4
6
|
import { DEFAULT_DIM_AFTER_DAYS, DEFAULT_MAX_AGE_DAYS } from "./limits.js";
|
|
7
|
+
import { ownerCountry } from "./owners.js";
|
|
5
8
|
/** The Earth's mean radius in kilometres: the unit of every position here (the same as the space view's). */
|
|
6
9
|
const EARTH_RADIUS_KM = 6371;
|
|
7
10
|
const DAY_MS = 86_400_000;
|
|
8
11
|
const MIN_STEP_MS = 1000;
|
|
9
12
|
const MAX_STEP_MS = 60_000;
|
|
13
|
+
/**
|
|
14
|
+
* From this eccentricity up, a satellite is not turned about its orbit's axis at the mean motion above the interpolation limit, because it does not go round at a steady rate or stay at one height
|
|
15
|
+
* (a Molniya orbit is 10 times quicker at its lowest point than its mean): its place and its streak are SGP4 itself, two calls a frame, for the few that are this eccentric.
|
|
16
|
+
*/
|
|
17
|
+
export const ECCENTRIC_FROM = 0.02;
|
|
10
18
|
const epochOf = (text) => Date.parse(/[zZ]|[+-]\d\d:?\d\d$/.test(text) ? text : `${text}Z`);
|
|
11
19
|
/**
|
|
12
20
|
* Make a group of satellites from their element sets. Each starts SGP4 once here; one that does not (bad numbers, decayed at its own epoch) is listed in `refused` and left out.
|
|
@@ -73,6 +81,32 @@ export function createSatellites(sets, options = {}) {
|
|
|
73
81
|
}
|
|
74
82
|
}
|
|
75
83
|
const n = recs.length;
|
|
84
|
+
const normal = new Float32Array(n * 3);
|
|
85
|
+
const rate = new Float64Array(n);
|
|
86
|
+
const classColour = new Float32Array(n * 3);
|
|
87
|
+
const eccentric = [];
|
|
88
|
+
let newestEpochMs = 0;
|
|
89
|
+
for (let i = 0; i < n; i += 1) {
|
|
90
|
+
const set = usable[i];
|
|
91
|
+
const epoch = epochs[i];
|
|
92
|
+
if (epoch > newestEpochMs)
|
|
93
|
+
newestEpochMs = epoch;
|
|
94
|
+
const iRad = (set.INCLINATION * Math.PI) / 180;
|
|
95
|
+
const oRad = (set.RA_OF_ASC_NODE * Math.PI) / 180;
|
|
96
|
+
const si = Math.sin(iRad);
|
|
97
|
+
const ci = Math.cos(iRad);
|
|
98
|
+
normal[i * 3] = Math.sin(oRad) * si;
|
|
99
|
+
normal[i * 3 + 1] = ci;
|
|
100
|
+
normal[i * 3 + 2] = Math.cos(oRad) * si;
|
|
101
|
+
rate[i] = (set.MEAN_MOTION * 2 * Math.PI) / DAY_MS;
|
|
102
|
+
if (set.ECCENTRICITY >= ECCENTRIC_FROM)
|
|
103
|
+
eccentric.push(i);
|
|
104
|
+
const kind = classOfElements(set.MEAN_MOTION, set.ECCENTRICITY) ?? "other";
|
|
105
|
+
const hex = Number.parseInt(CLASS_COLOURS[kind].slice(1), 16);
|
|
106
|
+
classColour[i * 3] = ((hex >> 16) & 255) / 255;
|
|
107
|
+
classColour[i * 3 + 1] = ((hex >> 8) & 255) / 255;
|
|
108
|
+
classColour[i * 3 + 2] = (hex & 255) / 255;
|
|
109
|
+
}
|
|
76
110
|
let a = new Float32Array(n * 3);
|
|
77
111
|
let b = new Float32Array(n * 3);
|
|
78
112
|
let okA = new Uint8Array(n);
|
|
@@ -87,6 +121,23 @@ export function createSatellites(sets, options = {}) {
|
|
|
87
121
|
let propagations = 0;
|
|
88
122
|
let placed = 0;
|
|
89
123
|
const timing = { lastBatchMs: 0, maxBatchMs: 0 };
|
|
124
|
+
const pinned = new Float32Array(n * 3);
|
|
125
|
+
const pinOk = new Uint8Array(n);
|
|
126
|
+
let pinMs = Number.NaN;
|
|
127
|
+
/** Turn `x,y,z` about the unit axis `nx,ny,nz` by `ang` radians, into `out` at `at` (no allocation: it runs for every satellite on every frame). */
|
|
128
|
+
const turn = (x, y, z, nx, ny, nz, ang, out, at) => {
|
|
129
|
+
const c = Math.cos(ang);
|
|
130
|
+
const s = Math.sin(ang);
|
|
131
|
+
const dot = nx * x + ny * y + nz * z;
|
|
132
|
+
const k = 1 - c;
|
|
133
|
+
out[at] = x * c + (ny * z - nz * y) * s + nx * dot * k;
|
|
134
|
+
out[at + 1] = y * c + (nz * x - nx * z) * s + ny * dot * k;
|
|
135
|
+
out[at + 2] = z * c + (nx * y - ny * x) * s + nz * dot * k;
|
|
136
|
+
};
|
|
137
|
+
const place = new Float64Array(6);
|
|
138
|
+
const isEccentric = new Uint8Array(n);
|
|
139
|
+
for (const i of eccentric)
|
|
140
|
+
isEccentric[i] = 1;
|
|
90
141
|
/** SGP4 for the whole group at one moment, into `buffer` in the space view's axes (TEME x, z, -y: x to the vernal equinox, y north). */
|
|
91
142
|
const sample = (buffer, ok, ms) => {
|
|
92
143
|
const started = performance.now();
|
|
@@ -142,9 +193,83 @@ export function createSatellites(sets, options = {}) {
|
|
|
142
193
|
return propagations;
|
|
143
194
|
},
|
|
144
195
|
timing,
|
|
196
|
+
newestEpochMs,
|
|
197
|
+
classColour,
|
|
145
198
|
get placed() {
|
|
146
199
|
return placed;
|
|
147
200
|
},
|
|
201
|
+
pin(ms) {
|
|
202
|
+
if (n === 0)
|
|
203
|
+
return;
|
|
204
|
+
sample(pinned, pinOk, ms);
|
|
205
|
+
pinMs = ms;
|
|
206
|
+
},
|
|
207
|
+
arc(ms, spanMs, positions, segments) {
|
|
208
|
+
if (n === 0)
|
|
209
|
+
return 0;
|
|
210
|
+
if (!Number.isFinite(pinMs)) {
|
|
211
|
+
sample(pinned, pinOk, ms);
|
|
212
|
+
pinMs = ms;
|
|
213
|
+
}
|
|
214
|
+
const span = spanMs;
|
|
215
|
+
let count = 0;
|
|
216
|
+
for (let i = 0; i < n; i += 1) {
|
|
217
|
+
const k = i * 3;
|
|
218
|
+
const dim = Math.abs(ms - epochs[i]) > dimAfterMs ? 1 : 0;
|
|
219
|
+
if (dim !== dimmed[i]) {
|
|
220
|
+
dimmed[i] = dim;
|
|
221
|
+
dimVersion += 1;
|
|
222
|
+
}
|
|
223
|
+
const w = k * 2;
|
|
224
|
+
if (isEccentric[i] === 1) {
|
|
225
|
+
if (!exactAt(i, ms, place)) {
|
|
226
|
+
positions.fill(0, k, k + 3);
|
|
227
|
+
segments.fill(0, w, w + 6);
|
|
228
|
+
shown[i] = 0;
|
|
229
|
+
continue;
|
|
230
|
+
}
|
|
231
|
+
positions[k] = place[0];
|
|
232
|
+
positions[k + 1] = place[1];
|
|
233
|
+
positions[k + 2] = place[2];
|
|
234
|
+
segments[w + 3] = place[0];
|
|
235
|
+
segments[w + 4] = place[1];
|
|
236
|
+
segments[w + 5] = place[2];
|
|
237
|
+
if (exactAt(i, ms - span, place)) {
|
|
238
|
+
segments[w] = place[0];
|
|
239
|
+
segments[w + 1] = place[1];
|
|
240
|
+
segments[w + 2] = place[2];
|
|
241
|
+
}
|
|
242
|
+
else {
|
|
243
|
+
segments[w] = positions[k];
|
|
244
|
+
segments[w + 1] = positions[k + 1];
|
|
245
|
+
segments[w + 2] = positions[k + 2];
|
|
246
|
+
}
|
|
247
|
+
shown[i] = 1;
|
|
248
|
+
count += 1;
|
|
249
|
+
continue;
|
|
250
|
+
}
|
|
251
|
+
if (pinOk[i] !== 1) {
|
|
252
|
+
positions.fill(0, k, k + 3);
|
|
253
|
+
segments.fill(0, w, w + 6);
|
|
254
|
+
shown[i] = 0;
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
257
|
+
const nx = normal[k];
|
|
258
|
+
const ny = normal[k + 1];
|
|
259
|
+
const nz = normal[k + 2];
|
|
260
|
+
const sweep = Math.max(-Math.PI, Math.min(Math.PI, rate[i] * span));
|
|
261
|
+
const along = rate[i] * (ms - pinMs);
|
|
262
|
+
turn(pinned[k], pinned[k + 1], pinned[k + 2], nx, ny, nz, along, positions, k);
|
|
263
|
+
turn(pinned[k], pinned[k + 1], pinned[k + 2], nx, ny, nz, along - sweep, segments, w);
|
|
264
|
+
segments[w + 3] = positions[k];
|
|
265
|
+
segments[w + 4] = positions[k + 1];
|
|
266
|
+
segments[w + 5] = positions[k + 2];
|
|
267
|
+
shown[i] = 1;
|
|
268
|
+
count += 1;
|
|
269
|
+
}
|
|
270
|
+
placed = count;
|
|
271
|
+
return count;
|
|
272
|
+
},
|
|
148
273
|
setStep(ms) {
|
|
149
274
|
const next = Math.min(MAX_STEP_MS, Math.max(MIN_STEP_MS, Math.round(ms)));
|
|
150
275
|
if (next !== stepMs) {
|
|
@@ -235,6 +360,9 @@ export function createSatellites(sets, options = {}) {
|
|
|
235
360
|
periodMinutes: 1440 / set.MEAN_MOTION,
|
|
236
361
|
inclinationDeg: set.INCLINATION,
|
|
237
362
|
};
|
|
363
|
+
const country = ownerCountry(set.COUNTRY_CODE ?? set.OWNER);
|
|
364
|
+
if (country)
|
|
365
|
+
info.ownerCountry = country;
|
|
238
366
|
return info;
|
|
239
367
|
},
|
|
240
368
|
};
|
|
@@ -48,6 +48,10 @@ export interface ElementSet {
|
|
|
48
48
|
CLASSIFICATION_TYPE?: string;
|
|
49
49
|
ELEMENT_SET_NO?: number;
|
|
50
50
|
REV_AT_EPOCH?: number;
|
|
51
|
+
/** The owner's code, as one catalogue writes it (`US`, `PRC`, `ESA`), when the source carries it. */
|
|
52
|
+
COUNTRY_CODE?: string;
|
|
53
|
+
/** The owner's code, as the other catalogue writes it (the same codes), when the source carries it. */
|
|
54
|
+
OWNER?: string;
|
|
51
55
|
}
|
|
52
56
|
/**
|
|
53
57
|
* What a page can tell a reader about one satellite at a moment: its name, its number, how old its elements are, how high and how fast it is.
|
|
@@ -80,6 +84,8 @@ export interface SatelliteInfo {
|
|
|
80
84
|
periodMinutes: number;
|
|
81
85
|
/** Degrees. */
|
|
82
86
|
inclinationDeg: number;
|
|
87
|
+
/** The owner's country as an ISO 3166-1 alpha-2 code (`ownerCountry`), when the elements carry an owner code (`COUNTRY_CODE` or `OWNER`) and the owner is one country; absent for an organisation, several countries, an ambiguous owner or an unknown code. */
|
|
88
|
+
ownerCountry?: string;
|
|
83
89
|
}
|
|
84
90
|
/**
|
|
85
91
|
* A satellite chosen from a group: which group and which place in it.
|
|
@@ -154,10 +160,22 @@ export interface Satellites {
|
|
|
154
160
|
at(ms: number, out: Float32Array): void;
|
|
155
161
|
/** True if satellite `index` was placed by the last `at` (its elements are not too old at that moment). */
|
|
156
162
|
visible(index: number): boolean;
|
|
157
|
-
/** How many of them the last `at` placed. */
|
|
163
|
+
/** How many of them the last `at` or `arc` placed. */
|
|
158
164
|
readonly placed: number;
|
|
165
|
+
/** The newest element epoch in the group, in milliseconds since the Unix epoch, or 0 when it is empty. The date of the data. */
|
|
166
|
+
readonly newestEpochMs: number;
|
|
167
|
+
/** Red, green and blue, from 0 to 1, of each satellite's orbit class, 3 numbers a satellite. It does not change. */
|
|
168
|
+
readonly classColour: Float32Array;
|
|
159
169
|
/** The game time between the two moments SGP4 is run at (1000 to 60000 ms); the space view sets it from the clock's speed. */
|
|
160
170
|
setStep(ms: number): void;
|
|
171
|
+
/** Place every satellite with SGP4 at `ms` and keep that place. `arc` turns it along the orbit until the next `pin`. One batch, no interpolation. */
|
|
172
|
+
pin(ms: number): void;
|
|
173
|
+
/**
|
|
174
|
+
* The place of each satellite at `ms` into `positions` (3 numbers each) and the stretch of orbit it travels over `spanMs` of game time into `segments` (6 numbers each: where it was `spanMs` earlier, then where it is).
|
|
175
|
+
* The place is the last `pin`, turned about the orbit's axis by the mean motion, so a fast clock does not run SGP4 for every satellite on every frame. A `spanMs` that would turn it more than half a revolution is cut there. An orbit with an eccentricity of 0.02 or more is placed by SGP4 itself instead (two calls a frame), because a turn at the mean motion would put it off its path.
|
|
176
|
+
* Returns how many were written.
|
|
177
|
+
*/
|
|
178
|
+
arc(ms: number, spanMs: number, positions: Float32Array, segments: Float32Array): number;
|
|
161
179
|
/** One satellite at exactly `ms` (no interpolation): position in Earth radii and velocity in km/s into `out` (6 numbers). False if its elements are too old or SGP4 gave up. */
|
|
162
180
|
exact(index: number, ms: number, out: Float64Array): boolean;
|
|
163
181
|
/** The path of satellite `index` for one revolution from `ms`, `points` + 1 points in order along it (the last on the first), into a new array of Earth radii. */
|