@johnmorrisdotca/wakusei-planets 0.57.0 → 0.58.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 CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.58.0] - 2026-11-17
6
+
7
+ - **Landing sites with their country's flag** (MODULES-1398; John Morris, 2026-11-16). New entry point `/landing-sites`: `LANDING_SITES`, 39 landings that touched down softly and were heard from (28 on the Moon: Apollo 11 to 17, Surveyor 1, 3, 5, 6 and 7, Luna 9, 13, 16, 17, 20, 21, 23 and 24, Chang'e 3 to 6, Chandrayaan-3, SLIM, IM-1, Blue Ghost 1, IM-2; 11 on Mars: Mars 3, Viking 1 and 2, Pathfinder, Spirit, Opportunity, Phoenix, Curiosity, InSight, Perseverance, Zhurong), each with its names in English and Japanese, its day, its point, its agency, its ISO country code and the page each coordinate is from, plus `landingSitesOf`, `findLandingSite` and `flagCodeOf`. The points are the place tables' own and a test pins them together; the Moon's were compared row by row with NASA NSSDCA's table. The attribute `site-flags` (property `siteFlags`) on `<wakusei-body>` and `<wakusei-space>` puts the country's flag in the tip of a place and, on a body at least 110 pixels of radius across on the screen, names each landing site beside its dot with its flag; the flag is `<hata-flag>`, drawn when the page has imported `@johnmorrisdotca/hata` (no new dependency: without it only the name shows). `wakusei-place`'s `detail` gains `site`. Nothing changes with the attribute off. The demo's Places row has a Flags button (`flags=1` in the address). `@johnmorrisdotca/hata` is a dev dependency, for the tests and the demo. Guide: Landing sites, with their flags.
8
+
5
9
  ## [0.57.0] - 2026-11-17
6
10
 
7
11
  - **A planet, a moon or the Sun is round wherever it is in the picture** (MODULES-1390; John Morris, 2026-11-20). In the space view's wide windows the Sun near the left edge was a wide flat ellipse, the Moon at the bottom stretched tall and the Earth near a corner stretched along the diagonal. The cause is the perspective camera itself, not a stale aspect, a non-uniform scale on the magnified bodies or a frame's up vector: a sphere `theta` off the line of sight is drawn `1 / cos(theta)` as long as it is wide, along the line to the middle of the picture, and the view's field of view (35 degrees top to bottom, 80 degrees across a 2012 by 745 window) puts the edge 37 degrees out and a corner more. Measured as the long axis over the short from the drawn pixels, in a 2012 by 745 window: Venus 1.267, the Earth 1.081 (the painter's own bodies at the edges and corners of that window: 1.21 to 1.24), all now 1.00 to 1.01. A narrower field of view was not taken: within 3% at the corners it would need under 30 degrees across, which moves the camera three times as far back and changes every travel and arrival framing. Each body is now drawn as the ellipsoid that projects to a circle: the sphere squeezed, across the line of sight to it, by `1 / sqrt(1 + tan²θ · d² / (d² − r²))` (the circular sections of the cone of sight), done in the vertex shaders of the globe, its rings and its name (`src/scene/round.ts`). The colours, light, map, rings, glow and name are the sphere's own, and the body's centre, its depth, picking and every camera path (travel, arrival, the Pair and Body frames) are unchanged. The radius on the screen (`placeOf(id).r`, what a press is tested against, the names' offset and the map tiles' choice) is now the drawn one, `1 / cos(theta)` times that in the middle (a press near the edge of a wide window used to miss the outer fifth of a disc), and the marks over the Earth and over a body follow the squeezed surface. `PaintInfo.round` (default `true`, in effect only with `view` and a perspective camera) turns it off for a scene of your own. Tests: `e2e/round-bodies.demo.ts` (the Sun, Mars and the Moon at the left, top, right, bottom and corners of a wide, a tall and a square window; the Sun's glow; the space view's Earth, Moon and Venus in two wide windows) and `test/round.test.ts`.
package/README.md CHANGED
@@ -19,7 +19,7 @@ Wakusei Planets runs in the browser of a phone, a tablet or a computer: nothing
19
19
 
20
20
  <p align="center"><img alt="The demo on a desk: Saturn in the painted look, turning in the big view, with the page's links to the portrait builder, the colouring sheets, the space view, the star page and the size line-up above it, and the choice of body and its moons below" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/main/docs/images/home-desk.webp" width="620"> <img alt="The same page on a phone: the same links in rows, and Saturn in the painted look below them" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/main/docs/images/home-phone.webp" width="200"></p>
21
21
 
22
- <p align="center"><img alt="Every body at one scale, the Earth among them: each small body has a magnified picture joined by a line, and the Sun shows only its edge" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/v0.57.0/docs/images/lineup-desk.png" width="640"></p>
22
+ <p align="center"><img alt="Every body at one scale, the Earth among them: each small body has a magnified picture joined by a line, and the Sun shows only its edge" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/v0.58.0/docs/images/lineup-desk.png" width="640"></p>
23
23
 
24
24
  ## Who it is for
25
25
 
@@ -388,7 +388,7 @@ The tiles of every body share one 48 MB budget, six loads at a time for a source
388
388
 
389
389
  ## The portrait builder
390
390
 
391
- <p align="center"><img alt="The Sun and the planets in an arc, painted, with their names, in the portrait builder" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/v0.57.0/docs/images/portrait-family.png" width="640"></p>
391
+ <p align="center"><img alt="The Sun and the planets in an arc, painted, with their names, in the portrait builder" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/v0.58.0/docs/images/portrait-family.png" width="640"></p>
392
392
 
393
393
  [The portrait builder](https://johnmorrisdotca.github.io/wakusei-planets/portrait.html) puts any bodies in one picture: drag them, size them, turn them, order them front to back, arrange them in a row, an arc, a grid or at true orbit distance (true or readable sizes, a planet's moons round it in orbit order), light them from one direction, and take the code, a PNG or an SVG. The scene is kept in the address, and every body is drawn in one WebGL scene, so the page holds one WebGL context. [The portrait builder](docs/guides/portrait-builder.md) is its guide.
394
394
 
@@ -445,6 +445,7 @@ The reference is a site, made from the source's own doc comments: every export h
445
445
  | `.../space` | Where the Sun, the Moon and the planets are for a date, in two scales, and where a camera riding along looks: `frameAt`, `createTrack`, `placeSun`, `placeAround`, `ridePose`. No browser. |
446
446
  | `.../space/element` | `<wakusei-space>`: the Earth, the Moon, the Sun and the planets in their places. |
447
447
  | `.../plan` | The top-down plan: `planAt`, `planSvg`, `planText`. `.../plan/element` is `<wakusei-plan>`, in SVG with no WebGL. |
448
+ | `.../landing-sites` | The 39 soft landings on the Moon and Mars as plain data: `LANDING_SITES`, `landingSitesOf`, `findLandingSite`, `flagCodeOf`. No browser, no three.js. |
448
449
  | `.../nearest` | The bodies nearest to a body on a date (`nearest`, `within`), when two bodies come closest (`closestApproach`, `conjunctions`) and how far apart they are (`distance`, `distanceRange`). No browser. |
449
450
  | `.../sheets` | Printable colouring sheets for children: the Sun, the planets and the big moons in thick lines with the real colours and three facts, and all the planets at one scale, in English and Japanese (`kidsSvg`, `kidsSheet`, `kidsFacts`). |
450
451
  | `.../look` | What a body needs to be drawn with three.js. |
@@ -494,6 +495,7 @@ Each guide has a Japanese twin in [docs/guides/ja](docs/guides/ja/getting-starte
494
495
  | [Starman and the Tesla Roadster](docs/guides/roadster.md) | where the car launched on the first Falcon Heavy is on any date from 2018 to the start of 2036, its distances, speeds, orbit and key moments |
495
496
  | [Comets](docs/guides/comets.md) | 34 well-known comets with orbits from JPL: where each is on any date, its distances, orbit line, last and next perihelion, meteor showers, and a door to add a new comet |
496
497
  | [Places on the Moon, Mars and 31 more bodies](docs/guides/places.md) | every landing, rover, crash, impact and atmospheric-entry site and the named features of 33 bodies, with positions, dates and sources, the famous ones marked, and the Sun's point, the terminator and the local solar time on any body |
498
+ | [Landing sites, with their flags](docs/guides/landing-sites.md) | the 28 soft landings on the Moon and 11 on Mars as one small plain list (names in English and Japanese, day, point, agency, country, the page each coordinate is from), and `site-flags` on the 3D views: the sites named beside their dots with their country's flag, from `@johnmorrisdotca/hata` when the page has it |
497
499
  | [Which face of a body the view looks at](docs/guides/which-face.md) | `subCameraPoint()` and `faceTo()` on the space view and on a body's picture: the longitude and latitude under the camera, and a turn to a point, for a card picture that follows the view |
498
500
  | [Data files](docs/guides/data-files.md) | CSV and Parquet tables of the bodies, orbits and spacecraft, for Python, R and Rust |
499
501
  | [Serve it yourself](docs/guides/serve-it-yourself.md) | A small Node server over the package, that you host |
@@ -537,7 +539,7 @@ BODIES.pluto.kind; // "dwarf-planet"
537
539
 
538
540
  If this package helps a paper, a talk or a class, please cite it as software. GitHub's "Cite this repository" button reads [CITATION.cff](CITATION.cff) and gives BibTeX and APA; in plain text:
539
541
 
540
- > Morris, J. (2026). *Wakusei Planets* (version 0.57.0) [Computer software]. https://github.com/johnmorrisdotca/wakusei-planets
542
+ > Morris, J. (2026). *Wakusei Planets* (version 0.58.0) [Computer software]. https://github.com/johnmorrisdotca/wakusei-planets
541
543
 
542
544
  Cite the version you used (`npm ls @johnmorrisdotca/wakusei-planets`), and cite the sources of the numbers you use as well: [NOTICE.md](NOTICE.md) names each one, with the paper or the page it was read from (the IAU working group's report for sizes and poles, VSOP87B, ELP2000-82B, L1.2 and TASS1.7 for positions, and NASA's JPL Horizons for the fits and the spacecraft).
543
545
 
package/dist/element.d.ts CHANGED
@@ -102,6 +102,13 @@ export declare class WakuseiBody extends HTMLElement {
102
102
  */
103
103
  get places(): PlaceLayer[];
104
104
  set places(layers: readonly PlaceLayer[] | null);
105
+ /**
106
+ * Whether the places carry their country's flag (the attribute `site-flags`): the tip of a place with a country shows its flag, and on a body close enough on the screen (110 pixels of radius) the landing sites (`LANDING_SITES` from
107
+ * `/landing-sites`) are named beside their dots, each with its flag. The flag is `<hata-flag>` from `@johnmorrisdotca/hata`, which the page imports itself (`import "@johnmorrisdotca/hata/element/define"`); until it is defined the name stands alone. Needs `places`.
108
+ * The `wakusei-place` event's detail carries the landing site as `site` where the place is one. Setting it writes the attribute.
109
+ */
110
+ get siteFlags(): boolean;
111
+ set siteFlags(on: boolean);
105
112
  /** The marks laid on the body now: each place's id, its layer and where its mark is, in CSS pixels from the picture's top left. */
106
113
  get placesShown(): readonly {
107
114
  id: string;
package/dist/element.js CHANGED
@@ -107,7 +107,7 @@ const TEMPLATE = `<style>
107
107
  * ```
108
108
  */
109
109
  export class WakuseiBody extends HTMLElement {
110
- static observedAttributes = ["body", "star", "quality", ...STAR_ATTRS, "look", "size", "time", "tilt", "pitch", "phase", "meridian", "turn", "rate", "moons", "range", "scale-to", "span-km", "fit", "live", "texture-base", "texture-far-base", "tiles", "data", "lang", "labels", "places", "surface-names", "cutaway", ...NAME_LABEL_ATTRIBUTES];
110
+ static observedAttributes = ["body", "star", "quality", ...STAR_ATTRS, "look", "size", "time", "tilt", "pitch", "phase", "meridian", "turn", "rate", "moons", "range", "scale-to", "span-km", "fit", "live", "texture-base", "texture-far-base", "tiles", "data", "lang", "labels", "places", "surface-names", "site-flags", "cutaway", ...NAME_LABEL_ATTRIBUTES];
111
111
  #stage;
112
112
  #state = "line";
113
113
  #renderer;
@@ -287,6 +287,17 @@ export class WakuseiBody extends HTMLElement {
287
287
  else
288
288
  this.setAttribute("places", layers.join(" "));
289
289
  }
290
+ /**
291
+ * Whether the places carry their country's flag (the attribute `site-flags`): the tip of a place with a country shows its flag, and on a body close enough on the screen (110 pixels of radius) the landing sites (`LANDING_SITES` from
292
+ * `/landing-sites`) are named beside their dots, each with its flag. The flag is `<hata-flag>` from `@johnmorrisdotca/hata`, which the page imports itself (`import "@johnmorrisdotca/hata/element/define"`); until it is defined the name stands alone. Needs `places`.
293
+ * The `wakusei-place` event's detail carries the landing site as `site` where the place is one. Setting it writes the attribute.
294
+ */
295
+ get siteFlags() {
296
+ return this.hasAttribute("site-flags");
297
+ }
298
+ set siteFlags(on) {
299
+ this.toggleAttribute("site-flags", on);
300
+ }
290
301
  /** The marks laid on the body now: each place's id, its layer and where its mark is, in CSS pixels from the picture's top left. */
291
302
  get placesShown() {
292
303
  return this.#placeLayer?.shown ?? [];
@@ -425,7 +436,8 @@ export class WakuseiBody extends HTMLElement {
425
436
  if (this.#placeLayer === undefined && this.shadowRoot !== null) {
426
437
  this.#placeLayer = createPlaceLayer(this.shadowRoot, {
427
438
  lang: () => (this.getAttribute("lang") === "ja" ? "ja" : "en"),
428
- pick: (place, at) => this.dispatchEvent(new CustomEvent("wakusei-place", { detail: { body, place, x: at.x, y: at.y }, bubbles: true, composed: true })),
439
+ flags: () => this.hasAttribute("site-flags"),
440
+ pick: (place, site, at) => this.dispatchEvent(new CustomEvent("wakusei-place", { detail: { body, place, site, x: at.x, y: at.y }, bubbles: true, composed: true })),
429
441
  });
430
442
  // a picture with buttons in it is a group, not an image
431
443
  if (this.getAttribute("role") === "img")
@@ -456,7 +468,7 @@ export class WakuseiBody extends HTMLElement {
456
468
  height: h,
457
469
  radiusPx: (Math.min(w, h) / 2) * (state.zoom / state.extent),
458
470
  }, facts.radiusKm, names, [], this.getAttribute("lang") === "ja" ? "ja" : "en");
459
- this.#placeLayer.set(marks);
471
+ this.#placeLayer.set(marks, (Math.min(w, h) / 2) * (state.zoom / state.extent));
460
472
  }
461
473
  /** What the element is doing now. */
462
474
  get state() {
@@ -561,7 +573,7 @@ export class WakuseiBody extends HTMLElement {
561
573
  this.#refreshLimits();
562
574
  }
563
575
  this.#lastAnchors = -1;
564
- if (name === "places" || name === "lang" || name === "body" || name === "look" || name === "star" || name === "surface-names")
576
+ if (name === "places" || name === "site-flags" || name === "lang" || name === "body" || name === "look" || name === "star" || name === "surface-names")
565
577
  this.#markPlaces();
566
578
  this.#queue();
567
579
  }
@@ -0,0 +1,120 @@
1
+ /**
2
+ * Where a site's coordinates come from: the source's name and the address of the page the numbers were read from.
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * import type { LandingSource } from "@johnmorrisdotca/wakusei-planets/landing-sites";
7
+ * import { LANDING_SITES } from "@johnmorrisdotca/wakusei-planets/landing-sites";
8
+ *
9
+ * const source: LandingSource = LANDING_SITES[0]!.source;
10
+ * console.log(source.name, source.url);
11
+ * ```
12
+ */
13
+ export interface LandingSource {
14
+ name: string;
15
+ url: string;
16
+ }
17
+ /**
18
+ * One landing site. `place` is the id of the same site in the place tables (`findPlace` on `/places/moon` or `/places/mars` takes it, and the 3D views' `wakusei-place` event carries it). Latitude is planetocentric and longitude east, from -180 to 180,
19
+ * as in the place tables. `country` is an ISO 3166-1 alpha-2 code in capitals, and `SU` for the Soviet Union (the code ISO 3166-3 kept for it); `flagCodeOf` turns it into the code a flag element wants. `agency` is who flew it.
20
+ * `source` is where the numbers were read, `checkedAgainst` a second NASA page that agrees, `page` the NSSDCA page of the mission where there is one, and `stand` the id of the site in the standing view (`/surface`), for the one place a reader can stand.
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * import type { LandingSite } from "@johnmorrisdotca/wakusei-planets/landing-sites";
25
+ * import { LANDING_SITES } from "@johnmorrisdotca/wakusei-planets/landing-sites";
26
+ *
27
+ * const site: LandingSite = LANDING_SITES.find((one) => one.id === "moon/apollo-17")!;
28
+ * console.log(site.name.en, site.lat, site.lon, site.country, site.stand);
29
+ * ```
30
+ */
31
+ export interface LandingSite {
32
+ /** `<body>/<slug>`, unique. */
33
+ id: string;
34
+ /** The id of the same place in the place tables. */
35
+ place: string;
36
+ /** The ids of the other places the tables hold on the same spot (the rover, the descent stage), so a mark on any of them is this site. */
37
+ alsoAt?: readonly string[];
38
+ body: "moon" | "mars";
39
+ name: {
40
+ en: string;
41
+ ja: string;
42
+ };
43
+ /** When it touched down (ISO, UTC, to the minute). */
44
+ date: string;
45
+ lat: number;
46
+ lon: number;
47
+ agency: {
48
+ en: string;
49
+ ja: string;
50
+ };
51
+ /** ISO 3166-1 alpha-2 in capitals, or `SU`. */
52
+ country: string;
53
+ /** True where the source gives the point as "about" or says the real place can be kilometres away. */
54
+ approximate?: true;
55
+ /** The id of the site in the standing view, where a reader can stand there. */
56
+ stand?: string;
57
+ /** A word about how it ended, in English, where the sources say. */
58
+ note?: string;
59
+ source: LandingSource;
60
+ /** A second page that gives the same place. */
61
+ checkedAgainst?: LandingSource;
62
+ /** The mission's page at NASA NSSDCA, where it loads. */
63
+ page?: string;
64
+ }
65
+ /**
66
+ * Every landing on the Moon and Mars that touched down softly and was heard from, 28 on the Moon (Apollo 11 to 17, Surveyor 1, 3, 5, 6 and 7, Luna 9, 13, 16, 17, 20, 21, 23 and 24, Chang'e 3, 4, 5 and 6, Chandrayaan-3, SLIM, IM-1, Blue Ghost 1 and IM-2) and 11 on
67
+ * Mars (Mars 3, Viking 1 and 2, Pathfinder, Spirit, Opportunity, Phoenix, Curiosity, InSight, Perseverance and Zhurong), the Moon's first and Mars's after, each by date. Landers that did not survive the landing (Mars 2 and 6, Beagle 2, Schiaparelli) are not here; they are
68
+ * in the place tables as crashes.
69
+ *
70
+ * @example
71
+ * ```ts
72
+ * import { LANDING_SITES } from "@johnmorrisdotca/wakusei-planets/landing-sites";
73
+ *
74
+ * console.log(LANDING_SITES.length, "sites;", LANDING_SITES.filter((site) => site.country === "CN").map((site) => site.name.en).join(", "));
75
+ * ```
76
+ */
77
+ export declare const LANDING_SITES: readonly LandingSite[];
78
+ /**
79
+ * The landing sites of one body, by date.
80
+ *
81
+ * @param body - `moon` or `mars`.
82
+ * @returns Its sites.
83
+ *
84
+ * @example
85
+ * ```ts
86
+ * import { landingSitesOf } from "@johnmorrisdotca/wakusei-planets/landing-sites";
87
+ *
88
+ * console.log(landingSitesOf("mars").map((site) => `${site.name.en} ${site.date.slice(0, 4)}`).join(", "));
89
+ * ```
90
+ */
91
+ export declare function landingSitesOf(body: LandingSite["body"]): LandingSite[];
92
+ /**
93
+ * A landing site by its id (`moon/apollo-11`), by the id of its place in the place tables (`moon/apollo-11-lunar-module`, or its rover's), or by its name in English or Japanese in any case, or `undefined`.
94
+ *
95
+ * @param text - The id, place id or name.
96
+ * @returns The site, or `undefined` when none matches.
97
+ *
98
+ * @example
99
+ * ```ts
100
+ * import { findLandingSite } from "@johnmorrisdotca/wakusei-planets/landing-sites";
101
+ *
102
+ * console.log(findLandingSite("moon/apollo-11-lunar-module")?.name.ja, findLandingSite("zhurong")?.country, findLandingSite("nowhere"));
103
+ * ```
104
+ */
105
+ export declare function findLandingSite(text: string): LandingSite | undefined;
106
+ /**
107
+ * The code a flag element (`<hata-flag code="...">`, from `@johnmorrisdotca/hata`) takes for a country as the place tables and the landing sites write it: the two letters of ISO 3166-1 in capitals, `SU` for the Soviet Union, and GCAT's `J` for Japan
108
+ * (`JP`). A country with no flag to show (an agency of several countries) or with no code gives `undefined`.
109
+ *
110
+ * @param country - A site's `country`, or a place's.
111
+ * @returns The code, or `undefined`.
112
+ *
113
+ * @example
114
+ * ```ts
115
+ * import { flagCodeOf } from "@johnmorrisdotca/wakusei-planets/landing-sites";
116
+ *
117
+ * console.log(flagCodeOf("J"), flagCodeOf("SU"), flagCodeOf("us"), flagCodeOf("ESA"), flagCodeOf(undefined));
118
+ * ```
119
+ */
120
+ export declare function flagCodeOf(country: string | undefined): string | undefined;
@@ -0,0 +1,339 @@
1
+ // The landing sites: every landing on the Moon and Mars that touched down softly and was heard from, as one small plain list a page can draw a card, a flat map or a marker from. Pure: no DOM, no three.js, no tables of places;
2
+ // the record carries what a card needs (names in English and Japanese, the day, the point, who flew it, the country as a flag code, and where each number is from). The points are the ones the place tables (`/places/moon`, `/places/mars`)
3
+ // hold, and `test/landing-sites.test.ts` pins the two together, so a site on a card is the site on the globe. Typed by hand from the sources named in each record; nothing is guessed, and a site with no primary source is left out.
4
+ // Moon: NASA NSSDCA's "Table of Anthropogenic Impacts and Spacecraft on the Moon", read 2026-11-17 (every row below was checked against the page). Mars: the Mars Orbital Data Explorer's list of landing sites, NASA NSSDCA's Viking pages,
5
+ // NASA GISS's Mars24 lander list and GCAT, each named in the record; where the record's own source is GCAT, a NASA page (`checkedAgainst`) agrees with it to the 0.01 degree the page prints.
6
+ const NSS = "https://nssdc.gsfc.nasa.gov/nmc/spacecraft/display.action?id=";
7
+ const AGENCY = {
8
+ NASA: { en: "NASA", ja: "NASA" },
9
+ USSR: { en: "Soviet space programme", ja: "ソ連の宇宙計画" },
10
+ CNSA: { en: "CNSA (China)", ja: "中国国家航天局 (CNSA)" },
11
+ ISRO: { en: "ISRO", ja: "インド宇宙研究機関 (ISRO)" },
12
+ JAXA: { en: "JAXA", ja: "宇宙航空研究開発機構 (JAXA)" },
13
+ IM: { en: "Intuitive Machines", ja: "インテュイティブ・マシーンズ" },
14
+ FF: { en: "Firefly Aerospace", ja: "ファイアフライ・エアロスペース" },
15
+ };
16
+ const SRC_NASA_MOON = { name: "NASA NSSDCA, Table of Anthropogenic Impacts and Spacecraft on the Moon", url: "https://nssdc.gsfc.nasa.gov/planetary/lunar/lunar_artifact_impacts.html" };
17
+ const SRC_ODE = { name: "NASA Planetary Data System, Mars Orbital Data Explorer, landing sites", url: "https://ode.rsl.wustl.edu/mars/pagehelp/Content/Missions_Instruments/Landing_Sites.htm" };
18
+ const SRC_MARS24 = { name: "NASA GISS, Mars24 Sunclock, Mars lander missions", url: "https://www.giss.nasa.gov/tools/mars24/help/landers.html" };
19
+ const SRC_GCAT = { name: "GCAT, J. McDowell (CC BY 4.0)", url: "https://planet4589.org/space/gcat/" };
20
+ /**
21
+ * Every landing on the Moon and Mars that touched down softly and was heard from, 28 on the Moon (Apollo 11 to 17, Surveyor 1, 3, 5, 6 and 7, Luna 9, 13, 16, 17, 20, 21, 23 and 24, Chang'e 3, 4, 5 and 6, Chandrayaan-3, SLIM, IM-1, Blue Ghost 1 and IM-2) and 11 on
22
+ * Mars (Mars 3, Viking 1 and 2, Pathfinder, Spirit, Opportunity, Phoenix, Curiosity, InSight, Perseverance and Zhurong), the Moon's first and Mars's after, each by date. Landers that did not survive the landing (Mars 2 and 6, Beagle 2, Schiaparelli) are not here; they are
23
+ * in the place tables as crashes.
24
+ *
25
+ * @example
26
+ * ```ts
27
+ * import { LANDING_SITES } from "@johnmorrisdotca/wakusei-planets/landing-sites";
28
+ *
29
+ * console.log(LANDING_SITES.length, "sites;", LANDING_SITES.filter((site) => site.country === "CN").map((site) => site.name.en).join(", "));
30
+ * ```
31
+ */
32
+ export const LANDING_SITES = [
33
+ {
34
+ id: "moon/luna-9", place: "moon/luna-9", body: "moon", name: { en: "Luna 9", ja: "ルナ9号" },
35
+ date: "1966-02-03T18:45Z", lat: 7.13, lon: -64.37, agency: AGENCY.USSR,
36
+ country: "SU", approximate: true,
37
+ source: SRC_NASA_MOON,
38
+ },
39
+ {
40
+ id: "moon/surveyor-1", place: "moon/surveyor-1", body: "moon", name: { en: "Surveyor 1", ja: "サーベイヤー1号" },
41
+ date: "1966-06-02T06:17Z", lat: -2.4745, lon: -43.3398, agency: AGENCY.NASA,
42
+ country: "US",
43
+ source: SRC_NASA_MOON, page: `${NSS}1966-045A`,
44
+ },
45
+ {
46
+ id: "moon/luna-13", place: "moon/luna-13", body: "moon", name: { en: "Luna 13", ja: "ルナ13号" },
47
+ date: "1966-12-24T18:01Z", lat: 18.87, lon: -62.05, agency: AGENCY.USSR,
48
+ country: "SU",
49
+ source: SRC_NASA_MOON,
50
+ },
51
+ {
52
+ id: "moon/surveyor-3", place: "moon/surveyor-3", body: "moon", name: { en: "Surveyor 3", ja: "サーベイヤー3号" },
53
+ date: "1967-04-20T00:04Z", lat: -3.0162, lon: -23.418, agency: AGENCY.NASA,
54
+ country: "US",
55
+ source: SRC_NASA_MOON, page: `${NSS}1967-035A`,
56
+ },
57
+ {
58
+ id: "moon/surveyor-5", place: "moon/surveyor-5", body: "moon", name: { en: "Surveyor 5", ja: "サーベイヤー5号" },
59
+ date: "1967-09-11T00:46Z", lat: 1.4551, lon: 23.1943, agency: AGENCY.NASA,
60
+ country: "US",
61
+ source: SRC_NASA_MOON, page: `${NSS}1967-084A`,
62
+ },
63
+ {
64
+ id: "moon/surveyor-6", place: "moon/surveyor-6", body: "moon", name: { en: "Surveyor 6", ja: "サーベイヤー6号" },
65
+ date: "1967-11-10T01:01Z", lat: 0.4742, lon: -1.4275, agency: AGENCY.NASA,
66
+ country: "US",
67
+ source: SRC_NASA_MOON, page: `${NSS}1967-112A`,
68
+ },
69
+ {
70
+ id: "moon/surveyor-7", place: "moon/surveyor-7", body: "moon", name: { en: "Surveyor 7", ja: "サーベイヤー7号" },
71
+ date: "1968-01-10T01:05Z", lat: -40.9812, lon: -11.5127, agency: AGENCY.NASA,
72
+ country: "US",
73
+ source: SRC_NASA_MOON, page: `${NSS}1968-001A`,
74
+ },
75
+ {
76
+ id: "moon/apollo-11", place: "moon/apollo-11-lunar-module", body: "moon", name: { en: "Apollo 11", ja: "アポロ11号" },
77
+ date: "1969-07-20T20:17Z", lat: 0.6742, lon: 23.4731, agency: AGENCY.NASA,
78
+ country: "US",
79
+ source: SRC_NASA_MOON, page: `${NSS}1969-059C`,
80
+ },
81
+ {
82
+ id: "moon/apollo-12", place: "moon/apollo-12-lunar-module", body: "moon", name: { en: "Apollo 12", ja: "アポロ12号" },
83
+ date: "1969-11-19T06:54Z", lat: -3.0128, lon: -23.4219, agency: AGENCY.NASA,
84
+ country: "US",
85
+ source: SRC_NASA_MOON, page: `${NSS}1969-099C`,
86
+ },
87
+ {
88
+ id: "moon/luna-16", place: "moon/luna-16", body: "moon", name: { en: "Luna 16", ja: "ルナ16号" },
89
+ date: "1970-09-20T05:17Z", lat: -0.5137, lon: 56.3638, agency: AGENCY.USSR,
90
+ country: "SU",
91
+ source: SRC_NASA_MOON,
92
+ },
93
+ {
94
+ id: "moon/luna-17", place: "moon/luna-17", body: "moon", name: { en: "Luna 17", ja: "ルナ17号" },
95
+ alsoAt: ["moon/lunokhod-1"],
96
+ date: "1970-11-17T03:47Z", lat: 38.2376, lon: -35.0016, agency: AGENCY.USSR,
97
+ country: "SU", note: "Carried Lunokhod 1.",
98
+ source: SRC_NASA_MOON,
99
+ },
100
+ {
101
+ id: "moon/apollo-14", place: "moon/apollo-14-lunar-module", body: "moon", name: { en: "Apollo 14", ja: "アポロ14号" },
102
+ date: "1971-02-05T09:18Z", lat: -3.6459, lon: -17.4719, agency: AGENCY.NASA,
103
+ country: "US",
104
+ source: SRC_NASA_MOON, page: `${NSS}1971-008C`,
105
+ },
106
+ {
107
+ id: "moon/apollo-15", place: "moon/apollo-15-lunar-module", body: "moon", name: { en: "Apollo 15", ja: "アポロ15号" },
108
+ alsoAt: ["moon/apollo-15-lunar-rover"],
109
+ date: "1971-07-30T22:16Z", lat: 26.1324, lon: 3.6333, agency: AGENCY.NASA,
110
+ country: "US",
111
+ source: SRC_NASA_MOON, page: `${NSS}1971-063C`,
112
+ },
113
+ {
114
+ id: "moon/luna-20", place: "moon/luna-20", body: "moon", name: { en: "Luna 20", ja: "ルナ20号" },
115
+ date: "1972-02-21T19:18Z", lat: 3.7863, lon: 56.6242, agency: AGENCY.USSR,
116
+ country: "SU",
117
+ source: SRC_NASA_MOON,
118
+ },
119
+ {
120
+ id: "moon/apollo-16", place: "moon/apollo-16-lunar-module", body: "moon", name: { en: "Apollo 16", ja: "アポロ16号" },
121
+ alsoAt: ["moon/apollo-16-lunar-rover"],
122
+ date: "1972-04-21T02:23Z", lat: -8.9734, lon: 15.5011, agency: AGENCY.NASA,
123
+ country: "US",
124
+ source: SRC_NASA_MOON, page: `${NSS}1972-031C`,
125
+ },
126
+ {
127
+ id: "moon/apollo-17", place: "moon/apollo-17-lunar-module", body: "moon", name: { en: "Apollo 17", ja: "アポロ17号" },
128
+ alsoAt: ["moon/apollo-17-lunar-rover"],
129
+ date: "1972-12-11T19:54Z", lat: 20.1911, lon: 30.7723, agency: AGENCY.NASA,
130
+ country: "US", stand: "apollo-17",
131
+ source: SRC_NASA_MOON, page: `${NSS}1972-096C`,
132
+ },
133
+ {
134
+ id: "moon/luna-21", place: "moon/luna-21", body: "moon", name: { en: "Luna 21", ja: "ルナ21号" },
135
+ date: "1973-01-15T22:35Z", lat: 25.9994, lon: 30.4076, agency: AGENCY.USSR,
136
+ country: "SU", note: "Carried Lunokhod 2.",
137
+ source: SRC_NASA_MOON,
138
+ },
139
+ {
140
+ id: "moon/luna-23", place: "moon/luna-23", body: "moon", name: { en: "Luna 23", ja: "ルナ23号" },
141
+ date: "1974-11-06T05:37Z", lat: 12.6667, lon: 62.1511, agency: AGENCY.USSR,
142
+ country: "SU",
143
+ source: SRC_NASA_MOON,
144
+ },
145
+ {
146
+ id: "moon/luna-24", place: "moon/luna-24", body: "moon", name: { en: "Luna 24", ja: "ルナ24号" },
147
+ date: "1976-08-18T06:36Z", lat: 12.7142, lon: 62.2129, agency: AGENCY.USSR,
148
+ country: "SU",
149
+ source: SRC_NASA_MOON,
150
+ },
151
+ {
152
+ id: "moon/chang-e-3", place: "moon/chang-e-3", body: "moon", name: { en: "Chang'e 3", ja: "嫦娥3号" },
153
+ alsoAt: ["moon/yutu"],
154
+ date: "2013-12-14T13:11Z", lat: 44.1214, lon: -19.5117, agency: AGENCY.CNSA,
155
+ country: "CN",
156
+ source: SRC_NASA_MOON,
157
+ },
158
+ {
159
+ id: "moon/chang-e-4", place: "moon/chang-e-4", body: "moon", name: { en: "Chang'e 4", ja: "嫦娥4号" },
160
+ alsoAt: ["moon/yutu-2"],
161
+ date: "2019-01-03T02:26Z", lat: -45.4561, lon: 177.5885, agency: AGENCY.CNSA,
162
+ country: "CN",
163
+ source: SRC_NASA_MOON,
164
+ },
165
+ {
166
+ id: "moon/chang-e-5", place: "moon/chang-e-5-lander", body: "moon", name: { en: "Chang'e 5", ja: "嫦娥5号" },
167
+ date: "2020-12-01T15:11Z", lat: 43.0576, lon: -51.9161, agency: AGENCY.CNSA,
168
+ country: "CN",
169
+ source: SRC_NASA_MOON,
170
+ },
171
+ {
172
+ id: "moon/chandrayaan-3", place: "moon/chandrayaan-3-vikram", body: "moon", name: { en: "Chandrayaan-3", ja: "チャンドラヤーン3号" },
173
+ alsoAt: ["moon/pragyan"],
174
+ date: "2023-08-23T12:32Z", lat: -69.3741, lon: 32.32, agency: AGENCY.ISRO,
175
+ country: "IN",
176
+ source: SRC_NASA_MOON,
177
+ },
178
+ {
179
+ id: "moon/slim", place: "moon/slim", body: "moon", name: { en: "SLIM", ja: "SLIM" },
180
+ alsoAt: ["moon/lev-1", "moon/lev-2"],
181
+ date: "2024-01-19T15:19Z", lat: -13.316, lon: 25.251, agency: AGENCY.JAXA,
182
+ country: "JP",
183
+ source: SRC_NASA_MOON,
184
+ },
185
+ {
186
+ id: "moon/im-1", place: "moon/im-1-odysseus", body: "moon", name: { en: "IM-1 Odysseus", ja: "IM-1 オデュッセウス" },
187
+ date: "2024-02-22T23:23Z", lat: -80.13, lon: 1.44, agency: AGENCY.IM,
188
+ country: "US",
189
+ source: SRC_NASA_MOON,
190
+ },
191
+ {
192
+ id: "moon/chang-e-6", place: "moon/chang-e-6-lander", body: "moon", name: { en: "Chang'e 6", ja: "嫦娥6号" },
193
+ date: "2024-06-01T22:23Z", lat: -41.6385, lon: -153.9852, agency: AGENCY.CNSA,
194
+ country: "CN",
195
+ source: SRC_NASA_MOON,
196
+ },
197
+ {
198
+ id: "moon/blue-ghost-1", place: "moon/blue-ghost-1", body: "moon", name: { en: "Blue Ghost 1", ja: "ブルーゴースト ミッション1" },
199
+ date: "2025-03-02T08:34Z", lat: 18.562, lon: 61.81, agency: AGENCY.FF,
200
+ country: "US",
201
+ source: SRC_NASA_MOON, page: `${NSS}2025-010A`,
202
+ },
203
+ {
204
+ id: "moon/im-2", place: "moon/im-2-athena", body: "moon", name: { en: "IM-2 Athena", ja: "IM-2 アテナ" },
205
+ date: "2025-03-06T17:28Z", lat: -84.7906, lon: 29.1957, agency: AGENCY.IM,
206
+ country: "US",
207
+ source: SRC_NASA_MOON, page: `${NSS}PRIME-1`,
208
+ },
209
+ {
210
+ id: "mars/mars-3", place: "mars/mars-3-lander", body: "mars", name: { en: "Mars 3", ja: "マルス3号" },
211
+ alsoAt: ["mars/prop-m"],
212
+ date: "1971-12-02T13:47Z", lat: -45.045, lon: -157.977, agency: AGENCY.USSR,
213
+ country: "SU", approximate: true, note: "Soft landed, then fell silent after about 20 seconds.",
214
+ source: SRC_GCAT, checkedAgainst: SRC_MARS24,
215
+ },
216
+ {
217
+ id: "mars/viking-1", place: "mars/viking-1", body: "mars", name: { en: "Viking 1", ja: "バイキング1号" },
218
+ date: "1976-07-20T11:53Z", lat: 22.27, lon: -47.95, agency: AGENCY.NASA,
219
+ country: "US",
220
+ source: { name: "NASA NSSDCA, Viking 1 lander", url: `${NSS}1975-075C` }, checkedAgainst: SRC_MARS24, page: `${NSS}1975-075C`,
221
+ },
222
+ {
223
+ id: "mars/viking-2", place: "mars/viking-2", body: "mars", name: { en: "Viking 2", ja: "バイキング2号" },
224
+ date: "1976-09-03T22:37Z", lat: 47.6673, lon: 134.2809, agency: AGENCY.NASA,
225
+ country: "US",
226
+ source: { name: "NASA NSSDCA, Viking 2 lander", url: `${NSS}1975-083C` }, checkedAgainst: SRC_MARS24, page: `${NSS}1975-083C`,
227
+ },
228
+ {
229
+ id: "mars/mars-pathfinder", place: "mars/mars-pathfinder", body: "mars", name: { en: "Mars Pathfinder", ja: "マーズ・パスファインダー" },
230
+ alsoAt: ["mars/sojourner"],
231
+ date: "1997-07-04T16:56Z", lat: 19.095, lon: -33.253, agency: AGENCY.NASA,
232
+ country: "US",
233
+ source: SRC_ODE, checkedAgainst: SRC_MARS24, page: `${NSS}1996-068A`,
234
+ },
235
+ {
236
+ id: "mars/spirit", place: "mars/spirit", body: "mars", name: { en: "Spirit", ja: "スピリット" },
237
+ alsoAt: ["mars/spirit-s-lander"],
238
+ date: "2004-01-04T04:25Z", lat: -14.5719, lon: 175.4785, agency: AGENCY.NASA,
239
+ country: "US",
240
+ source: SRC_ODE, checkedAgainst: SRC_MARS24, page: `${NSS}2003-027A`,
241
+ },
242
+ {
243
+ id: "mars/opportunity", place: "mars/opportunity", body: "mars", name: { en: "Opportunity", ja: "オポチュニティ" },
244
+ alsoAt: ["mars/opportunity-s-lander"],
245
+ date: "2004-01-25T04:54Z", lat: -1.9483, lon: -5.5258, agency: AGENCY.NASA,
246
+ country: "US",
247
+ source: SRC_ODE, checkedAgainst: SRC_MARS24, page: `${NSS}2003-032A`,
248
+ },
249
+ {
250
+ id: "mars/phoenix", place: "mars/phoenix", body: "mars", name: { en: "Phoenix", ja: "フェニックス" },
251
+ date: "2008-05-25T23:38Z", lat: 67.9859, lon: -125.75, agency: AGENCY.NASA,
252
+ country: "US", note: "The source prints 68.22 N, a planetographic latitude; the latitude here is the planetocentric one.",
253
+ source: SRC_ODE, checkedAgainst: SRC_MARS24, page: `${NSS}2007-034A`,
254
+ },
255
+ {
256
+ id: "mars/curiosity", place: "mars/curiosity", body: "mars", name: { en: "Curiosity", ja: "キュリオシティ" },
257
+ alsoAt: ["mars/curiosity-s-descent-stage"],
258
+ date: "2012-08-06T05:17Z", lat: -4.5895, lon: 137.4417, agency: AGENCY.NASA,
259
+ country: "US",
260
+ source: SRC_GCAT, checkedAgainst: SRC_ODE, page: `${NSS}2011-070A`,
261
+ },
262
+ {
263
+ id: "mars/insight", place: "mars/insight", body: "mars", name: { en: "InSight", ja: "インサイト" },
264
+ date: "2018-11-26T19:44Z", lat: 4.5, lon: 135.62, agency: AGENCY.NASA,
265
+ country: "US",
266
+ source: SRC_MARS24, page: `${NSS}2018-042A`,
267
+ },
268
+ {
269
+ id: "mars/perseverance", place: "mars/perseverance", body: "mars", name: { en: "Perseverance", ja: "パーシビアランス" },
270
+ alsoAt: ["mars/perseverance-s-descent-stage"],
271
+ date: "2021-02-18T20:43Z", lat: 18.4446, lon: 77.4508, agency: AGENCY.NASA,
272
+ country: "US",
273
+ source: SRC_GCAT, checkedAgainst: SRC_MARS24, page: `${NSS}2020-052A`,
274
+ },
275
+ {
276
+ id: "mars/zhurong", place: "mars/zhurong", body: "mars", name: { en: "Zhurong", ja: "祝融号" },
277
+ alsoAt: ["mars/tianwen-1-lander"],
278
+ date: "2021-05-14T23:17Z", lat: 25.066, lon: 109.925, agency: AGENCY.CNSA,
279
+ country: "CN",
280
+ source: SRC_GCAT, checkedAgainst: SRC_MARS24,
281
+ },
282
+ ];
283
+ /**
284
+ * The landing sites of one body, by date.
285
+ *
286
+ * @param body - `moon` or `mars`.
287
+ * @returns Its sites.
288
+ *
289
+ * @example
290
+ * ```ts
291
+ * import { landingSitesOf } from "@johnmorrisdotca/wakusei-planets/landing-sites";
292
+ *
293
+ * console.log(landingSitesOf("mars").map((site) => `${site.name.en} ${site.date.slice(0, 4)}`).join(", "));
294
+ * ```
295
+ */
296
+ export function landingSitesOf(body) {
297
+ return LANDING_SITES.filter((site) => site.body === body);
298
+ }
299
+ /**
300
+ * A landing site by its id (`moon/apollo-11`), by the id of its place in the place tables (`moon/apollo-11-lunar-module`, or its rover's), or by its name in English or Japanese in any case, or `undefined`.
301
+ *
302
+ * @param text - The id, place id or name.
303
+ * @returns The site, or `undefined` when none matches.
304
+ *
305
+ * @example
306
+ * ```ts
307
+ * import { findLandingSite } from "@johnmorrisdotca/wakusei-planets/landing-sites";
308
+ *
309
+ * console.log(findLandingSite("moon/apollo-11-lunar-module")?.name.ja, findLandingSite("zhurong")?.country, findLandingSite("nowhere"));
310
+ * ```
311
+ */
312
+ export function findLandingSite(text) {
313
+ if (typeof text !== "string")
314
+ return undefined;
315
+ const wanted = text.trim().toLowerCase();
316
+ return LANDING_SITES.find((site) => site.id === wanted || site.place === wanted || site.alsoAt?.includes(wanted) === true || site.name.en.toLowerCase() === wanted || site.name.ja === text.trim() || site.id.slice(site.id.indexOf("/") + 1) === wanted);
317
+ }
318
+ /**
319
+ * The code a flag element (`<hata-flag code="...">`, from `@johnmorrisdotca/hata`) takes for a country as the place tables and the landing sites write it: the two letters of ISO 3166-1 in capitals, `SU` for the Soviet Union, and GCAT's `J` for Japan
320
+ * (`JP`). A country with no flag to show (an agency of several countries) or with no code gives `undefined`.
321
+ *
322
+ * @param country - A site's `country`, or a place's.
323
+ * @returns The code, or `undefined`.
324
+ *
325
+ * @example
326
+ * ```ts
327
+ * import { flagCodeOf } from "@johnmorrisdotca/wakusei-planets/landing-sites";
328
+ *
329
+ * console.log(flagCodeOf("J"), flagCodeOf("SU"), flagCodeOf("us"), flagCodeOf("ESA"), flagCodeOf(undefined));
330
+ * ```
331
+ */
332
+ export function flagCodeOf(country) {
333
+ if (country === undefined)
334
+ return undefined;
335
+ const code = country.trim().toUpperCase();
336
+ if (code === "J")
337
+ return "JP";
338
+ return /^[A-Z]{2}$/.test(code) ? code : undefined;
339
+ }
@@ -1,5 +1,8 @@
1
1
  import type { Place, PlaceBody } from "../places.ts";
2
2
  import type { PlaceLayer, PlaceMark } from "../place-marks.ts";
3
+ import { type LandingSite } from "../landing-sites.ts";
4
+ /** A body's radius on the screen, in CSS pixels, from which the landing sites' names are written beside their dots (when the `site-flags` attribute is on). */
5
+ export declare const SITE_LABEL_FROM_PX = 110;
3
6
  /**
4
7
  * The short line under a place's name: what it is and when (a site's year, a planned landing's announced year, a feature's kind and size), in English or Japanese.
5
8
  *
@@ -38,8 +41,8 @@ export declare const placesLoader: () => PlacesLoader | undefined;
38
41
  export declare function onPlacesLoader(heard: () => void): () => void;
39
42
  /** The marks over one view. */
40
43
  export interface PlaceLayerView {
41
- /** Lay these marks, moving the ones already there, adding the new and taking away the rest. */
42
- set(marks: readonly PlaceMark[]): void;
44
+ /** Lay these marks, moving the ones already there, adding the new and taking away the rest. `radiusPx` is the body's radius on the screen: with flags on, the landing sites are named beside their dots from `SITE_LABEL_FROM_PX`. */
45
+ set(marks: readonly PlaceMark[], radiusPx?: number): void;
43
46
  /** Take every mark away. */
44
47
  clear(): void;
45
48
  /** The marks laid now: the place's id, its layer and where it is, in CSS pixels. */
@@ -60,7 +63,8 @@ export interface PlaceLayerView {
60
63
  */
61
64
  export declare function createPlaceLayer(root: ShadowRoot, options: {
62
65
  lang(): "en" | "ja";
63
- pick(place: Place, at: {
66
+ flags?(): boolean;
67
+ pick(place: Place, site: LandingSite | undefined, at: {
64
68
  x: number;
65
69
  y: number;
66
70
  }): void;
@@ -1,3 +1,4 @@
1
+ import { findLandingSite, flagCodeOf } from "../landing-sites.js";
1
2
  const STYLE = `.wk-places{position:absolute;inset:0;pointer-events:none;overflow:hidden}
2
3
  .wk-place{position:absolute;left:0;top:0;width:20px;height:20px;margin:-10px 0 0 -10px;padding:0;border:0;background:none;cursor:pointer;pointer-events:auto;will-change:transform;-webkit-tap-highlight-color:transparent}
3
4
  .wk-place::before{content:"";position:absolute;left:50%;top:50%;width:6px;height:6px;margin:-3px 0 0 -3px;border-radius:50%;box-sizing:border-box;background:var(--wakusei-place-landing,#fff);box-shadow:0 0 0 1px rgba(0,0,0,.55);opacity:.85}
@@ -11,7 +12,14 @@ const STYLE = `.wk-places{position:absolute;inset:0;pointer-events:none;overflow
11
12
  .wk-place[data-name]{width:auto;height:auto;margin:0;padding:0 3px;color:#fff;font:600 12px/1.2 var(--wakusei-place-font,system-ui,-apple-system,sans-serif);white-space:nowrap;text-shadow:0 1px 2px #000,0 0 3px #000;pointer-events:auto}
12
13
  .wk-place[data-pure]{pointer-events:none}
13
14
  .wk-place[data-name]::before{display:none}
14
- .wk-place-tip[data-on]{visibility:visible}`;
15
+ .wk-place-tip[data-on]{visibility:visible}
16
+ .wk-place-tip .wk-place-head{display:flex;align-items:center;gap:5px}
17
+ .wk-place-flag{flex:none;height:11px;pointer-events:none}
18
+ .wk-place-flag:not(:defined){display:none}
19
+ .wk-place-site{position:absolute;top:50%;left:13px;display:flex;align-items:center;gap:4px;margin-top:-8px;color:#fff;font:600 11px/16px var(--wakusei-place-font,system-ui,-apple-system,sans-serif);white-space:nowrap;text-shadow:0 1px 2px #000,0 0 3px #000;pointer-events:none}
20
+ .wk-place-site[data-side=left]{left:auto;right:13px;flex-direction:row-reverse}`;
21
+ /** A body's radius on the screen, in CSS pixels, from which the landing sites' names are written beside their dots (when the `site-flags` attribute is on). */
22
+ export const SITE_LABEL_FROM_PX = 110;
15
23
  const KIND_WORD = {
16
24
  crewed: { en: "crewed landing", ja: "有人着陸" },
17
25
  landing: { en: "lander", ja: "着陸機" },
@@ -52,6 +60,18 @@ export function placeLine(place, lang) {
52
60
  const year = place.date?.slice(0, 4);
53
61
  return year === undefined ? word : ja ? `${word}、${year}年` : `${word}, ${year}`;
54
62
  }
63
+ /** A flag for a country, as `<hata-flag>` (from `@johnmorrisdotca/hata`, which the page imports; where it is not defined the element draws nothing and the name stands alone). */
64
+ function flagFor(place) {
65
+ const code = flagCodeOf(place.country);
66
+ if (code === undefined)
67
+ return undefined;
68
+ const flag = document.createElement("hata-flag");
69
+ flag.className = "wk-place-flag";
70
+ flag.setAttribute("code", code);
71
+ flag.setAttribute("border", "");
72
+ flag.setAttribute("aria-hidden", "true");
73
+ return flag;
74
+ }
55
75
  // on globalThis, so the separate copies a CDN can load share the one loader
56
76
  const SLOT = Symbol.for("@johnmorrisdotca/wakusei-planets/places-loader");
57
77
  const slot = (globalThis[SLOT] ??= { heard: new Set() });
@@ -113,7 +133,15 @@ export function createPlaceLayer(root, options) {
113
133
  name.textContent = entry.mark.place.name[lang];
114
134
  const line = document.createElement("small");
115
135
  line.textContent = placeLine(entry.mark.place, lang);
116
- tip.replaceChildren(name, line);
136
+ const flag = options.flags?.() === true ? flagFor(entry.mark.place) : undefined;
137
+ if (flag === undefined)
138
+ tip.replaceChildren(name, line);
139
+ else {
140
+ const head = document.createElement("div");
141
+ head.className = "wk-place-head";
142
+ head.append(flag, name);
143
+ tip.replaceChildren(head, line);
144
+ }
117
145
  tip.setAttribute("data-on", "");
118
146
  tipFor = id;
119
147
  placeTip();
@@ -157,7 +185,7 @@ export function createPlaceLayer(root, options) {
157
185
  event.stopPropagation();
158
186
  const entry = held.get(id);
159
187
  if (entry !== undefined)
160
- options.pick(entry.mark.place, { x: entry.x, y: entry.y });
188
+ options.pick(entry.mark.place, entry.site, { x: entry.x, y: entry.y });
161
189
  });
162
190
  return button;
163
191
  };
@@ -189,7 +217,7 @@ export function createPlaceLayer(root, options) {
189
217
  best = { entry, away };
190
218
  }
191
219
  if (best !== undefined)
192
- options.pick(best.entry.mark.place, { x: best.entry.x, y: best.entry.y });
220
+ options.pick(best.entry.mark.place, best.entry.site, { x: best.entry.x, y: best.entry.y });
193
221
  };
194
222
  const nameCancel = () => {
195
223
  pressed = null;
@@ -197,8 +225,66 @@ export function createPlaceLayer(root, options) {
197
225
  window.addEventListener("pointerdown", nameDown, true);
198
226
  window.addEventListener("pointerup", nameUp, true);
199
227
  window.addEventListener("pointercancel", nameCancel, true);
228
+ // The landing sites' names beside their dots, with the country's flag: only with flags on, only on a body close enough to leave the room, and each in the first of the right or the left side that clears the dots and the names
229
+ // already written (marks come in the order they matter). A label belongs to its dot's button, so a press on it is the dot's.
230
+ const labelSites = (marks, radiusPx) => {
231
+ const lang = options.lang();
232
+ const width = box.clientWidth;
233
+ const on = options.flags?.() === true && radiusPx >= SITE_LABEL_FROM_PX;
234
+ // the names of the surface (Mare Imbrium, Plato) are written first and keep their place: a site's label goes round them
235
+ const taken = marks
236
+ .filter((mark) => mark.label === true && (mark.fade ?? 1) > 0.2)
237
+ .map((mark) => {
238
+ const halfWidth = Math.ceil(mark.place.name[lang].length * 3.7) + 5;
239
+ return { x0: mark.x - halfWidth, x1: mark.x + halfWidth, y0: mark.y - 9, y1: mark.y + 9 };
240
+ });
241
+ const dots = marks.filter((mark) => mark.label !== true).map((mark) => ({ mark, x0: mark.x - 8, x1: mark.x + 8, y0: mark.y - 8, y1: mark.y + 8 }));
242
+ const clear = (r, self) => (width <= 0 || (r.x0 >= 0 && r.x1 <= width)) && !taken.some((o) => r.x0 < o.x1 && r.x1 > o.x0 && r.y0 < o.y1 && r.y1 > o.y0) &&
243
+ !dots.some((d) => d.mark !== self && r.x0 < d.x1 && r.x1 > d.x0 && r.y0 < d.y1 && r.y1 > d.y0);
244
+ for (const mark of marks) {
245
+ const entry = held.get(mark.place.id);
246
+ if (entry === undefined)
247
+ continue;
248
+ let side;
249
+ if (on && mark.label !== true && entry.site !== undefined) {
250
+ const text = entry.site.name[lang];
251
+ const w = 13 + text.length * 6.4 + (flagCodeOf(entry.site.country) === undefined ? 0 : 19);
252
+ const right = { x0: mark.x + 10, x1: mark.x + 10 + w, y0: mark.y - 8, y1: mark.y + 8 };
253
+ const left = { x0: mark.x - 10 - w, x1: mark.x - 10, y0: mark.y - 8, y1: mark.y + 8 };
254
+ const spot = clear(right, mark) ? right : clear(left, mark) ? left : undefined;
255
+ if (spot !== undefined) {
256
+ taken.push(spot);
257
+ side = spot === right ? "right" : "left";
258
+ }
259
+ }
260
+ if (side === undefined) {
261
+ entry.label?.remove();
262
+ entry.label = undefined;
263
+ entry.labelKey = undefined;
264
+ continue;
265
+ }
266
+ const key = `${lang}|${side}`;
267
+ if (entry.label === undefined || !entry.label.isConnected || entry.labelKey !== key) {
268
+ entry.label?.remove();
269
+ const label = document.createElement("span");
270
+ label.className = "wk-place-site";
271
+ label.setAttribute("part", "place-site");
272
+ label.setAttribute("aria-hidden", "true");
273
+ label.dataset.side = side;
274
+ const flag = flagFor(mark.place);
275
+ const name = document.createElement("span");
276
+ name.textContent = entry.site.name[lang];
277
+ if (flag !== undefined)
278
+ label.append(flag);
279
+ label.append(name);
280
+ entry.button.append(label);
281
+ entry.label = label;
282
+ entry.labelKey = key;
283
+ }
284
+ }
285
+ };
200
286
  return {
201
- set(marks) {
287
+ set(marks, radiusPx = 0) {
202
288
  const lang = options.lang();
203
289
  const next = new Set();
204
290
  for (const mark of marks) {
@@ -207,7 +293,7 @@ export function createPlaceLayer(root, options) {
207
293
  let entry = held.get(id);
208
294
  if (entry === undefined) {
209
295
  const button = make(mark);
210
- entry = { button, mark, x: Number.NaN, y: Number.NaN, lang: "" };
296
+ entry = { button, mark, x: Number.NaN, y: Number.NaN, lang: "", site: findLandingSite(id) };
211
297
  held.set(id, entry);
212
298
  box.insertBefore(button, tip);
213
299
  }
@@ -249,6 +335,7 @@ export function createPlaceLayer(root, options) {
249
335
  entry.button.style.transform = `translate(${mark.x.toFixed(1)}px,${mark.y.toFixed(1)}px)${shift}`;
250
336
  }
251
337
  }
338
+ labelSites(marks, radiusPx);
252
339
  for (const [id, entry] of held) {
253
340
  if (next.has(id))
254
341
  continue;
@@ -197,6 +197,13 @@ export declare class WakuseiSpace extends HTMLElement {
197
197
  */
198
198
  get places(): PlaceLayer[];
199
199
  set places(layers: readonly PlaceLayer[] | null);
200
+ /**
201
+ * Whether the places carry their country's flag (the attribute `site-flags`): the tip of a place with a country shows its flag, and on a body close enough on the screen (110 pixels of radius) the landing sites (`LANDING_SITES` from
202
+ * `/landing-sites`) are named beside their dots, each with its flag. The flag is `<hata-flag>` from `@johnmorrisdotca/hata`, which the page imports itself (`import "@johnmorrisdotca/hata/element/define"`); until it is defined the name stands alone. Needs `places`.
203
+ * The `wakusei-place` event's detail carries the landing site as `site` where the place is one. Setting it writes the attribute.
204
+ */
205
+ get siteFlags(): boolean;
206
+ set siteFlags(on: boolean);
200
207
  /** The marks laid on the body looked at now: each place's id, its layer and where its mark is, in CSS pixels from the view's top left. */
201
208
  get placesShown(): readonly {
202
209
  id: string;
@@ -142,7 +142,7 @@ const orbiterLines = (value) => (value === "chosen" || value === "none" ? value
142
142
  * ```
143
143
  */
144
144
  export class WakuseiSpace extends HTMLElement {
145
- static observedAttributes = ["center", "time", "speed", "scale", "labels", "labels-always", "covered", "roadster", "spacecraft", "orbiters", "orbiter", "orbiter-lines", "orbiter-track", "orbits", "help", "look", "light", "lang", "data", "arrows", "help-through", "help-place", "places", "surface-names", "earth-places", "earth-places-look", "all-moons", "far-opacity", "transition", "pace", "frame", "pair-with", "belts", "moon-size", ...NAME_LABEL_ATTRIBUTES];
145
+ static observedAttributes = ["center", "time", "speed", "scale", "labels", "labels-always", "covered", "roadster", "spacecraft", "orbiters", "orbiter", "orbiter-lines", "orbiter-track", "orbits", "help", "look", "light", "lang", "data", "arrows", "help-through", "help-place", "places", "surface-names", "site-flags", "earth-places", "earth-places-look", "all-moons", "far-opacity", "transition", "pace", "frame", "pair-with", "belts", "moon-size", ...NAME_LABEL_ATTRIBUTES];
146
146
  #model = newSpaceModel();
147
147
  #allMoons = false;
148
148
  #catalogue;
@@ -421,7 +421,7 @@ export class WakuseiSpace extends HTMLElement {
421
421
  }
422
422
  else if (NAME_LABEL_ATTRIBUTES.includes(name))
423
423
  this.#relabel();
424
- if (name === "places" || name === "lang" || name === "surface-names")
424
+ if (name === "places" || name === "site-flags" || name === "lang" || name === "surface-names")
425
425
  this.#markSurface();
426
426
  if (name === "earth-places" || name === "earth-places-look")
427
427
  this.#askEarthPlaces();
@@ -439,6 +439,17 @@ export class WakuseiSpace extends HTMLElement {
439
439
  else
440
440
  this.setAttribute("places", layers.join(" "));
441
441
  }
442
+ /**
443
+ * Whether the places carry their country's flag (the attribute `site-flags`): the tip of a place with a country shows its flag, and on a body close enough on the screen (110 pixels of radius) the landing sites (`LANDING_SITES` from
444
+ * `/landing-sites`) are named beside their dots, each with its flag. The flag is `<hata-flag>` from `@johnmorrisdotca/hata`, which the page imports itself (`import "@johnmorrisdotca/hata/element/define"`); until it is defined the name stands alone. Needs `places`.
445
+ * The `wakusei-place` event's detail carries the landing site as `site` where the place is one. Setting it writes the attribute.
446
+ */
447
+ get siteFlags() {
448
+ return this.hasAttribute("site-flags");
449
+ }
450
+ set siteFlags(on) {
451
+ this.toggleAttribute("site-flags", on);
452
+ }
442
453
  /** The marks laid on the body looked at now: each place's id, its layer and where its mark is, in CSS pixels from the view's top left. */
443
454
  get placesShown() {
444
455
  return this.#markLayer?.shown ?? [];
@@ -769,7 +780,8 @@ export class WakuseiSpace extends HTMLElement {
769
780
  if (this.#markLayer === undefined) {
770
781
  this.#markLayer = createPlaceLayer(root, {
771
782
  lang: () => (this.getAttribute("lang") === "ja" ? "ja" : "en"),
772
- pick: (place, at) => this.dispatchEvent(new CustomEvent("wakusei-place", { detail: { body: id, place, x: at.x, y: at.y }, bubbles: true, composed: true })),
783
+ flags: () => this.hasAttribute("site-flags"),
784
+ pick: (place, site, at) => this.dispatchEvent(new CustomEvent("wakusei-place", { detail: { body: id, place, site, x: at.x, y: at.y }, bubbles: true, composed: true })),
773
785
  });
774
786
  if (this.getAttribute("role") === "img")
775
787
  this.setAttribute("role", "group");
@@ -782,7 +794,7 @@ export class WakuseiSpace extends HTMLElement {
782
794
  for (const [other, at] of Object.entries(this.#places ?? {}))
783
795
  if (at !== null && other !== id)
784
796
  keepClear.push({ x: at.x, y: at.y, halfWidth: 8, halfHeight: 8 });
785
- this.#markLayer.set(marksToShow(this.#markList.list, layers, { ...surface, scale }, facts.radiusKm, names, keepClear, this.getAttribute("lang") === "ja" ? "ja" : "en"));
797
+ this.#markLayer.set(marksToShow(this.#markList.list, layers, { ...surface, scale }, facts.radiusKm, names, keepClear, this.getAttribute("lang") === "ja" ? "ja" : "en"), surface.radiusPx);
786
798
  }
787
799
  #bodyLabel;
788
800
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@johnmorrisdotca/wakusei-planets",
3
- "version": "0.57.0",
3
+ "version": "0.58.0",
4
4
  "description": "Wakusei Planets 惑星 — The Sun, planets and moons for the web: each as a clean line drawing, a shaded realistic drawing or a painted surface map, with real sizes, axial tilt and rotation as data, and positions of the moons for any date and time. SVG for the lines, three.js (optional) for the rest.",
5
5
  "keywords": [
6
6
  "planets",
@@ -214,6 +214,11 @@
214
214
  "import": "./dist/comets.js",
215
215
  "default": "./dist/comets.js"
216
216
  },
217
+ "./landing-sites": {
218
+ "types": "./dist/landing-sites.d.ts",
219
+ "import": "./dist/landing-sites.js",
220
+ "default": "./dist/landing-sites.js"
221
+ },
217
222
  "./places": {
218
223
  "types": "./dist/places.d.ts",
219
224
  "import": "./dist/places.js",
@@ -637,6 +642,7 @@
637
642
  "@angular/platform-browser": "^22.2.4",
638
643
  "@eslint/js": "^9.0.0",
639
644
  "@johnmorrisdotca/chikyu-earth": "^0.36.0",
645
+ "@johnmorrisdotca/hata": "^1.9.0",
640
646
  "@playwright/test": "1.64.0",
641
647
  "@sveltejs/vite-plugin-svelte": "^7.3.1",
642
648
  "@types/node": "^24.0.0",