@johnmorrisdotca/chikyu-earth 0.53.0 → 0.55.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,22 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.55.0 - 2026-11-17
6
+
7
+ - **Real satellite pictures of the ground under a point: `@johnmorrisdotca/chikyu-earth/photos`** (MODULES-1368). Pure functions that make the address of a NASA GIBS (Worldview) true-colour snapshot of a box around a point, so a page can show the ground under a satellite or a ride. The reader's browser fetches the picture from NASA (no key, no account, no server cache); about 250 m a pixel, clouds left in.
8
+ - **Functions.** `photoUrl({ lat, lon, sizeKm, date, widthPx })` (a WMS GetMap request, EPSG:4326, JPEG; a box over the date line or a pole is moved inside the world), `photoPieces` (the exact box as one request, or two across the date line), `photoBox`, `photoLayer`, `photoFallbacks` (the days to try, newest first, when a day's picture is black) and `photoCredit(lang, full?)` (the short credit line, English and Japanese, or NASA's own acknowledgement sentence). The layer is NOAA-20 VIIRS from 2018-01-05, then Suomi NPP VIIRS (2015-11-24 to 2026-11-02, when it ends) and MODIS Terra (from 2000-02-24); before that there is no picture.
9
+ - **Demo.** The flat map page has "The ground under it": choose a satellite, pick 100, 300 or 1,000 km, press the button, and the picture of the place under it appears with the credit line. English and Japanese.
10
+ - **Docs and tests.** English and Japanese guides, a tested example `examples/node/photos.mjs`, and unit tests of every function (the address strings only: no test asks NASA), each shown to fail when its code is broken. `NOTICE.md` has the terms.
11
+
12
+ ## 0.54.0 - 2026-11-17
13
+
14
+ - **North up in the view above a satellite, a compass, and sunlit or in shadow on the ground track** (MODULES-1437). Riding above the ISS the way it is going was always at the top of the picture, so a reader could not tell its real direction (astroviewer shows it heading south-east).
15
+ - **North up.** `ride(ref, { view: "above", up: "north" })`, the attribute `ride-up="north"` and the property `rideUp` put north at the top of the picture, so the satellite is seen to move the way it really moves over the ground. `"travel"` is the default and today's look. Set while riding, the picture turns to the new up in a glide of 0.8 s (a jump for reduced motion). **Pole rule:** within 3 degrees of a pole north-up gives way to travel-up, mixed in by a smooth step out to 6 degrees, so the picture never jumps; `NORTH_UP_POLE_DEG`, `NORTH_UP_BLEND_DEG`, `northUpYaw`, `localNorth` and `screenAngle` are in `/space`. **A drag** turns the picture from north by the amount dragged, and the compass shows where north has gone.
16
+ - **Compass.** A DOM overlay in the shadow root (an arrow to north with an N, a dot on the rim for the way it is going, and "Heading SE 128°"), in English and Japanese, in every ride of a satellite. It is updated by the draw that moves it, only when it moved by half a degree (a degree for the words): nothing at rest, no timer. `compass="off"` hides it, `compass="north"` keeps the arrow only; `--chikyu-compass-colour` and `--chikyu-compass-travel`.
17
+ - **Heading as numbers.** `rideTrack` (and `stats.ride.track`) and the event `chikyu-ride-track` give `lat`, `lon`, `heightKm`, `bearingDeg` (the ground track's direction from north, the Earth's turn taken out), `ascending`, `sunlit`, `northDeg` and `travelDeg`; the event is sent only when the whole degree, `ascending` or `sunlit` changes. Pure: `trackStateOf(position, velocity, ms)` and `trackStateOfScene` in `/flat` (no dependency), `groundTrackState(elements, ms)` in `/passes` (SGP4), `compassPoint`, `sunDirection`, `inEarthShadow`.
18
+ - **Sunlit or in shadow.** The ground track of `<chikyu-flat>` is amber in sunlight and blue in the Earth's shadow (a key under the map; `--chikyu-flat-track-sun`, `--chikyu-flat-track-shadow`), and so is the chosen satellite's orbit on `<chikyu-space>` and `<chikyu-earth-realistic>` (`path-light="off"` for one colour; `--chikyu-path-sun`, `--chikyu-path-shadow`), a change of look for the `selected` path's white. **The shadow model is a cylinder** of the Earth's equatorial radius (6,378.137 km) along the line from the Sun: no umbra cone, no penumbra (the cone's edge is about 11 km inside the cylinder's where the ISS enters, a few seconds). `chikyu-flat-pick` carries `sunlit`, `bearingDeg` and `ascending`; `stateOf(id)` and `selectedState` on the flat element; `groundTrack` points have `sunlit`.
19
+ - **Tests and docs.** Unit tests of the bearing against the analytic polar orbit and the 51.6 degree equator crossing (35.4 degrees), ascending and descending, the cylinder, and the ISS's share of an orbit in shadow against `acos(sqrt(1 - (Re/r)^2) / cos beta) / pi` at four Sun angles (within 1 percentage point); the north-up rule and the pole rule; `e2e/north-up.demo.ts` (north at the top and the compass at 0, travel up, a drag, the switch, reduced motion, the heading event, the flat track's two colours), and the `north` look in the freeze test. English and Japanese guides (the Japanese read by the Japanese reviewer), a tested example `examples/node/track-state.mjs`, and a demo row "Up is".
20
+
5
21
  ## 0.53.0 - 2026-11-16
6
22
 
7
23
  - **`<chikyu-flat>`: satellites on a flat map of the world** (MODULES-1391). A new entry `@johnmorrisdotca/chikyu-earth/flat/define` registers the element, and `@johnmorrisdotca/chikyu-earth/flat` holds its pure parts (they import on a server, with no dependency, not even satellite.js).
package/NOTICE.md CHANGED
@@ -80,6 +80,10 @@ The default layer is `Landsat_WELD_CorrectedReflectance_TrueColor_Global_Annual`
80
80
 
81
81
  The 500 m maps could fill one more level (65536 across for the day map); the pyramid stops at level 5 (day) and level 4 (night) for now. Where the pyramid is hosted: GitHub Pages of this public repository, which costs nothing (docs/guides/earth-tiles.md). It adds 3,412 files and 35.4 MB to the site (852 files and 10.3 MB before the 500 m levels; the levels above day 4 and night 3 go out only when the repository variable EARTH_TILES_ALL is yes, see docs/guides/earth-tiles.md). The source files are downloaded by the build (688 MB, once, kept by CI's cache) and are not part of the site.
82
82
 
83
+ ## Pictures of the ground under a point
84
+
85
+ `@johnmorrisdotca/chikyu-earth/photos` makes the address of a snapshot (a WMS GetMap request, `https://gibs.earthdata.nasa.gov/wms/epsg4326/best/wms.cgi`) of NASA's Global Imagery Browse Services for a box on a day, and the demo's flat map page asks for it from the reader's browser when a button is pressed. Nothing is fetched by the package and nothing is stored or sent through this site. The terms are those of the section above (the same page, the same acknowledgement, which `photoCredit(lang, true)` returns) and of NASA's media guidelines (https://www.nasa.gov/nasa-brand-center/images-and-media/: NASA content "generally are not subject to copyright in the United States", "NASA should be acknowledged as the source of the material"); not endorsed by NASA. The layers are `VIIRS_NOAA20_CorrectedReflectance_TrueColor`, `VIIRS_SNPP_CorrectedReflectance_TrueColor` and `MODIS_Terra_CorrectedReflectance_TrueColor`, with the days NASA's WMS capabilities document (`https://gibs.earthdata.nasa.gov/wms/epsg4326/best/wms.cgi?SERVICE=WMS&REQUEST=GetCapabilities&VERSION=1.3.0`) listed on 2026-11-17. On that day a GetMap for Suomi NPP after 2026-11-02 returned a black picture (the satellite's last day in the list), and one for NOAA-20 and MODIS Terra returned a picture; the answers carry `access-control-allow-origin: *`. NASA publishes no rate limit that this repository has read.
86
+
83
87
  ## The Moon's picture
84
88
 
85
89
  `moon-*.webp` is made by `scripts/make-textures.py` from NASA's Scientific Visualization Studio item 4720, "Moon: LROC colour mosaic" (https://svs.gsfc.nasa.gov/4720/,
package/README.md CHANGED
@@ -359,7 +359,7 @@ Passes are only as good as the orbit data are new: each pass says how old its el
359
359
  <p align="center"><img alt="Riding along with the ISS, tipped towards the horizon: the Earth's curve and atmosphere, and the orbits of the other stations in the sky" src="docs/images/space-ride-horizon.png" width="420"></p>
360
360
 
361
361
  `space.ride({ group: "stations", index: 0 }, { look: "horizon" })` puts the camera on the ISS (or a Starlink satellite, the Moon, a planet) at its real place for the moment shown and looks at the Earth, which goes by beneath
362
- as the body moves along its orbit; switch to another body and the camera glides there. Straight down or toward the horizon, from the body or following it at a distance, time faster or slower. A ridden satellite is in the picture by default (the camera a little behind and above it, a small drawing of it where the page has no model, not to scale); `ride-viewpoint="inside"` (property `rideViewpoint`, option `viewpoint`) puts the camera at the satellite instead. A drag turns the view where the camera is, like turning your head (the satellite leaves the picture as you look away); `ride-drag="orbit"` (property `rideDrag`, option `drag`) takes the camera round the satellite as before. Seen from above, the model shrinks as the ride rises and hands over to the ordinary mark by 2,000 km; `ride-model-size="fixed"` (property `rideModelSize`, option `modelSize`) keeps one size at every height. `ride-model-share`, `ride-model-seat` and `ride-zoom` frame and zoom the ridden satellite (properties `rideModelShare`, `rideModelSeat`, `rideZoom`). It animates continuously, so it keeps to the
362
+ as the body moves along its orbit; switch to another body and the camera glides there. Straight down or toward the horizon, from the body or following it at a distance, time faster or slower. A ridden satellite is in the picture by default (the camera a little behind and above it, a small drawing of it where the page has no model, not to scale); `ride-viewpoint="inside"` (property `rideViewpoint`, option `viewpoint`) puts the camera at the satellite instead. A drag turns the view where the camera is, like turning your head (the satellite leaves the picture as you look away); `ride-drag="orbit"` (property `rideDrag`, option `drag`) takes the camera round the satellite as before. Seen from above, the model shrinks as the ride rises and hands over to the ordinary mark by 2,000 km; `ride-model-size="fixed"` (property `rideModelSize`, option `modelSize`) keeps one size at every height. `ride-up="north"` (property `rideUp`, option `up`) puts north at the top of the view above a satellite, so it is seen to go the way it really goes; a small compass on a ride shows north and the heading (`compass="off"` hides it), `rideTrack` and `chikyu-ride-track` give the heading, ground point and whether the Sun lights it, and the chosen orbit is amber in sunlight and blue in the Earth's shadow (`path-light="off"` for one colour). `ride-model-share`, `ride-model-seat` and `ride-zoom` frame and zoom the ridden satellite (properties `rideModelShare`, `rideModelSeat`, `rideZoom`). It animates continuously, so it keeps to the
363
363
  same budget: at most 30 frames a second (one a second for reduced motion), nothing drawn while paused, out of sight or hidden. [Ride along guide](docs/guides/ride-along.md), [docs/ride-along.md](docs/ride-along.md).
364
364
 
365
365
  ## Printable sheets
@@ -614,7 +614,7 @@ console.log(countryList().filter((country) => country.alpha2 === null).map((coun
614
614
 
615
615
  ## How to cite
616
616
 
617
- > Morris, J. (2026). *Chikyu Earth* (version 0.53.0) [Computer software]. https://github.com/johnmorrisdotca/chikyu-earth
617
+ > Morris, J. (2026). *Chikyu Earth* (version 0.55.0) [Computer software]. https://github.com/johnmorrisdotca/chikyu-earth
618
618
 
619
619
  GitHub's "Cite this repository" button reads [CITATION.cff](CITATION.cff) and gives BibTeX and APA. Cite the version you used (`npm ls @johnmorrisdotca/chikyu-earth`), and credit the sources behind the numbers and pictures: [NOTICE.md](NOTICE.md) says who made each one and under what terms.
620
620
 
@@ -31,3 +31,25 @@ export declare const PLANE_COLOURS: readonly string[];
31
31
  * ```
32
32
  */
33
33
  export declare const SPARE_COLOUR = "#9aa5b1";
34
+ /**
35
+ * The colour of a ground track where the satellite is in sunlight: a warm amber. It is one half of a pair chosen to be told apart by a reader who cannot tell red from green (amber and blue differ in lightness as well as in hue), and each stretch is drawn over a dark edge so it reads on a dark sea and on a light one. The element's `--chikyu-flat-track-sun` overrides it.
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * import { TRACK_SUNLIT } from "@johnmorrisdotca/chikyu-earth/flat";
40
+ *
41
+ * console.log(TRACK_SUNLIT);
42
+ * ```
43
+ */
44
+ export declare const TRACK_SUNLIT = "#ffb02e";
45
+ /**
46
+ * The colour of a ground track where the satellite is in the Earth's shadow: a cool blue. The element's `--chikyu-flat-track-shadow` overrides it.
47
+ *
48
+ * @example
49
+ * ```ts
50
+ * import { TRACK_SHADOW } from "@johnmorrisdotca/chikyu-earth/flat";
51
+ *
52
+ * console.log(TRACK_SHADOW);
53
+ * ```
54
+ */
55
+ export declare const TRACK_SHADOW = "#5aa9ff";
@@ -47,3 +47,25 @@ export const PLANE_COLOURS = ["#ff7a59", "#ffd23f", "#6ee7a0", "#4cc9f0", "#a78b
47
47
  * ```
48
48
  */
49
49
  export const SPARE_COLOUR = "#9aa5b1";
50
+ /**
51
+ * The colour of a ground track where the satellite is in sunlight: a warm amber. It is one half of a pair chosen to be told apart by a reader who cannot tell red from green (amber and blue differ in lightness as well as in hue), and each stretch is drawn over a dark edge so it reads on a dark sea and on a light one. The element's `--chikyu-flat-track-sun` overrides it.
52
+ *
53
+ * @example
54
+ * ```ts
55
+ * import { TRACK_SUNLIT } from "@johnmorrisdotca/chikyu-earth/flat";
56
+ *
57
+ * console.log(TRACK_SUNLIT);
58
+ * ```
59
+ */
60
+ export const TRACK_SUNLIT = "#ffb02e";
61
+ /**
62
+ * The colour of a ground track where the satellite is in the Earth's shadow: a cool blue. The element's `--chikyu-flat-track-shadow` overrides it.
63
+ *
64
+ * @example
65
+ * ```ts
66
+ * import { TRACK_SHADOW } from "@johnmorrisdotca/chikyu-earth/flat";
67
+ *
68
+ * console.log(TRACK_SHADOW);
69
+ * ```
70
+ */
71
+ export const TRACK_SHADOW = "#5aa9ff";
@@ -1,5 +1,6 @@
1
1
  import type { ElementSet } from "../satellites/types.ts";
2
2
  import { type GroupFacts, type Plane } from "./facts.ts";
3
+ import { type GroundTrackState } from "./track-state.ts";
3
4
  import { type FlatLang } from "./words.ts";
4
5
  /**
5
6
  * One satellite of a group, as a page is told of it: what `chikyu-flat-pick` carries.
@@ -22,6 +23,12 @@ export interface FlatPick {
22
23
  /** The letter of its orbital plane (`A`), or null when it is in none. */
23
24
  plane: string | null;
24
25
  altitudeKm: number;
26
+ /** True when the Sun lights it, false when it is in the Earth's shadow (the cylindrical model of `inEarthShadow`), at the moment shown. Null when it cannot be placed exactly then. */
27
+ sunlit: boolean | null;
28
+ /** The way its ground track runs, degrees clockwise from north (0 to 360), at the moment shown; null when it cannot be placed exactly. */
29
+ bearingDeg: number | null;
30
+ /** True going north, false going south; null when it cannot be placed exactly. */
31
+ ascending: boolean | null;
25
32
  /** What chose it: a pointer going over it (`hover`), a tap or click (`tap`), or the keyboard (`key`). */
26
33
  via: "hover" | "tap" | "key";
27
34
  }
@@ -61,7 +68,7 @@ export interface GroupStyle {
61
68
  *
62
69
  * The page gives it orbital elements: `setGroup(id, sets)` for each group (the ids of `SATELLITE_GROUPS` are known by name and colour), or the `elements` property for one, or `elements-src` (an address, read once, through `fetchElements`' rules). The package fetches nothing of its own.
63
70
  * Attributes: `center` (the longitude in the middle, degrees; 0, Greenwich, by default; the map wraps round the date line), `home-lon` and `home-lat` (the reader's place: a marker, and the "My place" button, which appear only when given; the element never asks the browser for a place),
64
- * `group` (which groups to show: `all`, one id, or several with commas), `off` (groups that are loaded but start off when `group` names none, such as `starlink`: the filter chip turns one on), `colour-by` (`group`, or `plane` to colour by orbital plane), `plane` (a plane letter: show that plane only), `footprint` and `track` (draw the coverage circle and the ground track; the footprint is of the chosen satellite, or of every one shown when there are 80 or fewer),
71
+ * `group` (which groups to show: `all`, one id, or several with commas), `off` (groups that are loaded but start off when `group` names none, such as `starlink`: the filter chip turns one on), `colour-by` (`group`, or `plane` to colour by orbital plane), `plane` (a plane letter: show that plane only), `footprint` and `track` (draw the coverage circle and the ground track, which is amber in sunlight and blue in the Earth's shadow, a cylinder, with a key: `--chikyu-flat-track-sun` and `--chikyu-flat-track-shadow` change the colours; the footprint is of the chosen satellite, or of every one shown when there are 80 or fewer),
65
72
  * `paused` (hold the clock and keep the speed; nothing is drawn while it is held), `trails` (`off` for no streaks at a fast clock), `footprint-elevation` (degrees above the horizon the circle is drawn for; 25 like the 3D beam), `selected` (a NORAD number: the chosen satellite), `time` (`now` or an ISO date; live when absent), `speed` (1 is real time, 0 holds, 86400 is a day a second, negative runs backwards), `estimate-far`, `shade` (`off` for no night),
66
73
  * `dot-size` (pixels), `controls` (`none`, or any of `centre zoom footprint track chips`: the built-in buttons and filter chips shown; all by default) and `lang` (`en` or `ja`; the page's language by default).
67
74
  *
@@ -161,6 +168,16 @@ export declare class ChikyuFlat extends HTMLElement {
161
168
  connectedCallback(): void;
162
169
  disconnectedCallback(): void;
163
170
  attributeChangedCallback(name: string): void;
171
+ /**
172
+ * Where a loaded satellite is over the ground at the moment shown, which way its ground track runs and whether the Sun lights it: `{ lat, lon, heightKm, bearingDeg, ascending, sunlit }` (see `GroundTrackState`), placed exactly by SGP4. Null when the number names no loaded satellite
173
+ * or it cannot be placed at that moment. It is the same state that `chikyu-flat-pick` carries (`sunlit`, `bearingDeg`, `ascending`).
174
+ *
175
+ * @param id - The NORAD catalogue number.
176
+ * @returns The state, or null.
177
+ */
178
+ stateOf(id: number): GroundTrackState | null;
179
+ /** The state (`stateOf`) of the chosen satellite, or null when none is chosen. */
180
+ get selectedState(): GroundTrackState | null;
164
181
  /** Choose a satellite from code, as a reader's tap would, without sending `chikyu-flat-pick`. A NORAD number the groups do not hold, or `null`, clears the choice. */
165
182
  pick(id: number | null): void;
166
183
  }
@@ -13,9 +13,10 @@ import { SHORT_NAMES } from "../satellites/names.js";
13
13
  import { MAX_SATELLITE_SPEED } from "../satellites/limits.js";
14
14
  import { fetchElements } from "../satellites/source.js";
15
15
  import { createSatellites } from "../satellites/track.js";
16
- import { GROUP_COLOURS, PLANE_COLOURS, SPARE_COLOUR } from "./colours.js";
16
+ import { GROUP_COLOURS, PLANE_COLOURS, SPARE_COLOUR, TRACK_SHADOW, TRACK_SUNLIT } from "./colours.js";
17
17
  import { clusterPlanes, groupFacts } from "./facts.js";
18
18
  import { FLATTENED, MAX_ZOOM, clampView, pixelsPerDegree, projectFlat, wrapLongitude, zoomAbout } from "./geometry.js";
19
+ import { trackStateOfScene } from "./track-state.js";
19
20
  import { say } from "./words.js";
20
21
  const RAD = Math.PI / 180;
21
22
  /** The most satellites whose footprints are drawn at once when none is chosen. */
@@ -28,6 +29,22 @@ const STREAK_PX = 28;
28
29
  const STREAK_PX_CROWD = 10;
29
30
  /** The furthest a pointer may move between going down and coming up and still be a tap, pixels. */
30
31
  const TAP_SLOP = 5;
32
+ /** Cut a ground track into stretches of sunlight and shadow. Each stretch ends on the first point of the next, so the line has no gap where the light changes. */
33
+ const trackRuns = (points) => {
34
+ const runs = [];
35
+ let run = null;
36
+ for (const p of points) {
37
+ if (!run || run.sunlit !== p.sunlit) {
38
+ const next = { sunlit: p.sunlit, points: [] };
39
+ if (run && run.points.length > 0)
40
+ next.points.push(run.points[run.points.length - 1]);
41
+ runs.push(next);
42
+ run = next;
43
+ }
44
+ run.points.push([p.lon, p.lat]);
45
+ }
46
+ return runs;
47
+ };
31
48
  const sameRef = (a, b) => a === b || (a !== null && b !== null && a.g === b.g && a.i === b.i);
32
49
  const escape = (text) => text.replace(/[&<>"]/g, (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;" })[c]);
33
50
  const flag = (value) => value !== null && !/^(off|false|no|0)$/i.test(value.trim());
@@ -69,6 +86,10 @@ canvas{position:absolute;inset:0;width:100%;height:100%;display:block}
69
86
  .ring.hov{width:14px;height:14px;margin:-7px 0 0 -7px;border-width:1px}
70
87
  .ring[hidden],.tip[hidden]{display:none}
71
88
  .tip{position:absolute;left:0;top:0;pointer-events:none;background:rgba(8,14,28,.94);color:#fff;padding:4px 8px;border-radius:6px;font-size:.85em;line-height:1.3;white-space:nowrap;border:1px solid rgba(255,255,255,.3)}
89
+ .key{position:absolute;left:8px;bottom:8px;display:flex;flex-wrap:wrap;gap:4px 12px;margin:0;padding:3px 8px;border-radius:6px;background:rgba(8,14,28,.82);color:#fff;font-size:.8em;line-height:1.3;pointer-events:none;max-width:calc(100% - 16px)}
90
+ .key[hidden]{display:none}
91
+ .key span{display:inline-flex;align-items:center;gap:6px}
92
+ .key i{display:inline-block;width:18px;height:0;border-top:3px solid var(--k,#fff);border-radius:2px;box-shadow:0 0 0 1px rgba(0,0,0,.55)}
72
93
  .msg{position:absolute;inset:0;display:grid;place-items:center;margin:0;padding:12px;text-align:center;color:#cfe0f5;pointer-events:none}
73
94
  .msg:empty{display:none}
74
95
  .sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
@@ -78,7 +99,7 @@ canvas{position:absolute;inset:0;width:100%;height:100%;display:block}
78
99
  *
79
100
  * The page gives it orbital elements: `setGroup(id, sets)` for each group (the ids of `SATELLITE_GROUPS` are known by name and colour), or the `elements` property for one, or `elements-src` (an address, read once, through `fetchElements`' rules). The package fetches nothing of its own.
80
101
  * Attributes: `center` (the longitude in the middle, degrees; 0, Greenwich, by default; the map wraps round the date line), `home-lon` and `home-lat` (the reader's place: a marker, and the "My place" button, which appear only when given; the element never asks the browser for a place),
81
- * `group` (which groups to show: `all`, one id, or several with commas), `off` (groups that are loaded but start off when `group` names none, such as `starlink`: the filter chip turns one on), `colour-by` (`group`, or `plane` to colour by orbital plane), `plane` (a plane letter: show that plane only), `footprint` and `track` (draw the coverage circle and the ground track; the footprint is of the chosen satellite, or of every one shown when there are 80 or fewer),
102
+ * `group` (which groups to show: `all`, one id, or several with commas), `off` (groups that are loaded but start off when `group` names none, such as `starlink`: the filter chip turns one on), `colour-by` (`group`, or `plane` to colour by orbital plane), `plane` (a plane letter: show that plane only), `footprint` and `track` (draw the coverage circle and the ground track, which is amber in sunlight and blue in the Earth's shadow, a cylinder, with a key: `--chikyu-flat-track-sun` and `--chikyu-flat-track-shadow` change the colours; the footprint is of the chosen satellite, or of every one shown when there are 80 or fewer),
82
103
  * `paused` (hold the clock and keep the speed; nothing is drawn while it is held), `trails` (`off` for no streaks at a fast clock), `footprint-elevation` (degrees above the horizon the circle is drawn for; 25 like the 3D beam), `selected` (a NORAD number: the chosen satellite), `time` (`now` or an ISO date; live when absent), `speed` (1 is real time, 0 holds, 86400 is a day a second, negative runs backwards), `estimate-far`, `shade` (`off` for no night),
83
104
  * `dot-size` (pixels), `controls` (`none`, or any of `centre zoom footprint track chips`: the built-in buttons and filter chips shown; all by default) and `lang` (`en` or `ja`; the page's language by default).
84
105
  *
@@ -139,6 +160,7 @@ export class ChikyuFlat extends HTMLElement {
139
160
  #mapKey = "";
140
161
  #trackKey = "";
141
162
  #trackLines = null;
163
+ #key;
142
164
  #stage;
143
165
  #bar;
144
166
  #mapCanvas;
@@ -888,8 +910,10 @@ export class ChikyuFlat extends HTMLElement {
888
910
  const wantFootprint = this.#footprint;
889
911
  const wantTrack = this.#track;
890
912
  const chosen = this.#selected && this.#selected.g.on[this.#selected.i] === 1 ? this.#selected : null;
891
- if (!wantFootprint && !(wantTrack && chosen))
913
+ if (!wantFootprint && !(wantTrack && chosen)) {
914
+ this.#showKey(false);
892
915
  return;
916
+ }
893
917
  const path = geoPath(this.#projection(), ctx);
894
918
  if (wantFootprint) {
895
919
  const elevation = finite(this.getAttribute("footprint-elevation"), BEAM_ELEVATION);
@@ -921,19 +945,59 @@ export class ChikyuFlat extends HTMLElement {
921
945
  if (wantTrack && chosen) {
922
946
  const lines = this.#trackOf(chosen, ms);
923
947
  if (lines) {
924
- ctx.lineWidth = 1.6;
925
- ctx.strokeStyle = "rgba(255,255,255,0.35)";
926
- ctx.setLineDash([4, 4]);
927
- ctx.beginPath();
928
- path({ type: "LineString", coordinates: lines.past });
929
- ctx.stroke();
948
+ const colours = this.#trackColours();
949
+ // each stretch is drawn over a dark edge, so it reads on a dark sea and on a light one; the part behind the satellite is dashed, the part ahead solid
950
+ const stroke = (runs, dash, sun) => {
951
+ ctx.setLineDash(dash);
952
+ for (const run of runs) {
953
+ if (run.sunlit !== sun || run.points.length < 2)
954
+ continue;
955
+ ctx.beginPath();
956
+ path({ type: "LineString", coordinates: run.points });
957
+ ctx.stroke();
958
+ }
959
+ };
960
+ for (const pass of [0, 1]) {
961
+ ctx.lineCap = "butt";
962
+ for (const [runs, dash] of [[lines.past, [4, 4]], [lines.future, []]]) {
963
+ for (const sun of [true, false]) {
964
+ ctx.lineWidth = pass === 0 ? 4 : 2;
965
+ ctx.strokeStyle = pass === 0 ? "rgba(4,8,18,0.55)" : sun ? colours.sun : colours.shadow;
966
+ stroke(runs, [...dash], sun);
967
+ }
968
+ }
969
+ }
930
970
  ctx.setLineDash([]);
931
- ctx.strokeStyle = "rgba(255,255,255,0.9)";
932
- ctx.beginPath();
933
- path({ type: "LineString", coordinates: lines.future });
934
- ctx.stroke();
935
971
  }
936
972
  }
973
+ this.#showKey(wantTrack && chosen !== null);
974
+ }
975
+ /** The colours of the ground track: amber in sunlight, blue in the Earth's shadow, or the page's own (`--chikyu-flat-track-sun`, `--chikyu-flat-track-shadow`). */
976
+ #trackColours() {
977
+ const style = getComputedStyle(this);
978
+ return { sun: style.getPropertyValue("--chikyu-flat-track-sun").trim() || TRACK_SUNLIT, shadow: style.getPropertyValue("--chikyu-flat-track-shadow").trim() || TRACK_SHADOW };
979
+ }
980
+ /** The key to the track's two colours, shown while the track is. It changes only when the track appears or goes, or the language does. */
981
+ #showKey(on) {
982
+ const key = this.#key;
983
+ if (!key)
984
+ return;
985
+ if (key.hidden === !on && (!on || key.lang === this.language))
986
+ return;
987
+ key.hidden = !on;
988
+ if (!on)
989
+ return;
990
+ const lang = this.language;
991
+ const colours = this.#trackColours();
992
+ key.lang = lang;
993
+ key.setAttribute("aria-label", say(lang, "trackKey"));
994
+ key.replaceChildren(...[["trackSunlit", colours.sun], ["trackShadow", colours.shadow]].map(([word, colour]) => {
995
+ const item = key.ownerDocument.createElement("span");
996
+ const line = key.ownerDocument.createElement("i");
997
+ line.style.setProperty("--k", colour);
998
+ item.append(line, say(lang, word));
999
+ return item;
1000
+ }));
937
1001
  }
938
1002
  /** The ground track of the chosen satellite for one orbit, half behind it and half ahead, worked out again when the clock has moved a fortieth of an orbit. */
939
1003
  #trackOf(ref, ms) {
@@ -951,10 +1015,7 @@ export class ChikyuFlat extends HTMLElement {
951
1015
  this.#trackKey = key;
952
1016
  const step = Math.max(5, period / 1000 / 160);
953
1017
  const points = groundTrack(set, ms - period / 2, ms + period / 2, step);
954
- this.#trackLines = {
955
- past: points.filter((p) => p.ms <= ms).map((p) => [p.lon, p.lat]),
956
- future: points.filter((p) => p.ms >= ms).map((p) => [p.lon, p.lat]),
957
- };
1018
+ this.#trackLines = { past: trackRuns(points.filter((p) => p.ms <= ms)), future: trackRuns(points.filter((p) => p.ms >= ms)) };
958
1019
  }
959
1020
  return this.#trackLines;
960
1021
  }
@@ -1043,12 +1104,15 @@ export class ChikyuFlat extends HTMLElement {
1043
1104
  tip.setAttribute("aria-hidden", "true");
1044
1105
  const msg = Object.assign(d.createElement("p"), { className: "msg" });
1045
1106
  msg.setAttribute("role", "status");
1107
+ const key = Object.assign(d.createElement("p"), { className: "key", hidden: true });
1108
+ key.setAttribute("role", "group");
1046
1109
  const live = Object.assign(d.createElement("p"), { className: "sr", id: "live" });
1047
1110
  live.setAttribute("role", "status");
1048
1111
  live.setAttribute("aria-live", "polite");
1049
1112
  const help = Object.assign(d.createElement("p"), { className: "sr", id: "help" });
1050
1113
  dots.setAttribute("aria-describedby", "help live");
1051
- stage.append(map, dots, selRing, hovRing, tip, msg);
1114
+ stage.append(map, dots, selRing, hovRing, tip, key, msg);
1115
+ this.#key = key;
1052
1116
  root.append(bar, stage, live, help);
1053
1117
  this.#bar = bar;
1054
1118
  this.#stage = stage;
@@ -1260,9 +1324,10 @@ export class ChikyuFlat extends HTMLElement {
1260
1324
  return best;
1261
1325
  }
1262
1326
  #pick(ref, via) {
1327
+ const state = ref ? this.#stateOf(ref) : null;
1263
1328
  const detail = ref
1264
- ? { id: ref.g.sats.sets[ref.i].NORAD_CAT_ID, index: ref.i, group: ref.g.id, name: this.#nameOf(ref), plane: this.#planeOfRef(ref), altitudeKm: ref.g.alt[ref.i], via }
1265
- : { id: null, index: -1, group: null, name: null, plane: null, altitudeKm: null, via };
1329
+ ? { id: ref.g.sats.sets[ref.i].NORAD_CAT_ID, index: ref.i, group: ref.g.id, name: this.#nameOf(ref), plane: this.#planeOfRef(ref), altitudeKm: ref.g.alt[ref.i], sunlit: state?.sunlit ?? null, bearingDeg: state?.bearingDeg ?? null, ascending: state?.ascending ?? null, via }
1330
+ : { id: null, index: -1, group: null, name: null, plane: null, altitudeKm: null, sunlit: null, bearingDeg: null, ascending: null, via };
1266
1331
  this.dispatchEvent(new CustomEvent("chikyu-flat-pick", { detail, bubbles: true, composed: true }));
1267
1332
  }
1268
1333
  #choose(ref, via) {
@@ -1285,8 +1350,32 @@ export class ChikyuFlat extends HTMLElement {
1285
1350
  this.#pick(null, via);
1286
1351
  }
1287
1352
  #announceLive(ref) {
1288
- if (this.#live)
1289
- this.#live.textContent = this.#describe(ref);
1353
+ if (!this.#live)
1354
+ return;
1355
+ const state = this.#stateOf(ref);
1356
+ this.#live.textContent = this.#describe(ref) + (state ? say(this.language, state.sunlit ? "sunlitNow" : "shadowNow") : "");
1357
+ }
1358
+ /** Where one satellite is over the ground, which way it goes and whether the Sun lights it, at the moment shown (SGP4 placed exactly, one call); null when it cannot be placed then. */
1359
+ #stateOf(ref) {
1360
+ const out = new Float64Array(6);
1361
+ if (!ref.g.sats.exact(ref.i, this.time, out))
1362
+ return null;
1363
+ return trackStateOfScene([out[0], out[1], out[2]], [out[3], out[4], out[5]], this.time);
1364
+ }
1365
+ /**
1366
+ * Where a loaded satellite is over the ground at the moment shown, which way its ground track runs and whether the Sun lights it: `{ lat, lon, heightKm, bearingDeg, ascending, sunlit }` (see `GroundTrackState`), placed exactly by SGP4. Null when the number names no loaded satellite
1367
+ * or it cannot be placed at that moment. It is the same state that `chikyu-flat-pick` carries (`sunlit`, `bearingDeg`, `ascending`).
1368
+ *
1369
+ * @param id - The NORAD catalogue number.
1370
+ * @returns The state, or null.
1371
+ */
1372
+ stateOf(id) {
1373
+ const ref = this.#index.get(id);
1374
+ return ref ? this.#stateOf(ref) : null;
1375
+ }
1376
+ /** The state (`stateOf`) of the chosen satellite, or null when none is chosen. */
1377
+ get selectedState() {
1378
+ return this.#selected ? this.#stateOf(this.#selected) : null;
1290
1379
  }
1291
1380
  #onDown = (event) => {
1292
1381
  if (event.pointerType === "mouse" && event.button !== 0)
@@ -1,5 +1,6 @@
1
1
  export { clusterPlanes, groupFacts, planeLetter, type FlatElements, type GroupFacts, type Plane, type PlaneClusters, type PlaneOptions } from "./facts.ts";
2
2
  export { FLATTENED, MAX_ZOOM, clampView, groundPoint, pixelsPerDegree, projectFlat, unprojectFlat, wrapLongitude, zoomAbout, type FlatView } from "./geometry.ts";
3
- export { GROUP_COLOURS, PLANE_COLOURS, SPARE_COLOUR } from "./colours.ts";
3
+ export { COMPASS_POINTS, SHADOW_RADIUS_KM, compassPoint, inEarthShadow, shadowFlags, sunDirection, sunDirectionScene, trackStateOf, trackStateOfScene, type CompassPoint, type GroundTrackState } from "./track-state.ts";
4
+ export { GROUP_COLOURS, PLANE_COLOURS, SPARE_COLOUR, TRACK_SHADOW, TRACK_SUNLIT } from "./colours.ts";
4
5
  export { FLAT_WORDS, type FlatLang } from "./words.ts";
5
6
  export type { ChikyuFlat, FlatPick, FlatPlane, GroupStyle } from "./element.ts";
@@ -2,5 +2,6 @@
2
2
  // The element itself is in `@johnmorrisdotca/chikyu-earth/flat/define`, which registers `<chikyu-flat>`.
3
3
  export { clusterPlanes, groupFacts, planeLetter } from "./facts.js";
4
4
  export { FLATTENED, MAX_ZOOM, clampView, groundPoint, pixelsPerDegree, projectFlat, unprojectFlat, wrapLongitude, zoomAbout } from "./geometry.js";
5
- export { GROUP_COLOURS, PLANE_COLOURS, SPARE_COLOUR } from "./colours.js";
5
+ export { COMPASS_POINTS, SHADOW_RADIUS_KM, compassPoint, inEarthShadow, shadowFlags, sunDirection, sunDirectionScene, trackStateOf, trackStateOfScene } from "./track-state.js";
6
+ export { GROUP_COLOURS, PLANE_COLOURS, SPARE_COLOUR, TRACK_SHADOW, TRACK_SUNLIT } from "./colours.js";
6
7
  export { FLAT_WORDS } from "./words.js";
@@ -0,0 +1,174 @@
1
+ /**
2
+ * The radius of the Earth's shadow, kilometres: the Earth's equatorial radius (6,378.137 km). The shadow is a cylinder of this radius along the line from the Sun through the Earth's centre (the cylindrical model: the edge of a conical umbra
3
+ * leans in by about 0.26 degrees, so where a satellite at 400 km enters the shadow the cylinder's edge is about 11 km outside the cone's, a few seconds of an orbit, and no penumbra is drawn). A satellite is in shadow when it is on the night side of the centre and inside the cylinder.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * import { SHADOW_RADIUS_KM } from "@johnmorrisdotca/chikyu-earth/flat";
8
+ *
9
+ * console.log(SHADOW_RADIUS_KM);
10
+ * ```
11
+ */
12
+ export declare const SHADOW_RADIUS_KM = 6378.137;
13
+ /**
14
+ * Where a satellite is over the ground at one moment and how it is going.
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * import type { GroundTrackState } from "@johnmorrisdotca/chikyu-earth/flat";
19
+ *
20
+ * const say = (s: GroundTrackState): string => `${s.bearingDeg.toFixed(0)} degrees, ${s.ascending ? "ascending" : "descending"}, ${s.sunlit ? "sunlit" : "in shadow"}`;
21
+ * console.log(typeof say);
22
+ * ```
23
+ */
24
+ export interface GroundTrackState {
25
+ /** Degrees north of the equator, geodetic (on the WGS84 ellipsoid), -90 to 90. */
26
+ lat: number;
27
+ /** Degrees east of Greenwich, -180 to 180. */
28
+ lon: number;
29
+ /** Height above the WGS84 ellipsoid, kilometres. */
30
+ heightKm: number;
31
+ /** The way the point under the satellite is going over the ground, degrees clockwise from north (0 north, 90 east, 180 south, 270 west), 0 up to 360. The Earth's turn is taken out: this is the direction of the ground track, not of the satellite's path through space. 0 when the satellite is not moving over the ground. */
32
+ bearingDeg: number;
33
+ /** True when it is going north (its latitude is rising), false when going south. */
34
+ ascending: boolean;
35
+ /** True when the Sun lights it, false when it is in the Earth's shadow (the cylindrical model, {@link SHADOW_RADIUS_KM}). */
36
+ sunlit: boolean;
37
+ }
38
+ /**
39
+ * The Sun as a unit vector in the Earth-fixed axes (x through longitude 0 on the equator, y east, z north) at `ms`, from the same low-precision Sun as the night side of the maps.
40
+ *
41
+ * @param ms - A moment, in milliseconds since the Unix epoch.
42
+ * @returns The unit vector from the Earth's centre towards the Sun.
43
+ *
44
+ * @example
45
+ * ```ts
46
+ * import { sunDirection } from "@johnmorrisdotca/chikyu-earth/flat";
47
+ *
48
+ * const sun = sunDirection(Date.UTC(2026, 5, 21, 12));
49
+ * console.log(sun.map((n) => n.toFixed(2)));
50
+ * ```
51
+ */
52
+ export declare function sunDirection(ms: number): [number, number, number];
53
+ /**
54
+ * Is a point in the Earth's shadow? Cylindrical model: behind the Earth's centre from the Sun and nearer the Sun-Earth line than {@link SHADOW_RADIUS_KM}.
55
+ *
56
+ * @param position - The point, kilometres from the Earth's centre, in any axes.
57
+ * @param sun - The unit vector towards the Sun, in the same axes.
58
+ * @returns True in shadow, false in sunlight (a point exactly on the terminator plane is sunlit).
59
+ *
60
+ * @example
61
+ * ```ts
62
+ * import { inEarthShadow } from "@johnmorrisdotca/chikyu-earth/flat";
63
+ *
64
+ * // the Sun along +x: a satellite 7,000 km out on the far side is in shadow, one at the same distance beside the Earth is not
65
+ * console.log(inEarthShadow([-7000, 0, 0], [1, 0, 0]), inEarthShadow([0, 7000, 0], [1, 0, 0]));
66
+ * ```
67
+ */
68
+ export declare function inEarthShadow(position: readonly [number, number, number], sun: readonly [number, number, number]): boolean;
69
+ /**
70
+ * Where a satellite is over the ground, how it is going and whether the Sun lights it, from its place and velocity in the axes SGP4 uses (TEME: x to the vernal equinox, z north, y a quarter turn east of x) and the moment. The
71
+ * velocity is turned into the ground's frame by taking the Earth's turn out of it, so the bearing is the way the ground track runs, as a map draws it.
72
+ *
73
+ * @param position - Kilometres from the Earth's centre, TEME.
74
+ * @param velocity - Kilometres a second, TEME.
75
+ * @param ms - The moment, in milliseconds since the Unix epoch.
76
+ * @returns Latitude, longitude, height, bearing, ascending or descending, and sunlit.
77
+ *
78
+ * @example
79
+ * ```ts
80
+ * import { trackStateOf } from "@johnmorrisdotca/chikyu-earth/flat";
81
+ *
82
+ * // 420 km over the equator going north at 7.66 km a second
83
+ * const at = Date.UTC(2026, 10, 3, 12);
84
+ * const state = trackStateOf([6798, 0, 0], [0, 0, 7.66], at);
85
+ * console.log(state.ascending, Math.round(state.heightKm));
86
+ * ```
87
+ */
88
+ export declare function trackStateOf(position: readonly [number, number, number], velocity: readonly [number, number, number], ms: number): GroundTrackState;
89
+ /**
90
+ * The same as {@link trackStateOf}, for a place and velocity in the package's own satellite axes (what `createSatellites(...).exact` and the space view give): Earth radii of 6,371 km, x to the vernal equinox, y north, z the other way from TEME's y; the velocity in kilometres a second in the same axes.
91
+ *
92
+ * @param place - Earth radii from the Earth's centre.
93
+ * @param velocity - Kilometres a second.
94
+ * @param ms - The moment, in milliseconds since the Unix epoch.
95
+ * @returns Latitude, longitude, height, bearing, ascending or descending, and sunlit.
96
+ *
97
+ * @example
98
+ * ```ts
99
+ * import { trackStateOfScene } from "@johnmorrisdotca/chikyu-earth/flat";
100
+ *
101
+ * const state = trackStateOfScene([1.0665, 0, 0], [0, 7.66, 0], Date.UTC(2026, 10, 3, 12));
102
+ * console.log(state.ascending);
103
+ * ```
104
+ */
105
+ export declare function trackStateOfScene(place: readonly [number, number, number], velocity: readonly [number, number, number], ms: number): GroundTrackState;
106
+ /**
107
+ * The eight points of the compass, from north clockwise.
108
+ *
109
+ * @example
110
+ * ```ts
111
+ * import { COMPASS_POINTS } from "@johnmorrisdotca/chikyu-earth/flat";
112
+ *
113
+ * console.log(COMPASS_POINTS.join(" "));
114
+ * ```
115
+ */
116
+ export declare const COMPASS_POINTS: readonly ["N", "NE", "E", "SE", "S", "SW", "W", "NW"];
117
+ /**
118
+ * One of the eight points of the compass.
119
+ *
120
+ * @example
121
+ * ```ts
122
+ * import type { CompassPoint } from "@johnmorrisdotca/chikyu-earth/flat";
123
+ *
124
+ * const point: CompassPoint = "SE";
125
+ * console.log(point);
126
+ * ```
127
+ */
128
+ export type CompassPoint = (typeof COMPASS_POINTS)[number];
129
+ /**
130
+ * The point of the compass a bearing is nearest to: 0 is N, 45 NE, 90 E, 135 SE, 180 S and so on, each point taking 45 degrees (22.5 either side).
131
+ *
132
+ * @param bearingDeg - Degrees clockwise from north.
133
+ * @returns N, NE, E, SE, S, SW, W or NW.
134
+ *
135
+ * @example
136
+ * ```ts
137
+ * import { compassPoint } from "@johnmorrisdotca/chikyu-earth/flat";
138
+ *
139
+ * console.log(compassPoint(128), compassPoint(350));
140
+ * ```
141
+ */
142
+ export declare function compassPoint(bearingDeg: number): CompassPoint;
143
+ /**
144
+ * The Sun as a unit vector in the satellites' own axes (x to the vernal equinox, y north, z the other way from TEME's y: what `createSatellites` and the space view use) at `ms`.
145
+ *
146
+ * @param ms - A moment, in milliseconds since the Unix epoch.
147
+ * @returns The unit vector from the Earth's centre towards the Sun.
148
+ *
149
+ * @example
150
+ * ```ts
151
+ * import { sunDirectionScene } from "@johnmorrisdotca/chikyu-earth/flat";
152
+ *
153
+ * console.log(sunDirectionScene(Date.UTC(2026, 2, 20, 9)).map((n) => n.toFixed(2)));
154
+ * ```
155
+ */
156
+ export declare function sunDirectionScene(ms: number): [number, number, number];
157
+ /**
158
+ * Which points of a path are in the Earth's shadow: 1 for in shadow, 0 for in sunlight (the cylindrical model, {@link SHADOW_RADIUS_KM}), for places in the satellites' own axes in Earth radii of 6,371 km. The Sun is taken as fixed over the path, which holds for the one revolution a path is (the Sun moves a quarter of a degree in that time).
159
+ *
160
+ * @param positions - Three numbers a point, Earth radii.
161
+ * @param count - How many points.
162
+ * @param sun - The unit vector towards the Sun in the same axes (`sunDirectionScene`).
163
+ * @param out - Where to put the flags, one a point.
164
+ * @returns `out`.
165
+ *
166
+ * @example
167
+ * ```ts
168
+ * import { shadowFlags } from "@johnmorrisdotca/chikyu-earth/flat";
169
+ *
170
+ * // the Sun along +x: the point behind the Earth is in shadow, the one in front of it is not
171
+ * console.log(shadowFlags(new Float32Array([-1.1, 0, 0, 1.1, 0, 0]), 2, [1, 0, 0], new Uint8Array(2)));
172
+ * ```
173
+ */
174
+ export declare function shadowFlags(positions: ArrayLike<number>, count: number, sun: readonly [number, number, number], out: Uint8Array): Uint8Array;