@johnmorrisdotca/chikyu-earth 0.55.0 → 0.57.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 +20 -0
- package/NOTICE.md +1 -1
- package/README.md +2 -1
- package/dist/door/gibs.d.ts +55 -6
- package/dist/door/gibs.js +177 -51
- package/dist/photos/index.js +4 -27
- package/dist/realistic/element-base.d.ts +21 -0
- package/dist/realistic/element-base.js +57 -14
- package/dist/realistic/gate.d.ts +5 -0
- package/dist/realistic/gate.js +5 -2
- package/dist/realistic/index.d.ts +1 -0
- package/dist/realistic/index.js +1 -0
- package/dist/realistic/pace.d.ts +98 -0
- package/dist/realistic/pace.js +112 -0
- package/dist/satellites/track.js +25 -0
- package/dist/satellites/types.d.ts +5 -0
- package/dist/space/element-base.d.ts +45 -0
- package/dist/space/element-base.js +120 -12
- package/dist/space/index.d.ts +1 -1
- package/dist/space/index.js +1 -1
- package/dist/space/ride.d.ts +26 -5
- package/dist/space/ride.js +44 -9
- package/dist/space/scene.d.ts +6 -0
- package/dist/space/scene.js +8 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
- **A published accuracy table, and a test that holds it** (MODULES-523). The new guide "How accurate it is" (English and Japanese) gives the measured error of the Sun's overhead point and of the line between day and night against NASA/JPL Horizons (eight moments from 1950 to 2075; worst 0.0074 degree, 0.8 km on the ground), and of the SGP4 places that `createSatellites` gives against Vallado's published verification set ("Revisiting Spacetrack Report #3", AIAA 2006-6753; four element sets, near Earth, strong drag and deep space; worst 0.000000007 km, agreement to every published digit). Each reference value is copied into `test/accuracy/references.ts` with its source and the date it was read. `test/accuracy.test.ts` holds the errors under stated limits (0.010 degree for the Sun and the line, 1 millimetre for SGP4), each the worst measured plus a margin, and each shown to fail when the code or the limit is broken. Not covered, and said so in the guide: NOAA's calculator (a page to operate, no file of values), the paper's printed tables and `tcppver.out` (only in a zip), the sunrise line with refraction, and the Earth-fixed step. No code of the package changed.
|
|
6
|
+
|
|
7
|
+
## 0.57.0 - 2026-11-17
|
|
8
|
+
|
|
9
|
+
- **A ride's tilt range follows its facing; the outside distance and the glide length are options** (MODULES-1471). `rideTiltLimits(distance, look, zoom)` ignored the facing, so a ride that opened facing up (the site's Below step, 25 km under the satellite) could look down only to about 40 degrees above the horizon.
|
|
10
|
+
- **Tilt range.** `rideTiltLimits` takes the facing as a fourth argument (`face`, left out or `null` for none) and gives the range from where the facing rests to straight down (`rest - cap` to `rest + 90` degrees, worked from the same resting elevation `ridePose` uses): facing `up` from straight up to straight down, facing `down` from straight down to 20 degrees above the horizon, the other facings as before. The element passes the ride's facing. Rides with no facing, and the `down` look, are unchanged.
|
|
11
|
+
- **Outside distance.** `outsideKm` in `ride()` options, the attribute `ride-outside-km` and the property `rideOutsideKm` set how far back an outside ride keeps the camera (25 km, `OUTSIDE_KM`, by default; never more than half the satellite's height). `outsidePose` takes it as a fifth argument, and `riding.outsideKm` reports it. Changed while riding it glides in 0.8 s.
|
|
12
|
+
- **Glide length.** `glide` in `ride()` options is a number of milliseconds (1200 by default, as before) or `{ minMs, maxMs }` for a length that follows how far the camera has to move. The new pure `rideGlideMs(km, minMs = 800, maxMs = 4000)` grows with each tenfold of the distance from 10 km to 30,000 km: about 1.2 s for 25 km and 3 s for 3,000 km. Nothing changes for a page that does not pass it.
|
|
13
|
+
- **Tests and docs.** Unit tests of the tilt range for every facing at 25 km and at 420 km (both ends of the range, nothing moving past them, something moving just inside), of `outsidePose`'s distance and of `rideGlideMs`; the ride guide in English and Japanese (the Japanese read by the Japanese reviewer) and `docs/ride-along.md`.
|
|
14
|
+
|
|
15
|
+
## 0.56.0 - 2026-11-17
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
- **Real time is smooth: a frame each time the quickest thing has moved half a pixel** (MODULES-1448). At real time the globe and the satellites were drawn once a second, and zoomed in or riding along that stepped visibly. Now, at real time and up to 60 times it, `<chikyu-space>` and `<chikyu-earth-realistic>` draw each time the quickest thing in the picture has moved half a CSS pixel on the screen.
|
|
19
|
+
- **What is measured.** The Earth's turn at the current zoom; a satellite dot, from the group's own quickest speed (the new `Satellites.fastest`, Earth radii a second, worked out from the two SGP4 places the group already holds, once for each pair, so about once a second and never at a frame) times the Earth's radius on the screen; and, in `<chikyu-space>`, the ridden craft and the camera in a ride. SGP4 still runs about once a second, with the places between interpolated.
|
|
20
|
+
- **Limits.** At least once a second while satellites are on show or a ride along (as before), so a whole Earth at real time stays at one or two a second; at most `smooth-fps` a second, 15 by default (the new attribute and property `smoothFps`, from 1 to 30); half of that on a small device (2 GB of memory or less, or 2 cores or fewer) or a battery at 20% or lower that is not charging; one a second for a reader who prefers reduced motion; nothing at rest, held, out of sight or in a hidden tab, as before. Above real time up to 60 times it the picture is drawn at least as often as before (a frame for each pixel, up to 30 a second), and above 60 times as before. With only the Earth turning, real time still waits up to a minute (`live-seconds` on `<chikyu-earth-realistic>`) but comes sooner when the turn has moved half a pixel, which happens zoomed in.
|
|
21
|
+
- **Seen.** `stats.pace` on both elements: `pixelsPerSecond`, `perSecond`, `cap` and `waitMs` as last worked out. New pure functions in `@johnmorrisdotca/chikyu-earth/realistic`: `framesPerSecond`, `waitFor`, `readSmoothFps`, `smoothCap` and `watchLowBattery`.
|
|
22
|
+
- **Measured** (software drawing, headless Chromium): whole Earth with 2,252 satellites at real time 1.00 frames a second; zoomed in 2.0; riding the ISS 8 to 10 (the software GPU draws a ride slowly; the page asked for 14); reduced motion 1.00 in both; `smooth-fps="4"` while riding 4.00. On a phone's screen with the CPU slowed to a quarter and 18,252 satellites: whole Earth 1.00 frames a second, zoomed in 1.4, riding the ISS 11.2, at 4.2 ms of JavaScript a frame on average while riding (28 ms for the one frame a second that also runs the SGP4 batch, 25 to 29 ms). Tests: `e2e/freeze.demo.ts` (the three cases and reduced motion), `e2e/satellites.gl.ts` (the phone), `test/pace.test.ts`.
|
|
23
|
+
- **Finer tiles: a daily layer's end is respected, and another layer stands in** (MODULES-1446). Suomi NPP VIIRS stops at 2026-11-02 in NASA's capabilities, but any later day was still asked of it, so its finer tiles for those days did not come. A layer that has ended is now asked for no day after its last. When the layer asked for has no picture for a day, the first of NOAA-20 VIIRS, NOAA-21 VIIRS, Suomi NPP VIIRS, MODIS Terra and MODIS Aqua that has it is read instead, and a day still to come shows the newest day there is. The credit line says when the picture is not the one asked for ("Shown: NOAA-20 VIIRS, 2026-11-10 (Suomi NPP VIIRS has no picture for that day)."). The days of every daily layer are one table, read on 2026-11-17 (`GIBS_DAYS_READ`), which `/photos` uses too; how to refresh it is beside it in `src/door/gibs.ts`. `gibsTiles` takes `now` (the present moment, `Date.now` when left out). Unit tests of each case from the table (no request to NASA), and a browser test that a past-end day of Suomi NPP draws NOAA-20's ground, not black.
|
|
24
|
+
|
|
5
25
|
## 0.55.0 - 2026-11-17
|
|
6
26
|
|
|
7
27
|
- **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.
|
package/NOTICE.md
CHANGED
|
@@ -76,7 +76,7 @@ The service's page "Data Use Guidance and Acknowledgements" (https://www.earthda
|
|
|
76
76
|
|
|
77
77
|
The tile matrix was read the same day from `https://gibs.earthdata.nasa.gov/wmts/epsg4326/best/1.0.0/WMTSCapabilities.xml`. Geographic tiles are 512 pixels, the corner of the matrix is longitude -180 and latitude 90, and a pixel is 0.5625/2^level degrees. Levels 0, 1 and 2 run past the Earth (2×1, 3×2 and 5×3 tiles); from level 3 the matrix covers the Earth in 10×5 tiles and doubles from there. A successful tile for the static shaded-relief layer answered `access-control-allow-origin: *` and `cache-control: public, max-age=259200`. A successful tile for a daily true-colour layer on the same day answered `access-control-allow-origin: *` and `cache-control: max-age=0, no-store`. No key is sent.
|
|
78
78
|
|
|
79
|
-
The default layer is `Landsat_WELD_CorrectedReflectance_TrueColor_Global_Annual` (NASA GWELDYR, "NASA Global Web-Enabled Landsat Data Annual Global 30 m V031", LP DAAC, concept id C2763268459-LPCLOUD; 31.25m matrix, JPEG, levels 0 to 11, a picture a year: 1984 to 1985, 1988 to 1990 and 1998 to 2000, the page uses 2000-12-01). Checked against the live service on 2026-11-13, with a few requests each: tiles answer 200 with `content-type: image/jpeg`, `cache-control: public, max-age=2592000`, `access-control-allow-origin: *`, `layer-time-actual: 2000-12-01T00:00:00Z`; the tile addresses are the ones this package's grid names (Vancouver level 9 row 72 column 101, level 10 row 144 column 202, level 11 row 289 column 404; Tokyo 9/96/568; Paris 10/146/648; the Sahara 9/115/337). Coverage as seen: land at 49 N, 35 N, 25 N and in the Amazon; no data (a 200 with an all-black, 4,723-byte picture, the same as a daily layer's) over the Pacific, Antarctica, Greenland at 72 N, Svalbard at 78 N and at the pole. The picture is cloud-free and sharp (streets and fields at level 9) but of the year 2000, and straight scene edges show in places (for example west of Tokyo). The page treats a wholly black tile as no picture, clears black and nearly black pixels (luminance up to 20 clear, from 32 opaque: the sea in the mosaic is about (7, 25, 12) and a dark wooded slope (8, 39, 6) to (22, 54, 7)), and multiplies the colours by 0.76, 0.66 and 0.55: the median, over six land places (Paris, the Sahara, the Amazon, Kansas, Siberia, Australia), of the package's own level 5 over this layer's mean colour in the same 2.25 degree square (0.75 0.77 0.77 0.70 0.81 0.68 red, 0.65 0.71 0.70 0.61 0.61 0.56 green, 0.53 0.64 0.59 0.51 0.54 0.53 blue). Layer-specific credit: NASA's acknowledgement is the one the data-use page asks for; the layer's metadata names the product and its data centre only, so the credit line names the Global Web-Enabled Landsat Data and LP DAAC as well. Other layers checked and not used as the default: `ASTER_GDEM_Color_Shaded_Relief` (31.25m, colour-coded height, not true colour); `MODIS_Terra_L3_SurfaceReflectance_Bands143_8Day` (500 m, an 8-day true-colour composite, speckled with cloud); `HLS_S30_Nadir_BRDF_Adjusted_Reflectance` and the L30 twin (31.25m daily scenes, 600 KB PNG tiles, solid cloud over Paris on 2026-11-05); `BlueMarble_NextGeneration` (500 m, the package's own source); no Blue Marble at 250 m exists on the service. `MODIS_Terra_CorrectedReflectance_TrueColor` (250 m, JPEG, days 2000-02-24 to 2026-11-13 with gaps; the name `today`): the page looks for the most recent day that answers with a picture, from the day before the moment on show back at most 10 days, one tile a day (2026-11-13 answered 200 with an all-black picture, 2026-11-12 and 2026-11-11 with pictures; the daily tiles answer `cache-control: max-age=0, no-store, no-cache, must-revalidate` and `access-control-allow-origin: *`, and carry `layer-time-actual`). `
|
|
79
|
+
The default layer is `Landsat_WELD_CorrectedReflectance_TrueColor_Global_Annual` (NASA GWELDYR, "NASA Global Web-Enabled Landsat Data Annual Global 30 m V031", LP DAAC, concept id C2763268459-LPCLOUD; 31.25m matrix, JPEG, levels 0 to 11, a picture a year: 1984 to 1985, 1988 to 1990 and 1998 to 2000, the page uses 2000-12-01). Checked against the live service on 2026-11-13, with a few requests each: tiles answer 200 with `content-type: image/jpeg`, `cache-control: public, max-age=2592000`, `access-control-allow-origin: *`, `layer-time-actual: 2000-12-01T00:00:00Z`; the tile addresses are the ones this package's grid names (Vancouver level 9 row 72 column 101, level 10 row 144 column 202, level 11 row 289 column 404; Tokyo 9/96/568; Paris 10/146/648; the Sahara 9/115/337). Coverage as seen: land at 49 N, 35 N, 25 N and in the Amazon; no data (a 200 with an all-black, 4,723-byte picture, the same as a daily layer's) over the Pacific, Antarctica, Greenland at 72 N, Svalbard at 78 N and at the pole. The picture is cloud-free and sharp (streets and fields at level 9) but of the year 2000, and straight scene edges show in places (for example west of Tokyo). The page treats a wholly black tile as no picture, clears black and nearly black pixels (luminance up to 20 clear, from 32 opaque: the sea in the mosaic is about (7, 25, 12) and a dark wooded slope (8, 39, 6) to (22, 54, 7)), and multiplies the colours by 0.76, 0.66 and 0.55: the median, over six land places (Paris, the Sahara, the Amazon, Kansas, Siberia, Australia), of the package's own level 5 over this layer's mean colour in the same 2.25 degree square (0.75 0.77 0.77 0.70 0.81 0.68 red, 0.65 0.71 0.70 0.61 0.61 0.56 green, 0.53 0.64 0.59 0.51 0.54 0.53 blue). Layer-specific credit: NASA's acknowledgement is the one the data-use page asks for; the layer's metadata names the product and its data centre only, so the credit line names the Global Web-Enabled Landsat Data and LP DAAC as well. Other layers checked and not used as the default: `ASTER_GDEM_Color_Shaded_Relief` (31.25m, colour-coded height, not true colour); `MODIS_Terra_L3_SurfaceReflectance_Bands143_8Day` (500 m, an 8-day true-colour composite, speckled with cloud); `HLS_S30_Nadir_BRDF_Adjusted_Reflectance` and the L30 twin (31.25m daily scenes, 600 KB PNG tiles, solid cloud over Paris on 2026-11-05); `BlueMarble_NextGeneration` (500 m, the package's own source); no Blue Marble at 250 m exists on the service. `MODIS_Terra_CorrectedReflectance_TrueColor` (250 m, JPEG, days 2000-02-24 to 2026-11-13 with gaps; the name `today`): the page looks for the most recent day that answers with a picture, from the day before the moment on show back at most 10 days, one tile a day (2026-11-13 answered 200 with an all-black picture, 2026-11-12 and 2026-11-11 with pictures; the daily tiles answer `cache-control: max-age=0, no-store, no-cache, must-revalidate` and `access-control-allow-origin: *`, and carry `layer-time-actual`). `BlueMarble_ShadedRelief_Bathymetry` (500 m) has no day. The days of the daily true-colour layers were read again on 2026-11-17 from the same WMTS capabilities file (the WMS capabilities list the same days), and are one table in `src/door/gibs.ts` (`GIBS_LAYERS`, `GIBS_DAYS_READ`; how to refresh it is beside it): `VIIRS_NOAA20_CorrectedReflectance_TrueColor` 2018-01-05 to 2026-11-16, `VIIRS_NOAA21_CorrectedReflectance_TrueColor` 2023-02-10 to 2026-11-16, `VIIRS_SNPP_CorrectedReflectance_TrueColor` 2015-11-24 to 2026-11-02 (its last day, two weeks behind the others: taken as ended), `MODIS_Terra_CorrectedReflectance_TrueColor` 2000-02-24 to 2026-11-17 and `MODIS_Aqua_CorrectedReflectance_TrueColor` 2002-07-03 to 2026-11-16, each with gaps. A tile of Suomi NPP for 2026-11-10 answered 404 that day, and the same tile of NOAA-20 a 77 KB picture. A layer's day before its first day, in a gap of its list, or after the last day of a layer that has ended, is not requested from it: the first of NOAA-20, NOAA-21, Suomi NPP, MODIS Terra and MODIS Aqua that has the day is read instead, and the credit line says so. A day after the last listed day of a layer still running is requested, up to today, because such a layer goes on growing. The daily layers are true colour with the clouds left in, and a day's picture has black gaps between passes, which the page clears.
|
|
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
|
|
package/README.md
CHANGED
|
@@ -589,6 +589,7 @@ Each guide has a Japanese twin in [docs/guides/ja](docs/guides/ja/getting-starte
|
|
|
589
589
|
| [Printable sheets](docs/guides/printable-sheets.md) | The globe, a world map, my country, day and night and the seasons to print and colour |
|
|
590
590
|
| [Why two packages](docs/guides/two-packages.md) | This package and wakusei-planets: which to install, alone and together |
|
|
591
591
|
| [How it stays light](docs/guides/how-it-works.md) | The budget |
|
|
592
|
+
| [How accurate it is](docs/guides/accuracy.md) | The Sun's overhead point, the day and night line and SGP4, each measured against a published reference, with its source and limit |
|
|
592
593
|
| [Architecture](docs/guides/architecture.md) | How the layers fit |
|
|
593
594
|
| [Troubleshooting](docs/guides/troubleshooting.md) | Something does not appear |
|
|
594
595
|
| [Upgrading](docs/guides/upgrading.md) | What to act on between versions |
|
|
@@ -614,7 +615,7 @@ console.log(countryList().filter((country) => country.alpha2 === null).map((coun
|
|
|
614
615
|
|
|
615
616
|
## How to cite
|
|
616
617
|
|
|
617
|
-
> Morris, J. (2026). *Chikyu Earth* (version 0.
|
|
618
|
+
> Morris, J. (2026). *Chikyu Earth* (version 0.57.0) [Computer software]. https://github.com/johnmorrisdotca/chikyu-earth
|
|
618
619
|
|
|
619
620
|
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
621
|
|
package/dist/door/gibs.d.ts
CHANGED
|
@@ -37,16 +37,31 @@ export declare const GIBS_CREDIT: {
|
|
|
37
37
|
readonly en: "We acknowledge the use of imagery provided by services from NASA's Global Imagery Browse Services (GIBS), part of NASA's Earth Science Data and Information System (ESDIS).";
|
|
38
38
|
readonly ja: "NASAの地球科学データ情報システム(ESDIS)の一部である Global Imagery Browse Services(GIBS)が提供する画像を使用していることを記します。";
|
|
39
39
|
};
|
|
40
|
-
/**
|
|
40
|
+
/**
|
|
41
|
+
* The day the daily layers' days in `GIBS_LAYERS` were read, from the capabilities documents (the tiles' WMTS and the snapshots' WMS list the same days).
|
|
42
|
+
*
|
|
43
|
+
* To refresh the table: fetch `https://gibs.earthdata.nasa.gov/wmts/epsg4326/best/1.0.0/WMTSCapabilities.xml`, and for each daily layer copy the `<Value>` ranges of its `Time` dimension
|
|
44
|
+
* (`start/end/P1D`) into `ranges`, oldest first. Mark a layer `ended` when its last day stays behind the others' (the satellite has stopped, or its processing has), and take the mark off if it starts again. Then change this date.
|
|
45
|
+
*/
|
|
46
|
+
export declare const GIBS_DAYS_READ = "2026-11-17";
|
|
47
|
+
/** A day the layer has imagery, inclusive, as the capabilities document listed it on `GIBS_DAYS_READ`. Dates sort as text. */
|
|
41
48
|
interface DayRange {
|
|
42
49
|
start: string;
|
|
43
50
|
end: string;
|
|
44
51
|
}
|
|
52
|
+
/** One layer of NASA's service, as the package uses it. */
|
|
45
53
|
interface GibsLayer {
|
|
46
54
|
id: string;
|
|
47
55
|
matrix: "31.25m" | "250m" | "500m";
|
|
48
|
-
/** Empty for a picture that has no day (the shaded relief, and the annual Landsat mosaics, which have `years`). */
|
|
56
|
+
/** The days it has, oldest first. Empty for a picture that has no day (the shaded relief, and the annual Landsat mosaics, which have `years`). */
|
|
49
57
|
ranges: readonly DayRange[];
|
|
58
|
+
/**
|
|
59
|
+
* True when the layer has stopped: no day after its last listed one is asked for. A layer still running is taken to go on to the present day after its last listed one, because the list is of the day it was read and
|
|
60
|
+
* the satellite goes on sending.
|
|
61
|
+
*/
|
|
62
|
+
ended?: boolean;
|
|
63
|
+
/** The satellite and instrument, for the credit line when this layer stands in for another (see `gibsPick`). */
|
|
64
|
+
name?: string;
|
|
50
65
|
/** True when the picture is one day of the satellite and clouds are left in. */
|
|
51
66
|
clouds: boolean;
|
|
52
67
|
/** For a layer with one picture a year: the years' times, as the service names them (`yyyy-mm-dd`), oldest first. The newest is the one used unless a page names another of them. */
|
|
@@ -64,10 +79,15 @@ interface GibsLayer {
|
|
|
64
79
|
};
|
|
65
80
|
}
|
|
66
81
|
/**
|
|
67
|
-
* The layers a page may ask for
|
|
68
|
-
* The
|
|
82
|
+
* The layers a page may ask for, and the one table of the days each daily layer has (read on `GIBS_DAYS_READ`; how to refresh it is there). A day outside a layer's days is not requested from it.
|
|
83
|
+
* The daily layers are true colour with the clouds left in. Suomi NPP VIIRS has ended: its last day is 2026-11-02, and a later day is a black picture. The shaded relief is the same kind of picture as the package's own level 5, and is only a stand-in.
|
|
69
84
|
*/
|
|
70
85
|
export declare const GIBS_LAYERS: Readonly<Record<string, GibsLayer>>;
|
|
86
|
+
/**
|
|
87
|
+
* The daily true-colour layers in the order one stands in for another: when the layer a page asked for has no picture for a day (it has ended, it had not started, or the day is in a gap of its list), the first of these that has the day is used.
|
|
88
|
+
* NOAA-20 VIIRS, NOAA-21 VIIRS, Suomi NPP VIIRS (VIIRS is finer and newer than MODIS), then MODIS Terra and MODIS Aqua.
|
|
89
|
+
*/
|
|
90
|
+
export declare const GIBS_DAILY_ORDER: readonly string[];
|
|
71
91
|
/**
|
|
72
92
|
* The layer a page gets without naming one: the Landsat annual true-colour mosaic (30 m, no cloud, land only; the year 2000, the newest it has). The daily layers are a named choice: `today` for MODIS Terra.
|
|
73
93
|
* A layer id is taken as it is, and these short names stand for two of them.
|
|
@@ -120,9 +140,36 @@ export declare function utcDay(ms: number): string;
|
|
|
120
140
|
*/
|
|
121
141
|
export declare function previousUtcDay(ms: number): string;
|
|
122
142
|
/**
|
|
123
|
-
* Whether the layer may have imagery for a day: inside one of
|
|
143
|
+
* Whether the layer may have imagery for a day: inside one of its listed ranges, or, for a layer still running (not `ended`), after the last of them and no later than `today` (the list is of the day it was read, and the layer goes on growing).
|
|
144
|
+
* A day before the layer's first day, in a gap the list shows, after the last day of a layer that has ended, or after `today`, has none, and is not asked for.
|
|
145
|
+
*
|
|
146
|
+
* @param today - The present UTC day, `yyyy-mm-dd`. Left out, a running layer has every day after its last listed one.
|
|
147
|
+
*/
|
|
148
|
+
export declare function gibsHasDay(layer: GibsLayer, day: string, today?: string): boolean;
|
|
149
|
+
/** Why `gibsPick` chose what it did: the layer asked for has the day, another layer stands in for it, or no layer has the day and the newest day there is is shown instead. */
|
|
150
|
+
type GibsPickWhy = "asked" | "layer" | "newest";
|
|
151
|
+
/** The layer and the day the tiles are read from, for a layer asked for and a day wanted. */
|
|
152
|
+
interface GibsPick {
|
|
153
|
+
layer: GibsLayer;
|
|
154
|
+
day: string;
|
|
155
|
+
/** The day that was wanted. */
|
|
156
|
+
wanted: string;
|
|
157
|
+
why: GibsPickWhy;
|
|
158
|
+
}
|
|
159
|
+
/** The newest day each daily layer surely has by `today`: the day before it for a layer still running (that day's passes are in), the last listed one for a layer that has ended. The newest of them, from the first layer in `GIBS_DAILY_ORDER` that has it. */
|
|
160
|
+
export declare function gibsNewest(today: string): {
|
|
161
|
+
layer: GibsLayer;
|
|
162
|
+
day: string;
|
|
163
|
+
} | undefined;
|
|
164
|
+
/**
|
|
165
|
+
* The layer and day to read for a day wanted. The layer asked for when it has the day. Else, for a daily true-colour layer, the first of `GIBS_DAILY_ORDER` that has it (Suomi NPP has ended on 2026-11-02, so a later day is NOAA-20's).
|
|
166
|
+
* Else, when the day is after the newest day any of them has (a day still to come), that newest day, from the layer asked for if it has it. A day no layer has that is not after all of them (before 2000-02-24, when MODIS Terra began) gives `undefined`: nothing is requested.
|
|
167
|
+
*
|
|
168
|
+
* @param today - The present UTC day, `yyyy-mm-dd`: no layer has a day after it.
|
|
124
169
|
*/
|
|
125
|
-
export declare function
|
|
170
|
+
export declare function gibsPick(asked: GibsLayer, day: string, today: string): GibsPick | undefined;
|
|
171
|
+
/** The days the default rule tries, newest first, each with the layer it is read from: from `start` (or, when `start` is after every layer, from the newest day there is), back, `GIBS_LOOKBACK_DAYS` days, skipping a day no layer has. */
|
|
172
|
+
export declare function gibsPickCandidates(asked: GibsLayer, start: string, today: string): GibsPick[];
|
|
126
173
|
/** A day the layer can serve for a fixed rule (`latest`, the default, starts at the day before `ms`), or `undefined` when it lands where the layer has no imagery (nothing is requested). */
|
|
127
174
|
export declare function gibsDay(layer: GibsLayer, rule: string, ms: number): string | undefined;
|
|
128
175
|
/** The days the default rule looks at, newest first: from `start`, back, skipping days the layer is known to lack, until the layer's first day or `GIBS_LOOKBACK_DAYS` days have been counted. */
|
|
@@ -153,6 +200,8 @@ export interface GibsTilesOptions extends EarthTilesOptions {
|
|
|
153
200
|
changed?: () => void;
|
|
154
201
|
/** How many milliseconds a tile is given to arrive (`GIBS_SLOW_MS`, 2000, when left out). A page on a slow link can give it longer. */
|
|
155
202
|
slowMs?: number;
|
|
203
|
+
/** The present moment, which no layer has a picture after (`Date.now` when left out; not the moment on show, which may be one still to come). */
|
|
204
|
+
now?: () => number;
|
|
156
205
|
}
|
|
157
206
|
/**
|
|
158
207
|
* Where a tile's luminance (0 to 255) is at or below this, the picture has no data there (the service paints it black) and the loader draws it clear; from `NODATA_FULL` it is opaque, and between the two a share, so the edge of a gap is not a hard
|
package/dist/door/gibs.js
CHANGED
|
@@ -49,8 +49,24 @@ const INFO = {
|
|
|
49
49
|
retrieved: GIBS_READ,
|
|
50
50
|
};
|
|
51
51
|
/**
|
|
52
|
-
* The
|
|
53
|
-
*
|
|
52
|
+
* The day the daily layers' days in `GIBS_LAYERS` were read, from the capabilities documents (the tiles' WMTS and the snapshots' WMS list the same days).
|
|
53
|
+
*
|
|
54
|
+
* To refresh the table: fetch `https://gibs.earthdata.nasa.gov/wmts/epsg4326/best/1.0.0/WMTSCapabilities.xml`, and for each daily layer copy the `<Value>` ranges of its `Time` dimension
|
|
55
|
+
* (`start/end/P1D`) into `ranges`, oldest first. Mark a layer `ended` when its last day stays behind the others' (the satellite has stopped, or its processing has), and take the mark off if it starts again. Then change this date.
|
|
56
|
+
*/
|
|
57
|
+
export const GIBS_DAYS_READ = "2026-11-17";
|
|
58
|
+
/** A daily true-colour layer on the 250 m matrix, with the clouds left in. */
|
|
59
|
+
const daily = (id, name, ranges, ended = false) => ({
|
|
60
|
+
id,
|
|
61
|
+
name,
|
|
62
|
+
matrix: "250m",
|
|
63
|
+
clouds: true,
|
|
64
|
+
ranges: ranges.map(([start, end]) => ({ start, end })),
|
|
65
|
+
...(ended ? { ended: true } : {}),
|
|
66
|
+
});
|
|
67
|
+
/**
|
|
68
|
+
* The layers a page may ask for, and the one table of the days each daily layer has (read on `GIBS_DAYS_READ`; how to refresh it is there). A day outside a layer's days is not requested from it.
|
|
69
|
+
* The daily layers are true colour with the clouds left in. Suomi NPP VIIRS has ended: its last day is 2026-11-02, and a later day is a black picture. The shaded relief is the same kind of picture as the package's own level 5, and is only a stand-in.
|
|
54
70
|
*/
|
|
55
71
|
export const GIBS_LAYERS = {
|
|
56
72
|
Landsat_WELD_CorrectedReflectance_TrueColor_Global_Annual: {
|
|
@@ -69,39 +85,59 @@ export const GIBS_LAYERS = {
|
|
|
69
85
|
ja: "Landsat画像:NASAのGlobal Web-Enabled Landsat Data(GWELD)の年間30 mモザイク。NASAのLP DAACが配布しています。",
|
|
70
86
|
},
|
|
71
87
|
},
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
],
|
|
102
|
-
|
|
88
|
+
VIIRS_NOAA20_CorrectedReflectance_TrueColor: daily("VIIRS_NOAA20_CorrectedReflectance_TrueColor", "NOAA-20 VIIRS", [
|
|
89
|
+
["2018-01-05", "2018-02-21"],
|
|
90
|
+
["2018-02-24", "2018-03-12"],
|
|
91
|
+
["2018-03-14", "2019-12-31"],
|
|
92
|
+
["2020-01-02", "2022-01-12"],
|
|
93
|
+
["2022-01-14", "2026-11-16"],
|
|
94
|
+
]),
|
|
95
|
+
VIIRS_NOAA21_CorrectedReflectance_TrueColor: daily("VIIRS_NOAA21_CorrectedReflectance_TrueColor", "NOAA-21 VIIRS", [
|
|
96
|
+
["2023-02-10", "2023-02-23"],
|
|
97
|
+
["2023-02-25", "2023-03-09"],
|
|
98
|
+
["2023-03-11", "2024-02-26"],
|
|
99
|
+
["2024-02-29", "2026-11-16"],
|
|
100
|
+
]),
|
|
101
|
+
VIIRS_SNPP_CorrectedReflectance_TrueColor: daily("VIIRS_SNPP_CorrectedReflectance_TrueColor", "Suomi NPP VIIRS", [
|
|
102
|
+
["2015-11-24", "2022-07-27"],
|
|
103
|
+
["2022-08-10", "2024-05-31"],
|
|
104
|
+
["2024-06-04", "2024-07-11"],
|
|
105
|
+
["2024-07-16", "2024-07-24"],
|
|
106
|
+
["2024-07-29", "2024-11-03"],
|
|
107
|
+
["2024-11-06", "2026-04-28"],
|
|
108
|
+
["2026-04-30", "2026-07-10"],
|
|
109
|
+
["2026-07-16", "2026-11-02"],
|
|
110
|
+
], true),
|
|
111
|
+
MODIS_Terra_CorrectedReflectance_TrueColor: daily("MODIS_Terra_CorrectedReflectance_TrueColor", "MODIS Terra", [
|
|
112
|
+
["2000-02-24", "2000-04-25"],
|
|
113
|
+
["2000-04-28", "2000-08-06"],
|
|
114
|
+
["2000-08-18", "2001-06-15"],
|
|
115
|
+
["2001-07-03", "2002-03-19"],
|
|
116
|
+
["2002-03-28", "2003-12-16"],
|
|
117
|
+
["2003-12-24", "2008-12-20"],
|
|
118
|
+
["2008-12-23", "2016-02-18"],
|
|
119
|
+
["2016-02-27", "2022-10-10"],
|
|
120
|
+
["2022-10-23", "2026-11-17"],
|
|
121
|
+
]),
|
|
122
|
+
MODIS_Aqua_CorrectedReflectance_TrueColor: daily("MODIS_Aqua_CorrectedReflectance_TrueColor", "MODIS Aqua", [
|
|
123
|
+
["2002-07-03", "2002-07-30"],
|
|
124
|
+
["2002-08-07", "2002-09-12"],
|
|
125
|
+
["2002-09-14", "2022-03-31"],
|
|
126
|
+
["2022-04-17", "2026-11-16"],
|
|
127
|
+
]),
|
|
103
128
|
BlueMarble_ShadedRelief_Bathymetry: { id: "BlueMarble_ShadedRelief_Bathymetry", matrix: "500m", clouds: false, ranges: [] },
|
|
104
129
|
};
|
|
130
|
+
/**
|
|
131
|
+
* The daily true-colour layers in the order one stands in for another: when the layer a page asked for has no picture for a day (it has ended, it had not started, or the day is in a gap of its list), the first of these that has the day is used.
|
|
132
|
+
* NOAA-20 VIIRS, NOAA-21 VIIRS, Suomi NPP VIIRS (VIIRS is finer and newer than MODIS), then MODIS Terra and MODIS Aqua.
|
|
133
|
+
*/
|
|
134
|
+
export const GIBS_DAILY_ORDER = [
|
|
135
|
+
"VIIRS_NOAA20_CorrectedReflectance_TrueColor",
|
|
136
|
+
"VIIRS_NOAA21_CorrectedReflectance_TrueColor",
|
|
137
|
+
"VIIRS_SNPP_CorrectedReflectance_TrueColor",
|
|
138
|
+
"MODIS_Terra_CorrectedReflectance_TrueColor",
|
|
139
|
+
"MODIS_Aqua_CorrectedReflectance_TrueColor",
|
|
140
|
+
];
|
|
105
141
|
/**
|
|
106
142
|
* The layer a page gets without naming one: the Landsat annual true-colour mosaic (30 m, no cloud, land only; the year 2000, the newest it has). The daily layers are a named choice: `today` for MODIS Terra.
|
|
107
143
|
* A layer id is taken as it is, and these short names stand for two of them.
|
|
@@ -171,9 +207,12 @@ export function previousUtcDay(ms) {
|
|
|
171
207
|
return day.toISOString().slice(0, 10);
|
|
172
208
|
}
|
|
173
209
|
/**
|
|
174
|
-
* Whether the layer may have imagery for a day: inside one of
|
|
210
|
+
* Whether the layer may have imagery for a day: inside one of its listed ranges, or, for a layer still running (not `ended`), after the last of them and no later than `today` (the list is of the day it was read, and the layer goes on growing).
|
|
211
|
+
* A day before the layer's first day, in a gap the list shows, after the last day of a layer that has ended, or after `today`, has none, and is not asked for.
|
|
212
|
+
*
|
|
213
|
+
* @param today - The present UTC day, `yyyy-mm-dd`. Left out, a running layer has every day after its last listed one.
|
|
175
214
|
*/
|
|
176
|
-
export function gibsHasDay(layer, day) {
|
|
215
|
+
export function gibsHasDay(layer, day, today) {
|
|
177
216
|
if (layer.ranges.length === 0)
|
|
178
217
|
return true;
|
|
179
218
|
const first = layer.ranges[0];
|
|
@@ -181,9 +220,62 @@ export function gibsHasDay(layer, day) {
|
|
|
181
220
|
if (day < first.start)
|
|
182
221
|
return false;
|
|
183
222
|
if (day > last.end)
|
|
184
|
-
return
|
|
223
|
+
return !layer.ended && (today === undefined || day <= today);
|
|
185
224
|
return layer.ranges.some((range) => day >= range.start && day <= range.end);
|
|
186
225
|
}
|
|
226
|
+
/** The day before `day`. */
|
|
227
|
+
const dayBefore = (day) => previousUtcDay(Date.parse(`${day}T12:00:00Z`));
|
|
228
|
+
const isDaily = (layer) => GIBS_DAILY_ORDER.includes(layer.id);
|
|
229
|
+
/** The newest day each daily layer surely has by `today`: the day before it for a layer still running (that day's passes are in), the last listed one for a layer that has ended. The newest of them, from the first layer in `GIBS_DAILY_ORDER` that has it. */
|
|
230
|
+
export function gibsNewest(today) {
|
|
231
|
+
let best;
|
|
232
|
+
const yesterday = dayBefore(today);
|
|
233
|
+
for (const id of GIBS_DAILY_ORDER) {
|
|
234
|
+
const layer = GIBS_LAYERS[id];
|
|
235
|
+
const day = layer.ended ? layer.ranges[layer.ranges.length - 1].end : yesterday;
|
|
236
|
+
if (!gibsHasDay(layer, day, today))
|
|
237
|
+
continue;
|
|
238
|
+
if (best === undefined || day > best.day)
|
|
239
|
+
best = { layer, day };
|
|
240
|
+
}
|
|
241
|
+
return best;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* The layer and day to read for a day wanted. The layer asked for when it has the day. Else, for a daily true-colour layer, the first of `GIBS_DAILY_ORDER` that has it (Suomi NPP has ended on 2026-11-02, so a later day is NOAA-20's).
|
|
245
|
+
* Else, when the day is after the newest day any of them has (a day still to come), that newest day, from the layer asked for if it has it. A day no layer has that is not after all of them (before 2000-02-24, when MODIS Terra began) gives `undefined`: nothing is requested.
|
|
246
|
+
*
|
|
247
|
+
* @param today - The present UTC day, `yyyy-mm-dd`: no layer has a day after it.
|
|
248
|
+
*/
|
|
249
|
+
export function gibsPick(asked, day, today) {
|
|
250
|
+
if (gibsHasDay(asked, day, today))
|
|
251
|
+
return { layer: asked, day, wanted: day, why: "asked" };
|
|
252
|
+
if (!isDaily(asked))
|
|
253
|
+
return undefined;
|
|
254
|
+
for (const id of GIBS_DAILY_ORDER) {
|
|
255
|
+
const other = GIBS_LAYERS[id];
|
|
256
|
+
if (other !== asked && gibsHasDay(other, day, today))
|
|
257
|
+
return { layer: other, day, wanted: day, why: "layer" };
|
|
258
|
+
}
|
|
259
|
+
const newest = gibsNewest(today);
|
|
260
|
+
if (!newest || day <= newest.day)
|
|
261
|
+
return undefined;
|
|
262
|
+
// the layer asked for, when it has that newest day too
|
|
263
|
+
return { layer: gibsHasDay(asked, newest.day, today) ? asked : newest.layer, day: newest.day, wanted: day, why: "newest" };
|
|
264
|
+
}
|
|
265
|
+
/** The days the default rule tries, newest first, each with the layer it is read from: from `start` (or, when `start` is after every layer, from the newest day there is), back, `GIBS_LOOKBACK_DAYS` days, skipping a day no layer has. */
|
|
266
|
+
export function gibsPickCandidates(asked, start, today) {
|
|
267
|
+
const first = gibsPick(asked, start, today);
|
|
268
|
+
const from = first?.why === "newest" ? first.day : start;
|
|
269
|
+
const found = [];
|
|
270
|
+
let day = from;
|
|
271
|
+
for (let count = 0; count < GIBS_LOOKBACK_DAYS; count += 1) {
|
|
272
|
+
const pick = gibsPick(asked, day, today);
|
|
273
|
+
if (pick && pick.why !== "newest")
|
|
274
|
+
found.push(first?.why === "newest" ? { ...pick, wanted: start, why: "newest" } : pick);
|
|
275
|
+
day = dayBefore(day);
|
|
276
|
+
}
|
|
277
|
+
return found;
|
|
278
|
+
}
|
|
187
279
|
/** The day a fixed rule names (`previous-day`, `shown`, or one `yyyy-mm-dd`), or `undefined` for `latest`, which has to be looked for. */
|
|
188
280
|
function fixedDay(rule, ms) {
|
|
189
281
|
if (/^\d{4}-\d{2}-\d{2}$/.test(rule))
|
|
@@ -206,8 +298,6 @@ export function gibsDay(layer, rule, ms) {
|
|
|
206
298
|
const named = fixedDay(rule, ms) ?? previousUtcDay(ms);
|
|
207
299
|
return gibsHasDay(layer, named) ? named : undefined;
|
|
208
300
|
}
|
|
209
|
-
/** The day before `day`. */
|
|
210
|
-
const dayBefore = (day) => previousUtcDay(Date.parse(`${day}T12:00:00Z`));
|
|
211
301
|
/** The days the default rule looks at, newest first: from `start`, back, skipping days the layer is known to lack, until the layer's first day or `GIBS_LOOKBACK_DAYS` days have been counted. */
|
|
212
302
|
export function gibsCandidates(layer, start) {
|
|
213
303
|
const found = [];
|
|
@@ -221,7 +311,7 @@ export function gibsCandidates(layer, start) {
|
|
|
221
311
|
}
|
|
222
312
|
return found;
|
|
223
313
|
}
|
|
224
|
-
/** The days the default rule has settled, by layer and starting day:
|
|
314
|
+
/** The days the default rule has settled, by layer and starting day: the day with imagery and the layer it is read from, or `null` for none. Kept for the session, so a view that moves asks nothing again. */
|
|
225
315
|
const settled = new Map();
|
|
226
316
|
const probing = new Set();
|
|
227
317
|
/** Forget what the default rule has settled (for a page that wants to look again, and for the tests). */
|
|
@@ -253,6 +343,17 @@ async function pictureIsBlank(image) {
|
|
|
253
343
|
return false;
|
|
254
344
|
}
|
|
255
345
|
}
|
|
346
|
+
/** The sentence the credit line adds when the picture is not the one asked for: another layer stands in for a day, or the newest day there is stands in for one still to come. */
|
|
347
|
+
function pickNote(asked, pick) {
|
|
348
|
+
const name = pick.layer.name ?? pick.layer.id;
|
|
349
|
+
if (pick.why === "layer") {
|
|
350
|
+
const was = asked.name ?? asked.id;
|
|
351
|
+
return { en: `Shown: ${name}, ${pick.day} (${was} has no picture for that day).`, ja: `表示中:${name}、${pick.day}(${was}にはこの日の画像がありません)。` };
|
|
352
|
+
}
|
|
353
|
+
if (pick.why === "newest")
|
|
354
|
+
return { en: `Shown: ${name}, ${pick.day}, the newest day with a picture (there is none yet for ${pick.wanted}).`, ja: `表示中:${name}、${pick.day}。画像のある最新の日です(${pick.wanted}の画像はまだありません)。` };
|
|
355
|
+
return undefined;
|
|
356
|
+
}
|
|
256
357
|
/**
|
|
257
358
|
* A map source that reads NASA's imagery service directly. It declares its own grid (512 pixel tiles, the Geographic matrix, which is not the package's pyramid). `need` names no tile for a day outside the layer's range.
|
|
258
359
|
* `load` gives a tile two seconds, and treats a 404 or an all-black tile as no imagery. The clouds are not taken out of the daily layers.
|
|
@@ -276,6 +377,11 @@ export function gibsTiles(options) {
|
|
|
276
377
|
const rule = options.date ?? "latest";
|
|
277
378
|
const get = options.fetch ?? ((url, init) => globalThis.fetch(url, init));
|
|
278
379
|
const decode = options.decode ?? ((blob) => createImageBitmap(blob, { premultiplyAlpha: "none", colorSpaceConversion: "none" }));
|
|
380
|
+
const today = () => utcDay(options.now ? options.now() : Date.now());
|
|
381
|
+
/** The layer a key's day is read from: the one asked for, or the daily layer that stands in for it on that day (`gibsPick`). */
|
|
382
|
+
const layerOf = (day) => (known && isDaily(layer) ? (gibsPick(layer, day, today())?.layer ?? layer) : layer);
|
|
383
|
+
/** The pick the tiles in view were last named from, for the credit line. */
|
|
384
|
+
let shown;
|
|
279
385
|
/** One tile of one day, as `load` reads it: nothing for a 404, a blank picture, a slow answer or a failure. */
|
|
280
386
|
const fetchTile = async (key, signal) => {
|
|
281
387
|
const parts = tileKeyParts(key);
|
|
@@ -285,7 +391,8 @@ export function gibsTiles(options) {
|
|
|
285
391
|
throw new RangeError(`"${key}" is not the key of a tile`);
|
|
286
392
|
if (!gridOnEarth(level, parts.col, parts.row, grid.extent))
|
|
287
393
|
throw new RangeError(`"${key}" is off the Earth`);
|
|
288
|
-
const
|
|
394
|
+
const from = layerOf(day);
|
|
395
|
+
const url = `${TILE_URL}/${from.id}/default/${day}/${from.matrix}/${parts.level}/${parts.row}/${parts.col}.jpg`;
|
|
289
396
|
const timer = AbortSignal.timeout(options.slowMs && options.slowMs > 0 ? options.slowMs : GIBS_SLOW_MS);
|
|
290
397
|
let response;
|
|
291
398
|
try {
|
|
@@ -308,14 +415,14 @@ export function gibsTiles(options) {
|
|
|
308
415
|
probing.add(settledKey);
|
|
309
416
|
void (async () => {
|
|
310
417
|
let found = null;
|
|
311
|
-
for (const
|
|
312
|
-
const keys = gridKeys(grid, place, detail, `${day}/`);
|
|
418
|
+
for (const pick of gibsPickCandidates(layer, start, today())) {
|
|
419
|
+
const keys = gridKeys(grid, place, detail, `${pick.day}/`);
|
|
313
420
|
if (keys.length === 0)
|
|
314
421
|
break;
|
|
315
422
|
try {
|
|
316
423
|
const tile = await fetchTile(keys[0], new AbortController().signal);
|
|
317
424
|
tile.image.close?.();
|
|
318
|
-
found =
|
|
425
|
+
found = pick;
|
|
319
426
|
break;
|
|
320
427
|
}
|
|
321
428
|
catch {
|
|
@@ -329,24 +436,42 @@ export function gibsTiles(options) {
|
|
|
329
436
|
})();
|
|
330
437
|
};
|
|
331
438
|
// an unknown layer has no published range, so no day is inside it and nothing is requested
|
|
332
|
-
const
|
|
439
|
+
const pickOf = (place, detail) => {
|
|
333
440
|
if (!known)
|
|
334
441
|
return undefined;
|
|
335
442
|
const ms = options.time().getTime();
|
|
336
|
-
if (layer.years ||
|
|
337
|
-
|
|
443
|
+
if (layer.years || layer.ranges.length === 0) {
|
|
444
|
+
const day = gibsDay(layer, rule, ms);
|
|
445
|
+
return day === undefined ? undefined : { layer, day, wanted: day, why: "asked" };
|
|
446
|
+
}
|
|
447
|
+
const fixed = fixedDay(rule, ms);
|
|
448
|
+
const now = today();
|
|
449
|
+
if (fixed !== undefined)
|
|
450
|
+
return gibsPick(layer, fixed, now);
|
|
338
451
|
const start = previousUtcDay(ms);
|
|
339
|
-
const settledKey = `${layer.id}|${start}`;
|
|
452
|
+
const settledKey = `${layer.id}|${start}|${now}`;
|
|
340
453
|
if (settled.has(settledKey))
|
|
341
454
|
return settled.get(settledKey) ?? undefined;
|
|
342
455
|
if (!probing.has(settledKey))
|
|
343
456
|
lookFor(settledKey, start, place, detail);
|
|
344
457
|
return undefined;
|
|
345
458
|
};
|
|
459
|
+
const baseInfo = layer.credit ? { ...INFO, credit: { en: `${GIBS_CREDIT.en} ${layer.credit.en}`, ja: `${GIBS_CREDIT.ja}${layer.credit.ja}` } } : INFO;
|
|
460
|
+
let noted = { key: "", info: baseInfo };
|
|
461
|
+
/** The credit, with a sentence when another layer or the newest day stands in for the one asked for; the same object while that does not change. */
|
|
462
|
+
const infoNow = () => {
|
|
463
|
+
const note = shown ? pickNote(layer, shown) : undefined;
|
|
464
|
+
const key = note ? note.en : "";
|
|
465
|
+
if (key !== noted.key)
|
|
466
|
+
noted = { key, info: note ? { ...baseInfo, credit: { en: `${baseInfo.credit.en} ${note.en}`, ja: `${baseInfo.credit.ja}${note.ja}` } } : baseInfo };
|
|
467
|
+
return noted.info;
|
|
468
|
+
};
|
|
346
469
|
const source = {
|
|
347
470
|
kind: "tiles",
|
|
348
471
|
layer: "day",
|
|
349
|
-
info
|
|
472
|
+
get info() {
|
|
473
|
+
return infoNow();
|
|
474
|
+
},
|
|
350
475
|
holes: true,
|
|
351
476
|
// the loader draws the tile with these on the graphics card: clear where it is dark, and each colour multiplied (nothing is done to the pixels on the processor)
|
|
352
477
|
look: { clear: layer.clear ?? [NODATA_BELOW, NODATA_FULL], ...(layer.gain ? { gain: layer.gain } : {}) },
|
|
@@ -354,10 +479,11 @@ export function gibsTiles(options) {
|
|
|
354
479
|
need(place, detail) {
|
|
355
480
|
if (gridLevelFor(grid, detail, 0) === undefined)
|
|
356
481
|
return [];
|
|
357
|
-
const
|
|
358
|
-
|
|
482
|
+
const pick = pickOf(place, detail);
|
|
483
|
+
shown = pick;
|
|
484
|
+
if (pick === undefined)
|
|
359
485
|
return [];
|
|
360
|
-
return gridKeys(grid, place, detail, `${day}/`);
|
|
486
|
+
return gridKeys(grid, place, detail, `${pick.day}/`);
|
|
361
487
|
},
|
|
362
488
|
levels() {
|
|
363
489
|
return { tileSize: grid.tileSize, levels: grid.levels.map((level) => ({ level: level.level, width: level.width })) };
|
package/dist/photos/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Real satellite pictures of the ground under a point: the address of a NASA GIBS (Worldview) snapshot of a box around it, the days to try when a day is missing, and the credit NASA asks for.
|
|
2
2
|
// Pure: nothing here fetches. The reader's browser asks NASA for the picture (no key, and the service answers any page). A page that never imports this does not pay for it.
|
|
3
|
-
import { GIBS_CREDIT, previousUtcDay, utcDay } from "../door/gibs.js";
|
|
3
|
+
import { GIBS_CREDIT, GIBS_LAYERS, gibsHasDay, previousUtcDay, utcDay } from "../door/gibs.js";
|
|
4
4
|
/** The WMS address of NASA's imagery, in the plain latitude and longitude (EPSG:4326) grid. */
|
|
5
5
|
const WMS = "https://gibs.earthdata.nasa.gov/wms/epsg4326/best/wms.cgi";
|
|
6
6
|
/** Kilometres in a degree of latitude (the mean sphere, 6,371 km). */
|
|
@@ -62,32 +62,9 @@ export const PHOTO_MAX_PX = 2048;
|
|
|
62
62
|
export const PHOTO_FALLBACK_DAYS = 3;
|
|
63
63
|
/**
|
|
64
64
|
* The daily true-colour layers, best first, about 250 m a pixel with the clouds left in: NOAA-20 VIIRS (from 2018-01-05), Suomi NPP VIIRS (2015-11-24 to 2026-11-02, then it ends) and MODIS Terra (from 2000-02-24).
|
|
65
|
-
* The first with a day is used, so a day one of them skipped is taken from the next.
|
|
65
|
+
* The first with a day is used, so a day one of them skipped is taken from the next. Their days are the one table in `door/gibs.ts` (`GIBS_LAYERS`, read on `GIBS_DAYS_READ`), which the finer map tiles use too.
|
|
66
66
|
*/
|
|
67
|
-
const LAYERS = [
|
|
68
|
-
{
|
|
69
|
-
id: "VIIRS_NOAA20_CorrectedReflectance_TrueColor",
|
|
70
|
-
running: true,
|
|
71
|
-
days: [["2018-01-05", "2018-02-21"], ["2018-02-24", "2018-03-12"], ["2018-03-14", "2019-12-31"], ["2020-01-02", "2022-01-12"], ["2022-01-14", "2026-11-16"]],
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
id: "VIIRS_SNPP_CorrectedReflectance_TrueColor",
|
|
75
|
-
running: false,
|
|
76
|
-
days: [["2015-11-24", "2022-07-27"], ["2022-08-10", "2024-05-31"], ["2024-06-04", "2024-07-11"], ["2024-07-16", "2024-07-24"], ["2024-07-29", "2024-11-03"], ["2024-11-06", "2026-04-28"], ["2026-04-30", "2026-07-10"], ["2026-07-16", "2026-11-02"]],
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
id: "MODIS_Terra_CorrectedReflectance_TrueColor",
|
|
80
|
-
running: true,
|
|
81
|
-
days: [["2000-02-24", "2000-04-25"], ["2000-04-28", "2000-08-06"], ["2000-08-18", "2001-06-15"], ["2001-07-03", "2002-03-19"], ["2002-03-28", "2003-12-16"], ["2003-12-24", "2008-12-20"], ["2008-12-23", "2016-02-18"], ["2016-02-27", "2022-10-10"], ["2022-10-23", "2026-11-17"]],
|
|
82
|
-
},
|
|
83
|
-
];
|
|
84
|
-
/** Whether the layer lists the day, or is still running and the day is after its last. */
|
|
85
|
-
const hasDay = (layer, day) => {
|
|
86
|
-
const last = layer.days[layer.days.length - 1][1];
|
|
87
|
-
if (day > last)
|
|
88
|
-
return layer.running;
|
|
89
|
-
return layer.days.some(([start, end]) => day >= start && day <= end);
|
|
90
|
-
};
|
|
67
|
+
const LAYERS = ["VIIRS_NOAA20_CorrectedReflectance_TrueColor", "VIIRS_SNPP_CorrectedReflectance_TrueColor", "MODIS_Terra_CorrectedReflectance_TrueColor"].map((id) => GIBS_LAYERS[id]);
|
|
91
68
|
const clamp = (value, low, high) => Math.min(high, Math.max(low, value));
|
|
92
69
|
const trim = (value) => String(Number(value.toFixed(5)));
|
|
93
70
|
/** The UTC day of a date option, or a RangeError when it is not one. */
|
|
@@ -159,7 +136,7 @@ export function photoBox(options) {
|
|
|
159
136
|
* ```
|
|
160
137
|
*/
|
|
161
138
|
export function photoLayer(day) {
|
|
162
|
-
return LAYERS.find((layer) =>
|
|
139
|
+
return LAYERS.find((layer) => gibsHasDay(layer, day))?.id ?? null;
|
|
163
140
|
}
|
|
164
141
|
function requestFor(layer, west, south, east, north, widthPx, heightPx, day) {
|
|
165
142
|
return `${WMS}?SERVICE=WMS&REQUEST=GetMap&VERSION=1.1.1&LAYERS=${layer}&STYLES=&FORMAT=image%2Fjpeg&SRS=EPSG%3A4326&BBOX=${trim(west)},${trim(south)},${trim(east)},${trim(north)}&WIDTH=${widthPx}&HEIGHT=${heightPx}&TIME=${day}`;
|
|
@@ -377,6 +377,13 @@ export declare class ChikyuEarthRealistic extends HTMLElement {
|
|
|
377
377
|
tiers: Record<EarthLayer, number>;
|
|
378
378
|
tiles: TileStats;
|
|
379
379
|
satellites: SatelliteStats;
|
|
380
|
+
/** How often the running clock draws, as last worked out: the quickest thing's speed on the screen (CSS pixels a second of real time), the frames a second that asks for, the most allowed (`smooth-fps`, halved on a small device or a low battery) and the wait before the next step in milliseconds. */
|
|
381
|
+
pace: {
|
|
382
|
+
pixelsPerSecond: number;
|
|
383
|
+
perSecond: number;
|
|
384
|
+
cap: number;
|
|
385
|
+
waitMs: number;
|
|
386
|
+
};
|
|
380
387
|
/** The cross-fade when `light` changes to or from `lit` (300 ms, a cut under reduced motion): `mix` is 0 for the true light and 1 for `lit`, and `fading` is true while it moves and another frame is wanted. */
|
|
381
388
|
lightFade: {
|
|
382
389
|
mix: number;
|
|
@@ -486,6 +493,20 @@ export declare class ChikyuEarthRealistic extends HTMLElement {
|
|
|
486
493
|
*/
|
|
487
494
|
get satelliteTint(): "off" | "orbit";
|
|
488
495
|
set satelliteTint(value: "off" | "orbit");
|
|
496
|
+
/**
|
|
497
|
+
* The most steps a second drawn for a clock at real time, or up to 60 times it (the attribute `smooth-fps`; 15 when the page says nothing; 1 to 30). The picture is drawn each time the quickest thing in it (the Sun's turn at this zoom, a satellite dot)
|
|
498
|
+
* has moved half a pixel, at least once a second while satellites are on show, and at most this many. Half as many on a small device or a battery at 20% or lower; one a second for a reader who asked for reduced motion.
|
|
499
|
+
*
|
|
500
|
+
* @example
|
|
501
|
+
* ```ts
|
|
502
|
+
* import "@johnmorrisdotca/chikyu-earth/realistic/element";
|
|
503
|
+
*
|
|
504
|
+
* const earth = document.querySelector("chikyu-earth-realistic")!;
|
|
505
|
+
* earth.smoothFps = 24;
|
|
506
|
+
* ```
|
|
507
|
+
*/
|
|
508
|
+
get smoothFps(): number;
|
|
509
|
+
set smoothFps(value: number);
|
|
489
510
|
/**
|
|
490
511
|
* The longest a satellite's streak may be on the screen, in CSS pixels (the attribute `satellite-streak-max`; 8 when the page says nothing; `0` or `off` for no cap). Above 60 times real time each satellite is drawn as a streak along its orbit
|
|
491
512
|
* for the stretch one frame spans, and at a fast clock that stretch is long: at an hour a second a low satellite would cross a tenth of the Earth in one frame. The cap is a length on the screen, so a low and a high satellite are drawn equally long, and the streak keeps the look it has at 10 minutes a second at any speed. It is the smaller of this number of pixels and 0.025 of the Earth's drawn radius (about 160 km of orbit, what a low satellite covers in a frame at 10 minutes a second), so as the Earth is drawn smaller the streak shrinks in proportion, to a dot, instead of staying as long on a small Earth as on a large one. The marks also lose weight on a small Earth: below a drawn radius of 150 pixels the streaks are fainter and the dark rim of the dots fades, gone at 40 pixels, and a crowd of satellites on a small Earth is drawn fainter in proportion so thousands of them do not wash it. Pointing along the orbit and ending at the satellite, it is the same length at any frame rate. Off restores the whole stretch.
|