@johnmorrisdotca/wakusei-planets 0.36.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 +9 -0
- package/NOTICE.md +15 -1
- package/README.md +5 -4
- package/dist/data/moon-catalogue.d.ts +31 -0
- package/dist/data/moon-catalogue.js +471 -0
- package/dist/data/places-planned.d.ts +3 -0
- package/dist/data/places-planned.js +51 -0
- package/dist/element.d.ts +28 -0
- package/dist/element.js +172 -1
- package/dist/moon-catalogue.d.ts +296 -0
- package/dist/moon-catalogue.js +234 -0
- package/dist/place-marks.d.ts +182 -0
- package/dist/place-marks.js +194 -0
- package/dist/places/mars.d.ts +1 -1
- package/dist/places/mars.js +4 -2
- package/dist/places/moon.d.ts +1 -1
- package/dist/places/moon.js +4 -2
- package/dist/places.d.ts +4 -2
- package/dist/places.js +2 -0
- package/dist/scene/place-layer.d.ts +68 -0
- package/dist/scene/place-layer.js +213 -0
- package/dist/scene/textures.d.ts +2 -2
- package/dist/space/all-moons.d.ts +30 -0
- package/dist/space/all-moons.js +61 -0
- package/dist/space/bodies.d.ts +18 -0
- package/dist/space/bodies.js +18 -0
- package/dist/space/element.d.ts +102 -2
- package/dist/space/element.js +415 -7
- package/dist/space/index.d.ts +2 -1
- package/dist/space/index.js +2 -1
- package/dist/space/scene.d.ts +32 -0
- package/dist/space/scene.js +44 -0
- package/dist/space/sight.d.ts +106 -0
- package/dist/space/sight.js +84 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +8 -2
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
// Every known moon of the planets and the dwarf planets, as a light list: names and designations, who found each and when, the mean orbit, the size where it is known, and where each is on a date from that orbit,
|
|
2
|
+
// with how far that position was measured to be from JPL Horizons. The rows (scripts/make-moon-catalogue.py, src/data/moon-catalogue.ts) are imported by this entry point only, so a page that does not import
|
|
3
|
+
// `/moon-catalogue` does not carry them. Positions are from the planet's centre, in kilometres, in the J2000 ecliptic frame (the axes `moonVector` gives). Pure: no DOM, no clock reads, no three.js.
|
|
4
|
+
import { MOON_CATALOGUE_READ, MOON_CATALOGUE_ROWS } from "./data/moon-catalogue.js";
|
|
5
|
+
import { toTerrestrialTime } from "./clock.js";
|
|
6
|
+
import { kepler } from "./ephemeris.js";
|
|
7
|
+
import { cross, fromRaDec, RAD, toEcliptic } from "./vec.js";
|
|
8
|
+
import { moment } from "./when.js";
|
|
9
|
+
const DAY_MS = 86_400_000;
|
|
10
|
+
const UNIX_JD = 2_440_587.5;
|
|
11
|
+
const YEAR_DAYS = 365.25;
|
|
12
|
+
/**
|
|
13
|
+
* Every group, in the order the guide lists them.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* import { MOON_GROUPS } from "@johnmorrisdotca/wakusei-planets/moon-catalogue";
|
|
18
|
+
*
|
|
19
|
+
* console.log(MOON_GROUPS.join(", "));
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export const MOON_GROUPS = ["inner", "major", "regular", "themisto", "himalia", "carpo", "valetudo", "ananke", "carme", "pasiphae", "inuit", "gallic", "norse", "prograde", "retrograde", "none"];
|
|
23
|
+
/**
|
|
24
|
+
* The albedo a `derived` size takes when the Horizons sheet gives none: 0.04, the albedo the sheet gives for Himalia, the largest of the irregular moons. The few other irregular moons with an albedo on their sheets have 0.03
|
|
25
|
+
* (Elara) to 0.081 (Phoebe), and Nereid 0.2; a darker moon is larger than the estimate and a brighter one smaller, so a derived radius is a guide to the size, not a measurement.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* import { ASSUMED_ALBEDO } from "@johnmorrisdotca/wakusei-planets/moon-catalogue";
|
|
30
|
+
*
|
|
31
|
+
* console.log(ASSUMED_ALBEDO);
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export const ASSUMED_ALBEDO = 0.04;
|
|
35
|
+
const FRAMES = ["ecliptic", "equatorial", "laplace"];
|
|
36
|
+
const SIZE_FROM = ["measured", "sheet"];
|
|
37
|
+
function moonOf(row) {
|
|
38
|
+
const [id, name, designation, number, host, code, year, by, reference, o, radius, sigma, from, albedo, magnitude, worstKm, worstDegrees, farDegrees, group, ja, confirmed] = row;
|
|
39
|
+
const orbit = o === null
|
|
40
|
+
? null
|
|
41
|
+
: {
|
|
42
|
+
frame: FRAMES[o[0]],
|
|
43
|
+
...(o[12] === undefined ? {} : { pole: [o[12], o[13]] }),
|
|
44
|
+
epochJd: o[1],
|
|
45
|
+
a: o[2],
|
|
46
|
+
e: o[3],
|
|
47
|
+
w: o[4],
|
|
48
|
+
m: o[5],
|
|
49
|
+
i: o[6],
|
|
50
|
+
node: o[7],
|
|
51
|
+
periodDays: o[8],
|
|
52
|
+
apsisYears: o[9],
|
|
53
|
+
nodeYears: o[10],
|
|
54
|
+
ephemeris: o[11],
|
|
55
|
+
};
|
|
56
|
+
let radiusKm = radius;
|
|
57
|
+
let radiusFrom = from === null ? null : SIZE_FROM[from];
|
|
58
|
+
if (radiusKm === null && magnitude !== null) {
|
|
59
|
+
radiusKm = Math.round(10 ** (3.1236 - 0.5 * Math.log10(albedo ?? ASSUMED_ALBEDO) - 0.2 * magnitude) * 5) / 10;
|
|
60
|
+
radiusFrom = "derived";
|
|
61
|
+
}
|
|
62
|
+
const grade = orbit === null ? "none" : worstDegrees === null ? "unmeasured" : worstDegrees < 1 ? "close" : worstDegrees < 10 ? "rough" : "loose";
|
|
63
|
+
return {
|
|
64
|
+
id,
|
|
65
|
+
name,
|
|
66
|
+
ja,
|
|
67
|
+
designation,
|
|
68
|
+
label: name ?? designation ?? id,
|
|
69
|
+
number,
|
|
70
|
+
host,
|
|
71
|
+
code,
|
|
72
|
+
named: name !== null,
|
|
73
|
+
confirmed: confirmed !== 0,
|
|
74
|
+
discovery: { year, by, reference },
|
|
75
|
+
orbit,
|
|
76
|
+
retrograde: orbit === null ? null : orbit.i > 90,
|
|
77
|
+
group,
|
|
78
|
+
radiusKm,
|
|
79
|
+
radiusSigmaKm: sigma,
|
|
80
|
+
radiusFrom,
|
|
81
|
+
albedo,
|
|
82
|
+
magnitude,
|
|
83
|
+
accuracy: worstKm === null || worstDegrees === null ? null : { worstKm, worstDegrees, farDegrees },
|
|
84
|
+
grade,
|
|
85
|
+
full: ja !== null,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Every known moon of the planets and the dwarf planets, as JPL lists them on `MOON_CATALOGUE_FETCHED`, in the order of the planets and, within a planet, of JPL's list (the long-known moons first, then by discovery).
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```ts
|
|
93
|
+
* import { MOON_CATALOGUE } from "@johnmorrisdotca/wakusei-planets/moon-catalogue";
|
|
94
|
+
*
|
|
95
|
+
* console.log(MOON_CATALOGUE.length, "moons;", MOON_CATALOGUE.filter((m) => m.named).length, "with a name");
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
export const MOON_CATALOGUE = MOON_CATALOGUE_ROWS.map(moonOf);
|
|
99
|
+
/**
|
|
100
|
+
* The day the catalogue was read from JPL. New moons are announced every year; `scripts/make-moon-catalogue.py --refresh` reads the sources again and prints what changed.
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```ts
|
|
104
|
+
* import { MOON_CATALOGUE_FETCHED } from "@johnmorrisdotca/wakusei-planets/moon-catalogue";
|
|
105
|
+
*
|
|
106
|
+
* console.log("moons as of", MOON_CATALOGUE_FETCHED);
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
export const MOON_CATALOGUE_FETCHED = MOON_CATALOGUE_READ;
|
|
110
|
+
/**
|
|
111
|
+
* The counts for every planet and dwarf planet that has a moon in the catalogue.
|
|
112
|
+
*
|
|
113
|
+
* @returns A count for each host, in the catalogue's order.
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```ts
|
|
117
|
+
* import { moonCounts } from "@johnmorrisdotca/wakusei-planets/moon-catalogue";
|
|
118
|
+
*
|
|
119
|
+
* for (const [host, count] of Object.entries(moonCounts())) console.log(host, count.total);
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
122
|
+
export function moonCounts() {
|
|
123
|
+
const out = {};
|
|
124
|
+
for (const moon of MOON_CATALOGUE) {
|
|
125
|
+
const count = (out[moon.host] ??= { total: 0, named: 0, placed: 0 });
|
|
126
|
+
count.total += 1;
|
|
127
|
+
if (moon.named)
|
|
128
|
+
count.named += 1;
|
|
129
|
+
if (moon.orbit !== null)
|
|
130
|
+
count.placed += 1;
|
|
131
|
+
}
|
|
132
|
+
return out;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* The moons of one planet or dwarf planet, nearest first (by the mean orbit's semi-major axis; a moon with no orbit last), optionally of one group.
|
|
136
|
+
*
|
|
137
|
+
* @param host - The planet or dwarf planet: "jupiter", "eris".
|
|
138
|
+
* @param group - A group, to narrow the list.
|
|
139
|
+
* @returns The moons, which must not be changed.
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* ```ts
|
|
143
|
+
* import { catalogueMoonsOf } from "@johnmorrisdotca/wakusei-planets/moon-catalogue";
|
|
144
|
+
*
|
|
145
|
+
* console.log(catalogueMoonsOf("jupiter", "himalia").map((m) => m.label).join(", "));
|
|
146
|
+
* ```
|
|
147
|
+
*/
|
|
148
|
+
export function catalogueMoonsOf(host, group) {
|
|
149
|
+
return MOON_CATALOGUE.filter((m) => m.host === host && (group === undefined || m.group === group)).sort((a, b) => (a.orbit?.a ?? Infinity) - (b.orbit?.a ?? Infinity));
|
|
150
|
+
}
|
|
151
|
+
const plain = (text) => text.normalize("NFKD").replace(/[̀-ͯ]/g, "").toLowerCase().replace(/[^a-z0-9-ヿ一-鿿]/g, "");
|
|
152
|
+
/**
|
|
153
|
+
* Finds a moon by its id, name (English, or Japanese for the package's own moons), designation (spaces and slashes do not matter: "S/2003 J 18", "s2003j18") or JPL code (501). Ignores case and accents.
|
|
154
|
+
*
|
|
155
|
+
* @param query - The id, name, designation or code.
|
|
156
|
+
* @returns The moon, or `undefined`.
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
* ```ts
|
|
160
|
+
* import { findCatalogueMoon } from "@johnmorrisdotca/wakusei-planets/moon-catalogue";
|
|
161
|
+
*
|
|
162
|
+
* console.log(findCatalogueMoon("io")?.code, findCatalogueMoon(506)?.label, findCatalogueMoon("s2003j18")?.host, findCatalogueMoon("nothing"));
|
|
163
|
+
* ```
|
|
164
|
+
*/
|
|
165
|
+
export function findCatalogueMoon(query) {
|
|
166
|
+
if (typeof query === "number")
|
|
167
|
+
return MOON_CATALOGUE.find((m) => m.code === query);
|
|
168
|
+
const q = plain(query);
|
|
169
|
+
if (q === "")
|
|
170
|
+
return undefined;
|
|
171
|
+
return MOON_CATALOGUE.find((m) => [m.id, m.name, m.ja, m.designation, m.code === null ? null : String(m.code)].some((v) => v !== null && plain(v) === q));
|
|
172
|
+
}
|
|
173
|
+
const basisCache = new Map();
|
|
174
|
+
function basisOf(pole) {
|
|
175
|
+
if (pole === null)
|
|
176
|
+
return [[1, 0, 0], [0, 1, 0], [0, 0, 1]];
|
|
177
|
+
const key = pole.join();
|
|
178
|
+
let basis = basisCache.get(key);
|
|
179
|
+
if (basis === undefined) {
|
|
180
|
+
const z = fromRaDec(pole[0], pole[1]);
|
|
181
|
+
const x = fromRaDec(pole[0] + 90, 0);
|
|
182
|
+
basis = [toEcliptic(x), toEcliptic(cross(z, x)), toEcliptic(z)];
|
|
183
|
+
basisCache.set(key, basis);
|
|
184
|
+
}
|
|
185
|
+
return basis;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* The rates a mean orbit turns at, degrees a day: the mean anomaly's from the sidereal period (the mean longitude goes once round in it, so the mean anomaly runs slower by the turning of the other two); the periapsis turning forwards where 5 cos²i - 1 is positive and backwards where it is negative, and the node backwards on a prograde orbit
|
|
189
|
+
* and forwards on a retrograde one, as a planet's flattening and the Sun's pull turn them; each at the speed of the period the source gives (none where it gives none).
|
|
190
|
+
*/
|
|
191
|
+
function ratesOf(orbit) {
|
|
192
|
+
const ci = Math.cos(orbit.i * RAD);
|
|
193
|
+
const dw = orbit.apsisYears ? (Math.sign(5 * ci * ci - 1) * 360) / (orbit.apsisYears * YEAR_DAYS) : 0;
|
|
194
|
+
const dn = orbit.nodeYears ? (-Math.sign(ci) * 360) / (orbit.nodeYears * YEAR_DAYS) : 0;
|
|
195
|
+
return [360 / orbit.periodDays - dw - dn, dw, dn];
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Where a moon is at a moment, from its planet's centre, in kilometres, in the J2000 ecliptic frame (the axes of `moonVector`): its mean orbit, turned for the precession of its periapsis and node, solved by Kepler's
|
|
199
|
+
* equation. How close that is to the moon's real place near 2026 is the moon's `accuracy` and `grade`; decades away it drifts much further (`accuracy.farDegrees`). A moon the package draws in full is placed far better
|
|
200
|
+
* by the main entry point's `moonVector`.
|
|
201
|
+
*
|
|
202
|
+
* @param moon - A moon of the catalogue, or its id, name, designation or code.
|
|
203
|
+
* @param when - A `Date` or milliseconds since 1970 (UTC).
|
|
204
|
+
* @returns x, y, z in kilometres, or `undefined` for a moon with no orbit.
|
|
205
|
+
*
|
|
206
|
+
* @example
|
|
207
|
+
* ```ts
|
|
208
|
+
* import { catalogueMoonPosition } from "@johnmorrisdotca/wakusei-planets/moon-catalogue";
|
|
209
|
+
*
|
|
210
|
+
* const [x, y, z] = catalogueMoonPosition("Himalia", new Date("2026-11-11T00:00:00Z"))!;
|
|
211
|
+
* console.log(Math.round(Math.hypot(x, y, z) / 1e6), "million km from Jupiter");
|
|
212
|
+
* ```
|
|
213
|
+
*/
|
|
214
|
+
export function catalogueMoonPosition(moon, when) {
|
|
215
|
+
const m = typeof moon === "object" ? moon : findCatalogueMoon(moon);
|
|
216
|
+
if (m === undefined)
|
|
217
|
+
throw new RangeError(`unknown moon ${JSON.stringify(moon)}; look one up with findCatalogueMoon`);
|
|
218
|
+
const orbit = m.orbit;
|
|
219
|
+
if (orbit === null)
|
|
220
|
+
return undefined;
|
|
221
|
+
const [n, dw, dn] = ratesOf(orbit);
|
|
222
|
+
const dt = toTerrestrialTime(moment(when)) / DAY_MS + UNIX_JD - orbit.epochJd;
|
|
223
|
+
const w = (orbit.w + dw * dt) * RAD;
|
|
224
|
+
const node = (orbit.node + dn * dt) * RAD;
|
|
225
|
+
const E = kepler((orbit.m + n * dt) * RAD, orbit.e);
|
|
226
|
+
const x = orbit.a * (Math.cos(E) - orbit.e);
|
|
227
|
+
const y = orbit.a * Math.sqrt(1 - orbit.e * orbit.e) * Math.sin(E);
|
|
228
|
+
const [cw, sw, cn, sn, ci, si] = [Math.cos(w), Math.sin(w), Math.cos(node), Math.sin(node), Math.cos(orbit.i * RAD), Math.sin(orbit.i * RAD)];
|
|
229
|
+
const px = (cw * cn - sw * sn * ci) * x + (-sw * cn - cw * sn * ci) * y;
|
|
230
|
+
const py = (cw * sn + sw * cn * ci) * x + (-sw * sn + cw * cn * ci) * y;
|
|
231
|
+
const pz = sw * si * x + cw * si * y;
|
|
232
|
+
const [bx, by, bz] = basisOf(orbit.frame === "ecliptic" ? null : (orbit.pole ?? null));
|
|
233
|
+
return [px * bx[0] + py * by[0] + pz * bz[0], px * bx[1] + py * by[1] + pz * bz[1], px * bx[2] + py * by[2] + pz * bz[2]];
|
|
234
|
+
}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import type { Place, PlaceKind } from "./places.ts";
|
|
2
|
+
import { type Vec3 } from "./vec.ts";
|
|
3
|
+
/**
|
|
4
|
+
* The layers of places a view can show, each switched on by itself: `landing` (the crewed landings, the landers and the rovers), `crash` (the crash, impact and atmospheric-entry sites), `planned` (announced landings) and `feature`
|
|
5
|
+
* (the named features of the surface).
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { PLACE_LAYERS } from "@johnmorrisdotca/wakusei-planets/places";
|
|
10
|
+
*
|
|
11
|
+
* console.log(PLACE_LAYERS.join(" "));
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare const PLACE_LAYERS: readonly ["landing", "crash", "planned", "feature"];
|
|
15
|
+
/**
|
|
16
|
+
* One layer of places.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* import type { PlaceLayer } from "@johnmorrisdotca/wakusei-planets/places";
|
|
21
|
+
*
|
|
22
|
+
* const layer: PlaceLayer = "landing";
|
|
23
|
+
* console.log(layer);
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export type PlaceLayer = (typeof PLACE_LAYERS)[number];
|
|
27
|
+
/**
|
|
28
|
+
* The layer a kind of place is shown in.
|
|
29
|
+
*
|
|
30
|
+
* @param kind - The place's kind.
|
|
31
|
+
* @returns Its layer.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* import { layerOf } from "@johnmorrisdotca/wakusei-planets/places";
|
|
36
|
+
*
|
|
37
|
+
* console.log(layerOf("rover"), layerOf("impact"), layerOf("feature"));
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare function layerOf(kind: PlaceKind): PlaceLayer;
|
|
41
|
+
/**
|
|
42
|
+
* The layers an attribute asks for: a list of layer names with spaces or commas between (`"landing crash"`), `all` (or an empty value) for every layer, and `none` or `off` for none. Unknown words are left out.
|
|
43
|
+
*
|
|
44
|
+
* @param value - The attribute's value, or `null` when it is absent (no layers).
|
|
45
|
+
* @returns The layers, in `PLACE_LAYERS` order.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* import { readPlaceLayers } from "@johnmorrisdotca/wakusei-planets/places";
|
|
50
|
+
*
|
|
51
|
+
* console.log(readPlaceLayers("crash, landing"), readPlaceLayers(""), readPlaceLayers(null));
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export declare function readPlaceLayers(value: string | null): PlaceLayer[];
|
|
55
|
+
/**
|
|
56
|
+
* A body as a view draws it, for laying marks over it: its centre and radius in the scene's units, its axes there (`pole` north, `meridian` towards longitude 0 on the equator), the stretch of its globe along each
|
|
57
|
+
* (east, pole, meridian: 1, 1, 1 for a sphere), where the viewer is (`eye`, a point, for a camera with perspective; `toward`, a direction, for one without), the projection of a point in the scene to CSS pixels
|
|
58
|
+
* (`null` when it cannot be drawn), the view's size in CSS pixels, and the body's radius on the screen in CSS pixels.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```ts
|
|
62
|
+
* import type { SurfaceView } from "@johnmorrisdotca/wakusei-planets/places";
|
|
63
|
+
*
|
|
64
|
+
* const view: SurfaceView = { centre: [0, 0, 0], radius: 1, pole: [0, 1, 0], meridian: [0, 0, 1], scale: [1, 1, 1], toward: [0, 0, 1], project: (p) => ({ x: 160 + p[0] * 100, y: 160 - p[1] * 100 }), width: 320, height: 320, radiusPx: 100 };
|
|
65
|
+
* console.log(view.radiusPx);
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export interface SurfaceView {
|
|
69
|
+
centre: Vec3;
|
|
70
|
+
radius: number;
|
|
71
|
+
pole: Vec3;
|
|
72
|
+
meridian: Vec3;
|
|
73
|
+
scale: Vec3;
|
|
74
|
+
eye?: Vec3;
|
|
75
|
+
toward?: Vec3;
|
|
76
|
+
project(point: Vec3): {
|
|
77
|
+
x: number;
|
|
78
|
+
y: number;
|
|
79
|
+
} | null;
|
|
80
|
+
width: number;
|
|
81
|
+
height: number;
|
|
82
|
+
radiusPx: number;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* A place's point on the body's surface in the scene, and the outward normal there: the planetocentric latitude and east longitude laid along the body's own axes onto its ellipsoid.
|
|
86
|
+
*
|
|
87
|
+
* @param view - The body as drawn.
|
|
88
|
+
* @param lat - Planetocentric latitude, degrees.
|
|
89
|
+
* @param lon - East longitude, degrees.
|
|
90
|
+
* @returns The point and the unit normal.
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```ts
|
|
94
|
+
* import { surfacePoint } from "@johnmorrisdotca/wakusei-planets/places";
|
|
95
|
+
*
|
|
96
|
+
* const view = { centre: [0, 0, 0] as [number, number, number], radius: 2, pole: [0, 1, 0] as [number, number, number], meridian: [0, 0, 1] as [number, number, number], scale: [1, 1, 1] as [number, number, number], project: () => null, width: 1, height: 1, radiusPx: 1 };
|
|
97
|
+
* console.log(surfacePoint(view, 0, 90).point.map((n) => n.toFixed(1)).join(", "));
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
export declare function surfacePoint(view: SurfaceView, lat: number, lon: number): {
|
|
101
|
+
point: Vec3;
|
|
102
|
+
normal: Vec3;
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* One mark to lay over the view: the place, its layer, and where it is in CSS pixels from the view's top left.
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* ```ts
|
|
109
|
+
* import type { PlaceMark } from "@johnmorrisdotca/wakusei-planets/places";
|
|
110
|
+
*
|
|
111
|
+
* const mark: Pick<PlaceMark, "layer" | "x" | "y"> = { layer: "landing", x: 120, y: 80 };
|
|
112
|
+
* console.log(mark.layer);
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
export interface PlaceMark {
|
|
116
|
+
place: Place;
|
|
117
|
+
layer: PlaceLayer;
|
|
118
|
+
x: number;
|
|
119
|
+
y: number;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* The rules that keep the marks quiet, in CSS pixels: nothing is marked on a body under `fromPx` of radius on the screen; a named feature is marked once it is `featureFromPx` across (a famous one at any size);
|
|
123
|
+
* no two marks are closer than `gapPx` (the one chosen first keeps its place); and a body gets one mark for every `sharePx` of its radius, 8 at least and `most` at most.
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* ```ts
|
|
127
|
+
* import { MARK_RULES } from "@johnmorrisdotca/wakusei-planets/places";
|
|
128
|
+
*
|
|
129
|
+
* console.log(MARK_RULES.gapPx, MARK_RULES.most);
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
export declare const MARK_RULES: {
|
|
133
|
+
readonly fromPx: 40;
|
|
134
|
+
readonly featureFromPx: 14;
|
|
135
|
+
readonly gapPx: 12;
|
|
136
|
+
readonly sharePx: 4;
|
|
137
|
+
readonly most: 60;
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* The marks to lay over a body: the places of the layers asked for that face the viewer (not too near the edge of the disc, where they would crowd), are inside the view, and are not crowded out by a mark
|
|
141
|
+
* that comes first. The visited sites come first, the famous before the rest, then the named features by size, and a feature is marked only once it is big enough on the screen to show (`MARK_RULES`;
|
|
142
|
+
* any famous one). Nothing is marked on a body too small on the screen, and a small body gets fewer marks than a big one.
|
|
143
|
+
*
|
|
144
|
+
* @param places - The body's list.
|
|
145
|
+
* @param layers - The layers to show.
|
|
146
|
+
* @param view - The body as drawn.
|
|
147
|
+
* @param radiusKm - The body's radius in kilometres, to tell a feature's size on the screen.
|
|
148
|
+
* @returns The marks, in the order they were chosen.
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* ```ts
|
|
152
|
+
* import { placeMarks } from "@johnmorrisdotca/wakusei-planets/places";
|
|
153
|
+
* import { PLACES_MOON } from "@johnmorrisdotca/wakusei-planets/places/moon";
|
|
154
|
+
*
|
|
155
|
+
* const view = { centre: [0, 0, 0] as [number, number, number], radius: 1, pole: [0, 1, 0] as [number, number, number], meridian: [0, 0, 1] as [number, number, number], scale: [1, 1, 1] as [number, number, number], toward: [0, 0, 1] as [number, number, number],
|
|
156
|
+
* project: (p: [number, number, number]) => ({ x: 200 + p[0] * 180, y: 200 - p[1] * 180 }), width: 400, height: 400, radiusPx: 180 };
|
|
157
|
+
* console.log(placeMarks(PLACES_MOON, ["landing"], view, 1737.4).slice(0, 3).map((mark) => mark.place.name.en));
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
160
|
+
export declare function placeMarks(places: readonly Place[], layers: readonly PlaceLayer[], view: SurfaceView, radiusKm: number): PlaceMark[];
|
|
161
|
+
/**
|
|
162
|
+
* The turn of a body that brings a place to the middle of the disc, for a view that is turned by a yaw about the body's pole and then a tilt about the screen's x axis, looking along -z (the `<wakusei-body>` view):
|
|
163
|
+
* the yaw and the tilt in degrees. Where the pole is tipped so far that no yaw puts the place in the plane the tilt turns, it comes as near as it can.
|
|
164
|
+
*
|
|
165
|
+
* @param pole - The body's north pole in the view before the turn.
|
|
166
|
+
* @param meridian - Its longitude 0 on the equator.
|
|
167
|
+
* @param lat - The place's latitude, degrees.
|
|
168
|
+
* @param lon - Its east longitude, degrees.
|
|
169
|
+
* @returns `{ yaw, tilt }`: the yaw about the pole, and the turn about the x axis (positive brings the place's y down to the middle).
|
|
170
|
+
*
|
|
171
|
+
* @example
|
|
172
|
+
* ```ts
|
|
173
|
+
* import { turnToPlace } from "@johnmorrisdotca/wakusei-planets/places";
|
|
174
|
+
*
|
|
175
|
+
* const turn = turnToPlace([0, 1, 0], [0, 0, 1], 0, 90);
|
|
176
|
+
* console.log(turn.yaw.toFixed(0), turn.tilt.toFixed(0));
|
|
177
|
+
* ```
|
|
178
|
+
*/
|
|
179
|
+
export declare function turnToPlace(pole: Vec3, meridian: Vec3, lat: number, lon: number): {
|
|
180
|
+
yaw: number;
|
|
181
|
+
tilt: number;
|
|
182
|
+
};
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { dot } from "./vec.js";
|
|
2
|
+
/**
|
|
3
|
+
* The layers of places a view can show, each switched on by itself: `landing` (the crewed landings, the landers and the rovers), `crash` (the crash, impact and atmospheric-entry sites), `planned` (announced landings) and `feature`
|
|
4
|
+
* (the named features of the surface).
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { PLACE_LAYERS } from "@johnmorrisdotca/wakusei-planets/places";
|
|
9
|
+
*
|
|
10
|
+
* console.log(PLACE_LAYERS.join(" "));
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export const PLACE_LAYERS = ["landing", "crash", "planned", "feature"];
|
|
14
|
+
/**
|
|
15
|
+
* The layer a kind of place is shown in.
|
|
16
|
+
*
|
|
17
|
+
* @param kind - The place's kind.
|
|
18
|
+
* @returns Its layer.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* import { layerOf } from "@johnmorrisdotca/wakusei-planets/places";
|
|
23
|
+
*
|
|
24
|
+
* console.log(layerOf("rover"), layerOf("impact"), layerOf("feature"));
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export function layerOf(kind) {
|
|
28
|
+
return kind === "crewed" || kind === "landing" || kind === "rover" ? "landing" : kind === "crash" || kind === "impact" || kind === "entry" ? "crash" : kind === "planned" ? "planned" : "feature";
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The layers an attribute asks for: a list of layer names with spaces or commas between (`"landing crash"`), `all` (or an empty value) for every layer, and `none` or `off` for none. Unknown words are left out.
|
|
32
|
+
*
|
|
33
|
+
* @param value - The attribute's value, or `null` when it is absent (no layers).
|
|
34
|
+
* @returns The layers, in `PLACE_LAYERS` order.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* import { readPlaceLayers } from "@johnmorrisdotca/wakusei-planets/places";
|
|
39
|
+
*
|
|
40
|
+
* console.log(readPlaceLayers("crash, landing"), readPlaceLayers(""), readPlaceLayers(null));
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export function readPlaceLayers(value) {
|
|
44
|
+
if (value === null)
|
|
45
|
+
return [];
|
|
46
|
+
const words = value.toLowerCase().split(/[\s,]+/).filter((word) => word !== "");
|
|
47
|
+
if (words.length === 0 || words.includes("all") || words.includes("on"))
|
|
48
|
+
return [...PLACE_LAYERS];
|
|
49
|
+
return PLACE_LAYERS.filter((layer) => words.includes(layer));
|
|
50
|
+
}
|
|
51
|
+
const RAD = Math.PI / 180;
|
|
52
|
+
/**
|
|
53
|
+
* A place's point on the body's surface in the scene, and the outward normal there: the planetocentric latitude and east longitude laid along the body's own axes onto its ellipsoid.
|
|
54
|
+
*
|
|
55
|
+
* @param view - The body as drawn.
|
|
56
|
+
* @param lat - Planetocentric latitude, degrees.
|
|
57
|
+
* @param lon - East longitude, degrees.
|
|
58
|
+
* @returns The point and the unit normal.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```ts
|
|
62
|
+
* import { surfacePoint } from "@johnmorrisdotca/wakusei-planets/places";
|
|
63
|
+
*
|
|
64
|
+
* const view = { centre: [0, 0, 0] as [number, number, number], radius: 2, pole: [0, 1, 0] as [number, number, number], meridian: [0, 0, 1] as [number, number, number], scale: [1, 1, 1] as [number, number, number], project: () => null, width: 1, height: 1, radiusPx: 1 };
|
|
65
|
+
* console.log(surfacePoint(view, 0, 90).point.map((n) => n.toFixed(1)).join(", "));
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export function surfacePoint(view, lat, lon) {
|
|
69
|
+
const { pole: p, meridian: m, scale: s } = view;
|
|
70
|
+
const e = [p[1] * m[2] - p[2] * m[1], p[2] * m[0] - p[0] * m[2], p[0] * m[1] - p[1] * m[0]];
|
|
71
|
+
// the direction in the body's own frame (east, pole, meridian), stretched onto the ellipsoid along that direction: planetocentric, so the point is where that line from the centre meets the surface
|
|
72
|
+
const ux = Math.cos(lat * RAD) * Math.sin(lon * RAD);
|
|
73
|
+
const uy = Math.sin(lat * RAD);
|
|
74
|
+
const uz = Math.cos(lat * RAD) * Math.cos(lon * RAD);
|
|
75
|
+
const k = 1 / Math.hypot(ux / s[0], uy / s[1], uz / s[2]);
|
|
76
|
+
const [lx, ly, lz] = [ux * k, uy * k, uz * k];
|
|
77
|
+
const r = view.radius;
|
|
78
|
+
const point = [view.centre[0] + r * (e[0] * lx + p[0] * ly + m[0] * lz), view.centre[1] + r * (e[1] * lx + p[1] * ly + m[1] * lz), view.centre[2] + r * (e[2] * lx + p[2] * ly + m[2] * lz)];
|
|
79
|
+
const [nx, ny, nz] = [lx / (s[0] * s[0]), ly / (s[1] * s[1]), lz / (s[2] * s[2])];
|
|
80
|
+
const n = [e[0] * nx + p[0] * ny + m[0] * nz, e[1] * nx + p[1] * ny + m[1] * nz, e[2] * nx + p[2] * ny + m[2] * nz];
|
|
81
|
+
const len = Math.hypot(n[0], n[1], n[2]) || 1;
|
|
82
|
+
return { point, normal: [n[0] / len, n[1] / len, n[2] / len] };
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* The rules that keep the marks quiet, in CSS pixels: nothing is marked on a body under `fromPx` of radius on the screen; a named feature is marked once it is `featureFromPx` across (a famous one at any size);
|
|
86
|
+
* no two marks are closer than `gapPx` (the one chosen first keeps its place); and a body gets one mark for every `sharePx` of its radius, 8 at least and `most` at most.
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```ts
|
|
90
|
+
* import { MARK_RULES } from "@johnmorrisdotca/wakusei-planets/places";
|
|
91
|
+
*
|
|
92
|
+
* console.log(MARK_RULES.gapPx, MARK_RULES.most);
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
export const MARK_RULES = { fromPx: 40, featureFromPx: 14, gapPx: 12, sharePx: 4, most: 60 };
|
|
96
|
+
/**
|
|
97
|
+
* The marks to lay over a body: the places of the layers asked for that face the viewer (not too near the edge of the disc, where they would crowd), are inside the view, and are not crowded out by a mark
|
|
98
|
+
* that comes first. The visited sites come first, the famous before the rest, then the named features by size, and a feature is marked only once it is big enough on the screen to show (`MARK_RULES`;
|
|
99
|
+
* any famous one). Nothing is marked on a body too small on the screen, and a small body gets fewer marks than a big one.
|
|
100
|
+
*
|
|
101
|
+
* @param places - The body's list.
|
|
102
|
+
* @param layers - The layers to show.
|
|
103
|
+
* @param view - The body as drawn.
|
|
104
|
+
* @param radiusKm - The body's radius in kilometres, to tell a feature's size on the screen.
|
|
105
|
+
* @returns The marks, in the order they were chosen.
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* ```ts
|
|
109
|
+
* import { placeMarks } from "@johnmorrisdotca/wakusei-planets/places";
|
|
110
|
+
* import { PLACES_MOON } from "@johnmorrisdotca/wakusei-planets/places/moon";
|
|
111
|
+
*
|
|
112
|
+
* const view = { centre: [0, 0, 0] as [number, number, number], radius: 1, pole: [0, 1, 0] as [number, number, number], meridian: [0, 0, 1] as [number, number, number], scale: [1, 1, 1] as [number, number, number], toward: [0, 0, 1] as [number, number, number],
|
|
113
|
+
* project: (p: [number, number, number]) => ({ x: 200 + p[0] * 180, y: 200 - p[1] * 180 }), width: 400, height: 400, radiusPx: 180 };
|
|
114
|
+
* console.log(placeMarks(PLACES_MOON, ["landing"], view, 1737.4).slice(0, 3).map((mark) => mark.place.name.en));
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
export function placeMarks(places, layers, view, radiusKm) {
|
|
118
|
+
if (layers.length === 0 || !(view.radiusPx >= MARK_RULES.fromPx))
|
|
119
|
+
return [];
|
|
120
|
+
const wanted = [];
|
|
121
|
+
for (const place of places) {
|
|
122
|
+
const layer = layerOf(place.kind);
|
|
123
|
+
if (!layers.includes(layer))
|
|
124
|
+
continue;
|
|
125
|
+
if (layer === "feature" && place.famous !== true && ((place.feature?.diameterKm ?? 0) / radiusKm) * view.radiusPx < MARK_RULES.featureFromPx)
|
|
126
|
+
continue;
|
|
127
|
+
wanted.push(place);
|
|
128
|
+
}
|
|
129
|
+
const rank = (place) => (place.kind === "feature" ? 2 : 0) + (place.famous === true ? 0 : 1);
|
|
130
|
+
wanted.sort((a, b) => rank(a) - rank(b) || (b.feature?.diameterKm ?? 0) - (a.feature?.diameterKm ?? 0));
|
|
131
|
+
const most = Math.max(8, Math.min(MARK_RULES.most, Math.round(view.radiusPx / MARK_RULES.sharePx)));
|
|
132
|
+
const out = [];
|
|
133
|
+
for (const place of wanted) {
|
|
134
|
+
if (out.length >= most)
|
|
135
|
+
break;
|
|
136
|
+
const { point, normal } = surfacePoint(view, place.lat, place.lon);
|
|
137
|
+
const sight = view.eye !== undefined ? [view.eye[0] - point[0], view.eye[1] - point[1], view.eye[2] - point[2]] : (view.toward ?? [0, 0, 1]);
|
|
138
|
+
const len = Math.hypot(sight[0], sight[1], sight[2]) || 1;
|
|
139
|
+
// a little short of the limb: a mark seen edge-on is a crowd of dots on the rim, and the surface there is a sliver
|
|
140
|
+
if (dot(normal, sight) / len < 0.12)
|
|
141
|
+
continue;
|
|
142
|
+
const at = view.project(point);
|
|
143
|
+
if (at === null || at.x < 0 || at.y < 0 || at.x > view.width || at.y > view.height)
|
|
144
|
+
continue;
|
|
145
|
+
if (out.some((mark) => Math.hypot(mark.x - at.x, mark.y - at.y) < MARK_RULES.gapPx))
|
|
146
|
+
continue;
|
|
147
|
+
out.push({ place, layer: layerOf(place.kind), x: at.x, y: at.y });
|
|
148
|
+
}
|
|
149
|
+
return out;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* The turn of a body that brings a place to the middle of the disc, for a view that is turned by a yaw about the body's pole and then a tilt about the screen's x axis, looking along -z (the `<wakusei-body>` view):
|
|
153
|
+
* the yaw and the tilt in degrees. Where the pole is tipped so far that no yaw puts the place in the plane the tilt turns, it comes as near as it can.
|
|
154
|
+
*
|
|
155
|
+
* @param pole - The body's north pole in the view before the turn.
|
|
156
|
+
* @param meridian - Its longitude 0 on the equator.
|
|
157
|
+
* @param lat - The place's latitude, degrees.
|
|
158
|
+
* @param lon - Its east longitude, degrees.
|
|
159
|
+
* @returns `{ yaw, tilt }`: the yaw about the pole, and the turn about the x axis (positive brings the place's y down to the middle).
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* ```ts
|
|
163
|
+
* import { turnToPlace } from "@johnmorrisdotca/wakusei-planets/places";
|
|
164
|
+
*
|
|
165
|
+
* const turn = turnToPlace([0, 1, 0], [0, 0, 1], 0, 90);
|
|
166
|
+
* console.log(turn.yaw.toFixed(0), turn.tilt.toFixed(0));
|
|
167
|
+
* ```
|
|
168
|
+
*/
|
|
169
|
+
export function turnToPlace(pole, meridian, lat, lon) {
|
|
170
|
+
const e = [pole[1] * meridian[2] - pole[2] * meridian[1], pole[2] * meridian[0] - pole[0] * meridian[2], pole[0] * meridian[1] - pole[1] * meridian[0]];
|
|
171
|
+
const c = Math.cos(lat * RAD);
|
|
172
|
+
const d = [0, 1, 2].map((i) => c * Math.cos(lon * RAD) * meridian[i] + c * Math.sin(lon * RAD) * e[i] + Math.sin(lat * RAD) * pole[i]);
|
|
173
|
+
// turning d about the pole by `yaw` (Rodrigues): x = A cos + B sin + C. Choose the yaw that makes x zero and leaves the place on the near side.
|
|
174
|
+
const pd = dot(pole, d);
|
|
175
|
+
const A = d[0] - pole[0] * pd;
|
|
176
|
+
const B = pole[1] * d[2] - pole[2] * d[1];
|
|
177
|
+
const C = pole[0] * pd;
|
|
178
|
+
const R = Math.hypot(A, B) || 1e-12;
|
|
179
|
+
const phi = Math.atan2(B, A);
|
|
180
|
+
const spread = Math.acos(Math.max(-1, Math.min(1, -C / R)));
|
|
181
|
+
const turned = (yaw) => {
|
|
182
|
+
const cs = Math.cos(yaw);
|
|
183
|
+
const sn = Math.sin(yaw);
|
|
184
|
+
const k = pole;
|
|
185
|
+
const kv = [k[1] * d[2] - k[2] * d[1], k[2] * d[0] - k[0] * d[2], k[0] * d[1] - k[1] * d[0]];
|
|
186
|
+
return [d[0] * cs + kv[0] * sn + k[0] * pd * (1 - cs), d[1] * cs + kv[1] * sn + k[1] * pd * (1 - cs), d[2] * cs + kv[2] * sn + k[2] * pd * (1 - cs)];
|
|
187
|
+
};
|
|
188
|
+
const a = turned(phi + spread);
|
|
189
|
+
const b = turned(phi - spread);
|
|
190
|
+
const [yaw, d1] = a[2] >= b[2] ? [phi + spread, a] : [phi - spread, b];
|
|
191
|
+
const tilt = Math.atan2(d1[1], d1[2]);
|
|
192
|
+
const wrap = (deg) => ((((deg + 180) % 360) + 360) % 360) - 180;
|
|
193
|
+
return { yaw: wrap(yaw / RAD), tilt: tilt / RAD };
|
|
194
|
+
}
|
package/dist/places/mars.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Place } from "../places.ts";
|
|
2
2
|
/**
|
|
3
|
-
* Every place on the Mars the package knows: the sites first, by date, then the named features by size. A place's `kind` says what it is (`placesOfKind` from `/places` picks by it).
|
|
3
|
+
* Every place on the Mars the package knows: the sites first, by date, then the planned landings, then the named features by size. A place's `kind` says what it is (`placesOfKind` from `/places` picks by it).
|
|
4
4
|
*
|
|
5
5
|
* @example
|
|
6
6
|
* ```ts
|
package/dist/places/mars.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
// The places on the Mars: landing, rover, crash and impact sites, and the named features, as one list. See `/places` for the record's shape and the lookups.
|
|
2
2
|
import { PLACES_MARS as DATA } from "../data/places-mars.js";
|
|
3
|
+
import { PLANNED_MARS } from "../data/places-planned.js";
|
|
4
|
+
const ALL = DATA;
|
|
3
5
|
/**
|
|
4
|
-
* Every place on the Mars the package knows: the sites first, by date, then the named features by size. A place's `kind` says what it is (`placesOfKind` from `/places` picks by it).
|
|
6
|
+
* Every place on the Mars the package knows: the sites first, by date, then the planned landings, then the named features by size. A place's `kind` says what it is (`placesOfKind` from `/places` picks by it).
|
|
5
7
|
*
|
|
6
8
|
* @example
|
|
7
9
|
* ```ts
|
|
@@ -10,4 +12,4 @@ import { PLACES_MARS as DATA } from "../data/places-mars.js";
|
|
|
10
12
|
* console.log(PLACES_MARS.length, "places;", PLACES_MARS.filter((place) => place.kind === "landing").length, "landings");
|
|
11
13
|
* ```
|
|
12
14
|
*/
|
|
13
|
-
export const PLACES_MARS =
|
|
15
|
+
export const PLACES_MARS = [...ALL.filter((place) => place.kind !== "feature"), ...PLANNED_MARS, ...ALL.filter((place) => place.kind === "feature")];
|
package/dist/places/moon.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Place } from "../places.ts";
|
|
2
2
|
/**
|
|
3
|
-
* Every place on the Moon the package knows: the sites first, by date, then the named features by size. A place's `kind` says what it is (`placesOfKind` from `/places` picks by it).
|
|
3
|
+
* Every place on the Moon the package knows: the sites first, by date, then the planned landings, then the named features by size. A place's `kind` says what it is (`placesOfKind` from `/places` picks by it).
|
|
4
4
|
*
|
|
5
5
|
* @example
|
|
6
6
|
* ```ts
|
package/dist/places/moon.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
// The places on the Moon: landing, rover, crash and impact sites, and the named features, as one list. See `/places` for the record's shape and the lookups.
|
|
2
2
|
import { PLACES_MOON as DATA } from "../data/places-moon.js";
|
|
3
|
+
import { PLANNED_MOON } from "../data/places-planned.js";
|
|
4
|
+
const ALL = DATA;
|
|
3
5
|
/**
|
|
4
|
-
* Every place on the Moon the package knows: the sites first, by date, then the named features by size. A place's `kind` says what it is (`placesOfKind` from `/places` picks by it).
|
|
6
|
+
* Every place on the Moon the package knows: the sites first, by date, then the planned landings, then the named features by size. A place's `kind` says what it is (`placesOfKind` from `/places` picks by it).
|
|
5
7
|
*
|
|
6
8
|
* @example
|
|
7
9
|
* ```ts
|
|
@@ -10,4 +12,4 @@ import { PLACES_MOON as DATA } from "../data/places-moon.js";
|
|
|
10
12
|
* console.log(PLACES_MOON.length, "places;", PLACES_MOON.filter((place) => place.kind === "landing").length, "landings");
|
|
11
13
|
* ```
|
|
12
14
|
*/
|
|
13
|
-
export const PLACES_MOON =
|
|
15
|
+
export const PLACES_MOON = [...ALL.filter((place) => place.kind !== "feature"), ...PLANNED_MOON, ...ALL.filter((place) => place.kind === "feature")];
|