@johnmorrisdotca/chikyu-earth 0.43.0 → 0.46.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 +16 -0
- package/NOTICE.md +15 -5
- package/README.md +4 -4
- package/dist/door/map.js +5 -1
- package/dist/element.d.ts +30 -0
- package/dist/element.js +82 -2
- package/dist/markers/here-city-host.d.ts +3 -1
- package/dist/markers/here-city-host.js +67 -5
- package/dist/markers/here-city.d.ts +94 -1
- package/dist/markers/here-city.js +69 -1
- package/dist/markers/index.d.ts +1 -1
- package/dist/markers/index.js +1 -1
- package/dist/realistic/element-base.d.ts +37 -0
- package/dist/realistic/element-base.js +86 -14
- package/dist/realistic/index.d.ts +1 -0
- package/dist/realistic/index.js +1 -0
- package/dist/realistic/zoom-reach.d.ts +29 -0
- package/dist/realistic/zoom-reach.js +30 -0
- package/dist/satellites/catalogue.d.ts +52 -1
- package/dist/satellites/catalogue.js +96 -5
- package/dist/satellites/index.d.ts +1 -1
- package/dist/satellites/index.js +1 -1
- package/dist/satellites/track.js +18 -3
- package/dist/satellites/types.d.ts +2 -2
- package/dist/sea-names/features.d.ts +12 -0
- package/dist/sea-names/features.js +46 -0
- package/dist/sea-names/geometry.d.ts +121 -0
- package/dist/sea-names/geometry.js +135 -0
- package/dist/sea-names/host.d.ts +46 -0
- package/dist/sea-names/host.js +111 -0
- package/dist/space/element-base.d.ts +48 -1
- package/dist/space/element-base.js +109 -9
- package/dist/space/generic-satellite.d.ts +46 -0
- package/dist/space/generic-satellite.js +96 -0
- package/dist/space/index.d.ts +2 -1
- package/dist/space/index.js +2 -1
- package/dist/space/ride.d.ts +45 -0
- package/dist/space/ride.js +38 -0
- package/dist/space/satellite-layer.d.ts +37 -0
- package/dist/space/satellite-layer.js +96 -14
- package/dist/space/scene.d.ts +3 -1
- package/dist/space/scene.js +54 -25
- package/package.json +3 -3
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// The nearest city's name on a "you are here" marker. Pure: kuni does the lookup (`CitySet.nearest`); this only decides which places are named, in which language, and how far is too far.
|
|
2
|
+
import { greatCircleKm } from "../route.js";
|
|
1
3
|
/**
|
|
2
4
|
* How far, in kilometres, a `here` marker looks for a city when `here-city` is set with no number.
|
|
3
5
|
*
|
|
@@ -21,7 +23,7 @@ export const HERE_CITY_KM = 100;
|
|
|
21
23
|
*/
|
|
22
24
|
export const HERE_CITY_MAX_KM = 20_000;
|
|
23
25
|
/**
|
|
24
|
-
* The kuni tiers a `here` marker
|
|
26
|
+
* The kuni tiers a `here` marker looks through first. A smaller town is read afterwards from that city's country, one country file at a time.
|
|
25
27
|
*
|
|
26
28
|
* @example
|
|
27
29
|
* ```ts
|
|
@@ -105,3 +107,69 @@ export function hereCityLabels(places, source, options) {
|
|
|
105
107
|
}
|
|
106
108
|
return out;
|
|
107
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
* At most two countries to read for a place. The first is the country of the nearest city in the three tiers, however far.
|
|
112
|
+
* The second is added only when a city of another country is also inside the limit: a place near a border. `src/countries.ts` has no point-in-country test, so the country comes from those cities.
|
|
113
|
+
*
|
|
114
|
+
* @param point - The place.
|
|
115
|
+
* @param source - The three tiers.
|
|
116
|
+
* @param maxKm - The limit, in kilometres.
|
|
117
|
+
* @returns ISO codes, upper case, at most two.
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```ts
|
|
121
|
+
* import { hereCountries } from "@johnmorrisdotca/chikyu-earth/markers";
|
|
122
|
+
*
|
|
123
|
+
* const source = {
|
|
124
|
+
* nearest: () => ({ city: { id: "a", name: { en: "A" }, country: "fr" }, km: 30 }),
|
|
125
|
+
* within: () => [{ city: { country: "fr" }, km: 30 }, { city: { country: "de" }, km: 40 }],
|
|
126
|
+
* };
|
|
127
|
+
* console.log(hereCountries({ lat: 49, lon: 8 }, source, 100).join(" "));
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
export function hereCountries(point, source, maxKm) {
|
|
131
|
+
const nearest = source.nearest(point);
|
|
132
|
+
const first = nearest?.city.country?.trim().toUpperCase();
|
|
133
|
+
if (!first)
|
|
134
|
+
return [];
|
|
135
|
+
const out = [first];
|
|
136
|
+
for (const hit of source.within?.(point, maxKm) ?? []) {
|
|
137
|
+
const code = hit.city.country?.trim().toUpperCase();
|
|
138
|
+
if (code && code !== first) {
|
|
139
|
+
out.push(code);
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return out;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* The city to draw: the nearest of the coarse hit and the towns, and only when it is within `maxKm`. A town closer than the big city wins.
|
|
147
|
+
*
|
|
148
|
+
* @param point - The place.
|
|
149
|
+
* @param coarse - The nearest city of the three tiers inside the limit, or null.
|
|
150
|
+
* @param towns - The cities of the one or two countries read for this place.
|
|
151
|
+
* @param maxKm - The limit, in kilometres.
|
|
152
|
+
* @returns The city and its distance, or null when none is close enough.
|
|
153
|
+
*
|
|
154
|
+
* @example
|
|
155
|
+
* ```ts
|
|
156
|
+
* import { chooseHereCity } from "@johnmorrisdotca/chikyu-earth/markers";
|
|
157
|
+
*
|
|
158
|
+
* const town = { id: "v", name: { en: "Village" }, lat: 0.05, lon: 0 };
|
|
159
|
+
* const chosen = chooseHereCity({ lat: 0, lon: 0 }, { city: { id: "c", name: { en: "City" } }, km: 40 }, [town], 100);
|
|
160
|
+
* console.log(chosen?.id);
|
|
161
|
+
* ```
|
|
162
|
+
*/
|
|
163
|
+
export function chooseHereCity(point, coarse, towns, maxKm) {
|
|
164
|
+
if (!(maxKm > 0))
|
|
165
|
+
return null;
|
|
166
|
+
let best = coarse && coarse.km <= maxKm ? { id: coarse.city.id, name: coarse.city.name, km: coarse.km } : null;
|
|
167
|
+
for (const town of towns) {
|
|
168
|
+
const km = greatCircleKm({ lon: point.lon, lat: point.lat }, { lon: town.lon, lat: town.lat });
|
|
169
|
+
if (km === null || km > maxKm)
|
|
170
|
+
continue;
|
|
171
|
+
if (!best || km < best.km - 1e-6)
|
|
172
|
+
best = { id: town.id, name: town.name, km };
|
|
173
|
+
}
|
|
174
|
+
return best;
|
|
175
|
+
}
|
package/dist/markers/index.d.ts
CHANGED
|
@@ -4,5 +4,5 @@ export { clusterPoints, type Cluster } from "./cluster.ts";
|
|
|
4
4
|
export { placeLabels, type LabelItem, type Placement } from "./labels.ts";
|
|
5
5
|
export type { GroupInfo, MarkerEventDetail, MarkerIcon, MarkerInput } from "./types.ts";
|
|
6
6
|
export { cleanPlaces, groupCell, groupPlaces, layoutPlaces, MAX_PLACES, nearby, orthoView, PLACE_GROUP_PX, PLACE_LOOKS, readPlaceGroups, readPlaces, type Place, type PlaceGroup, type PlaceKind, type PlaceLabelSpot, type PlaceLayout, type PlaceLayoutOptions, type PlaceLook, type PlaceShape, type PlaceView, type SurfacePoint } from "./places.ts";
|
|
7
|
-
export { HERE_CITY_KM, HERE_CITY_MAX_KM, HERE_CITY_TIERS, hereCityLabels, readHereCity, type HereCityHit, type HereCitySource } from "./here-city.ts";
|
|
7
|
+
export { HERE_CITY_KM, HERE_CITY_MAX_KM, HERE_CITY_TIERS, chooseHereCity, hereCityLabels, hereCountries, readHereCity, type HereCityHit, type HereCitySource, type HereTown } from "./here-city.ts";
|
|
8
8
|
export { PLACE_DOTS, PLACE_MARKS } from "./place-layer.ts";
|
package/dist/markers/index.js
CHANGED
|
@@ -5,5 +5,5 @@ export { project, projectAll, canvasRatio } from "./project.js";
|
|
|
5
5
|
export { clusterPoints } from "./cluster.js";
|
|
6
6
|
export { placeLabels } from "./labels.js";
|
|
7
7
|
export { cleanPlaces, groupCell, groupPlaces, layoutPlaces, MAX_PLACES, nearby, orthoView, PLACE_GROUP_PX, PLACE_LOOKS, readPlaceGroups, readPlaces } from "./places.js";
|
|
8
|
-
export { HERE_CITY_KM, HERE_CITY_MAX_KM, HERE_CITY_TIERS, hereCityLabels, readHereCity } from "./here-city.js";
|
|
8
|
+
export { HERE_CITY_KM, HERE_CITY_MAX_KM, HERE_CITY_TIERS, chooseHereCity, hereCityLabels, hereCountries, readHereCity } from "./here-city.js";
|
|
9
9
|
export { PLACE_DOTS, PLACE_MARKS } from "./place-layer.js";
|
|
@@ -16,6 +16,7 @@ import type { BorderData, BorderStats } from "../borders/layer.ts";
|
|
|
16
16
|
import { type RouteLeg } from "../route.ts";
|
|
17
17
|
import type { GridStats } from "../grid/layer.ts";
|
|
18
18
|
import { type CountryNamesStats, type CountryNamesStyle } from "../country-names/host.ts";
|
|
19
|
+
import { type SeaNamesStats } from "../sea-names/host.ts";
|
|
19
20
|
import { setSharedRenderer, setThreeLoader } from "./shared.ts";
|
|
20
21
|
export { setSharedRenderer, setThreeLoader };
|
|
21
22
|
export type { CameraMode };
|
|
@@ -41,6 +42,11 @@ type SatelliteStats = {
|
|
|
41
42
|
segments: number;
|
|
42
43
|
tooFast: boolean;
|
|
43
44
|
dotScale: number;
|
|
45
|
+
longestStreakPx: number;
|
|
46
|
+
streakCapPx: number;
|
|
47
|
+
weight: number;
|
|
48
|
+
fade: number;
|
|
49
|
+
earthPx: number;
|
|
44
50
|
epochMs: number;
|
|
45
51
|
propagations: number;
|
|
46
52
|
lastBatchMs: number;
|
|
@@ -271,6 +277,21 @@ export declare class ChikyuEarthRealistic extends HTMLElement {
|
|
|
271
277
|
*/
|
|
272
278
|
get countryNamesStyle(): CountryNamesStyle;
|
|
273
279
|
set countryNamesStyle(value: CountryNamesStyle);
|
|
280
|
+
/**
|
|
281
|
+
* Names of oceans, seas and continents (the attribute `sea-names`). Off unless set: a bare attribute is on. Oceans and continents from far out, seas once the Earth is large on the screen. A city name keeps the space where both fit only one. Nothing is drawn again at rest.
|
|
282
|
+
*
|
|
283
|
+
* @example
|
|
284
|
+
* ```ts no-run
|
|
285
|
+
* import type { ChikyuEarthRealistic } from "@johnmorrisdotca/chikyu-earth/realistic/element";
|
|
286
|
+
*
|
|
287
|
+
* const earth = document.querySelector("chikyu-earth-realistic") as ChikyuEarthRealistic;
|
|
288
|
+
* earth.seaNames = true;
|
|
289
|
+
* console.log(earth.seaNames);
|
|
290
|
+
* earth.seaNames = false;
|
|
291
|
+
* ```
|
|
292
|
+
*/
|
|
293
|
+
get seaNames(): boolean;
|
|
294
|
+
set seaNames(value: boolean);
|
|
274
295
|
/**
|
|
275
296
|
* Which borders are drawn (the attribute `borders`): the countries' at any size, and the regions' (provinces, states, prefectures) once the Earth is large enough on the screen to tell them apart.
|
|
276
297
|
* Setting it writes the attribute: both sets as `borders="countries regions"`, one as its own word, none takes the attribute away.
|
|
@@ -431,6 +452,8 @@ export declare class ChikyuEarthRealistic extends HTMLElement {
|
|
|
431
452
|
};
|
|
432
453
|
/** The names of countries: whether `country-names` is set and the most it asks for, the countries loaded, the names shown at the last draw, how many times they were laid out, and whether the outlines could not be loaded. */
|
|
433
454
|
countryNames: CountryNamesStats;
|
|
455
|
+
/** The names of oceans, seas and continents: whether `sea-names` is on, the Earth's radius on the screen, the names shown at the last draw, and how many times the layer was laid out. */
|
|
456
|
+
seaNames: SeaNamesStats;
|
|
434
457
|
};
|
|
435
458
|
/**
|
|
436
459
|
* Apply a shared view controller's camera (yaw, tilt, zoom, pan). A change under half a pixel is not drawn, a settled change always is,
|
|
@@ -442,6 +465,20 @@ export declare class ChikyuEarthRealistic extends HTMLElement {
|
|
|
442
465
|
*/
|
|
443
466
|
get satelliteTint(): "off" | "orbit";
|
|
444
467
|
set satelliteTint(value: "off" | "orbit");
|
|
468
|
+
/**
|
|
469
|
+
* 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
|
|
470
|
+
* 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.
|
|
471
|
+
*
|
|
472
|
+
* @example
|
|
473
|
+
* ```ts
|
|
474
|
+
* import "@johnmorrisdotca/chikyu-earth/realistic/element";
|
|
475
|
+
*
|
|
476
|
+
* const earth = document.querySelector("chikyu-earth-realistic")!;
|
|
477
|
+
* earth.satelliteStreakMax = 12;
|
|
478
|
+
* ```
|
|
479
|
+
*/
|
|
480
|
+
get satelliteStreakMax(): number;
|
|
481
|
+
set satelliteStreakMax(value: number);
|
|
445
482
|
/**
|
|
446
483
|
* Show a group of satellites (made by `createSatellites`) under a name, or take the group away with `null`. A group is one draw call however many satellites it holds, so every group of the catalogue can be shown at once. Giving the name of a group
|
|
447
484
|
* that is already shown replaces it. `style`: `color` and `size` (CSS pixels) of the dots, and `orbits` to draw every orbit (only for a group of 40 or fewer, such as the stations). The groups are placed by SGP4 about once a second and interpolated
|
|
@@ -8,7 +8,7 @@ import { IMMERSIVE_STYLE, immersiveWheel } from "./immersive.js";
|
|
|
8
8
|
import { NOTES_STYLE, setAirNote } from "./air-note.js";
|
|
9
9
|
import { cameraCentre, createEarthItem, discRadius, lookAt, newModel } from "./earth.js";
|
|
10
10
|
import { createPaintState, paintedGround, paintedPeriod } from "../paint/buffer.js";
|
|
11
|
-
import { MAX_ORBIT_GROUP } from "../space/satellite-layer.js";
|
|
11
|
+
import { MAX_ORBIT_GROUP, readStreakMax } from "../space/satellite-layer.js";
|
|
12
12
|
import { applySatelliteFocus, satelliteEmphasis, satelliteGroupRows, shellRadiusOf, zoomForOrthographicShell } from "../space/satellite-focus.js";
|
|
13
13
|
import { readMeteorStrength } from "../meteors/strength.js";
|
|
14
14
|
import { METEOR_NOTE_STYLE, prefersLessMotion, setMeteorNote } from "../meteors/note.js";
|
|
@@ -31,11 +31,14 @@ import { readRoute, routeLeg, routeText } from "../route.js";
|
|
|
31
31
|
import { applyRoute } from "../route/layer.js";
|
|
32
32
|
import { COUNTRY_NAMES_ATTRIBUTES } from "../country-names/geometry.js";
|
|
33
33
|
import { COUNTRY_NAMES_STYLE, createCountryHost } from "../country-names/host.js";
|
|
34
|
+
import { SEA_NAMES_ATTRIBUTES, readSeaNames } from "../sea-names/geometry.js";
|
|
35
|
+
import { SEA_NAMES_STYLE, createSeaHost } from "../sea-names/host.js";
|
|
34
36
|
import { createGate, frameCap } from "./gate.js";
|
|
35
37
|
import { setSharedRenderer, setThreeLoader, takeRenderer } from "./shared.js";
|
|
36
38
|
export { setSharedRenderer, setThreeLoader };
|
|
37
39
|
import { MAX_TEXTURE, TIERS } from "./tiers.js";
|
|
38
|
-
|
|
40
|
+
import { mayWriteZoomMax, raisedZoomMax } from "./zoom-reach.js";
|
|
41
|
+
const STYLE = ":host{display:block;aspect-ratio:1/1;position:relative;isolation:isolate}" + IMMERSIVE_STYLE + "#stage,#overlay{position:absolute;inset:0}#overlay{pointer-events:none}" + PLACE_STYLE + SKY_STYLE + COUNTRY_NAMES_STYLE + SEA_NAMES_STYLE + CITY_NAMES_STYLE + METEOR_NOTE_STYLE + NOTES_STYLE;
|
|
39
42
|
const RAD = Math.PI / 180;
|
|
40
43
|
/** The Sun and the clouds are re-placed this often at real time: 15 degrees an hour is 0.25 degree a minute. */
|
|
41
44
|
const LIVE_TICK_MS = 60_000;
|
|
@@ -46,8 +49,6 @@ const TIME_EVENT_MS = 250;
|
|
|
46
49
|
const SUN_RATE = 360 / 86_400;
|
|
47
50
|
/** Tilt to the poles; zoom from a tenth of Fit, which leaves the whole Earth small in the view, to 5 times: the package's own pictures are sharp to about 5 times. */
|
|
48
51
|
const LIMITS = { tiltMax: 90, zoomMin: 0.1, zoomMax: 5 };
|
|
49
|
-
/** With the finer tiles the detail runs 4 times further: the finest level is 4 times wider than the widest picture. */
|
|
50
|
-
const TILES_ZOOM_MAX = "20";
|
|
51
52
|
const readCentre = (value) => {
|
|
52
53
|
if (!value)
|
|
53
54
|
return null;
|
|
@@ -159,7 +160,7 @@ export const readTime = (value) => {
|
|
|
159
160
|
* ```
|
|
160
161
|
*/
|
|
161
162
|
export class ChikyuEarthRealistic extends HTMLElement {
|
|
162
|
-
static observedAttributes = ["cloud-drift", "center", "time", "speed", "clouds", "lights", "light", "live-seconds", "tiles", "data", "camera", "immersive", "meteors", "meteors-label", "meteors-strength", ...BODY_LABEL_ATTRIBUTES, ...SKY_ATTRIBUTES, ...CITY_NAMES_ATTRIBUTES, ...BORDER_ATTRIBUTES, ...GRID_ATTRIBUTES, ...COUNTRY_NAMES_ATTRIBUTES, "air-thickness", "air-label", "lang", "places", "places-look", "place-groups", "here-city", "route", "satellite-tint"];
|
|
163
|
+
static observedAttributes = ["cloud-drift", "center", "time", "speed", "clouds", "lights", "light", "live-seconds", "tiles", "data", "camera", "immersive", "meteors", "meteors-label", "meteors-strength", ...BODY_LABEL_ATTRIBUTES, ...SKY_ATTRIBUTES, ...CITY_NAMES_ATTRIBUTES, ...BORDER_ATTRIBUTES, ...GRID_ATTRIBUTES, ...COUNTRY_NAMES_ATTRIBUTES, ...SEA_NAMES_ATTRIBUTES, "air-thickness", "air-label", "lang", "places", "places-look", "place-groups", "here-city", "route", "satellite-tint", "satellite-streak-max"];
|
|
163
164
|
#model = newModel();
|
|
164
165
|
#paint = createPaintState();
|
|
165
166
|
#mode = "now";
|
|
@@ -189,6 +190,7 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
189
190
|
#citiesStyle = {};
|
|
190
191
|
/** The names of the countries on the Earth (`country-names`), and the look of the names. */
|
|
191
192
|
#countries;
|
|
193
|
+
#seas;
|
|
192
194
|
#countriesStyle = {};
|
|
193
195
|
#listeners = new Set();
|
|
194
196
|
#placeLayer;
|
|
@@ -279,6 +281,11 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
279
281
|
onError: (error) => this.dispatchEvent(new CustomEvent("chikyu-country-names-unavailable", { detail: { reason: error instanceof Error ? error.message : String(error) } })),
|
|
280
282
|
});
|
|
281
283
|
this.#countries.setStyle(this.#countriesStyle);
|
|
284
|
+
this.#seas = createSeaHost({
|
|
285
|
+
root,
|
|
286
|
+
attribute: (name) => this.getAttribute(name),
|
|
287
|
+
language: () => ((this.closest("[lang]")?.getAttribute("lang") ?? "").toLowerCase().startsWith("ja") ? "ja" : "en"),
|
|
288
|
+
});
|
|
282
289
|
this.#played = false;
|
|
283
290
|
this.#model.meteors.on = this.#meteorsAsked();
|
|
284
291
|
this.#model.meteors.strength = readMeteorStrength(this.getAttribute("meteors-strength"));
|
|
@@ -306,11 +313,12 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
306
313
|
cap: () => this.#textureCap(),
|
|
307
314
|
sources: () => this.#tileSources(),
|
|
308
315
|
onTiles: (layers) => {
|
|
309
|
-
if (
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
316
|
+
if (mayWriteZoomMax(this.getAttribute("zoom-max"), this.#reach)) {
|
|
317
|
+
// only ever raised, and lowered when the tiles are taken away (below), not before
|
|
318
|
+
const reach = raisedZoomMax(this.#reach, layers);
|
|
319
|
+
this.#reach = reach;
|
|
320
|
+
if (this.getAttribute("zoom-max") !== reach)
|
|
321
|
+
this.setAttribute("zoom-max", reach);
|
|
314
322
|
}
|
|
315
323
|
this.dispatchEvent(new CustomEvent("chikyu-tiles", { detail: { layers } }));
|
|
316
324
|
},
|
|
@@ -406,6 +414,8 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
406
414
|
this.#cities = undefined;
|
|
407
415
|
this.#countries?.dispose();
|
|
408
416
|
this.#countries = undefined;
|
|
417
|
+
this.#seas?.dispose();
|
|
418
|
+
this.#seas = undefined;
|
|
409
419
|
}
|
|
410
420
|
attributeChangedCallback(name, _old, value) {
|
|
411
421
|
if (name === "center")
|
|
@@ -448,6 +458,7 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
448
458
|
this.#applyBodyLabel();
|
|
449
459
|
this.#sky?.refresh();
|
|
450
460
|
this.#cities?.refresh();
|
|
461
|
+
this.#seas?.refresh();
|
|
451
462
|
this.#countries?.refresh();
|
|
452
463
|
this.#here?.refresh();
|
|
453
464
|
}
|
|
@@ -478,6 +489,11 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
478
489
|
}
|
|
479
490
|
else if (CITY_NAMES_ATTRIBUTES.includes(name))
|
|
480
491
|
this.#cities?.refresh();
|
|
492
|
+
else if (SEA_NAMES_ATTRIBUTES.includes(name)) {
|
|
493
|
+
this.#seas?.refresh();
|
|
494
|
+
this.#seaFrame();
|
|
495
|
+
this.#countryFrame();
|
|
496
|
+
}
|
|
481
497
|
else if (name === "borders") {
|
|
482
498
|
Object.assign(this.#model.borders, readBorders(value));
|
|
483
499
|
this.#gate?.soon();
|
|
@@ -492,6 +508,10 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
492
508
|
this.#model.satellites.orbitTint = value === "orbit";
|
|
493
509
|
this.#gate?.soon();
|
|
494
510
|
}
|
|
511
|
+
else if (name === "satellite-streak-max") {
|
|
512
|
+
this.#model.satellites.streakMax = readStreakMax(value);
|
|
513
|
+
this.#gate?.soon();
|
|
514
|
+
}
|
|
495
515
|
if (name === "air-thickness" || name === "air-label" || name === "lang")
|
|
496
516
|
setAirNote(this.#airNote, this, this.#model.airThickness);
|
|
497
517
|
}
|
|
@@ -798,6 +818,28 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
798
818
|
this.#countriesStyle = { ...value };
|
|
799
819
|
this.#countries?.setStyle(this.#countriesStyle);
|
|
800
820
|
}
|
|
821
|
+
/**
|
|
822
|
+
* Names of oceans, seas and continents (the attribute `sea-names`). Off unless set: a bare attribute is on. Oceans and continents from far out, seas once the Earth is large on the screen. A city name keeps the space where both fit only one. Nothing is drawn again at rest.
|
|
823
|
+
*
|
|
824
|
+
* @example
|
|
825
|
+
* ```ts no-run
|
|
826
|
+
* import type { ChikyuEarthRealistic } from "@johnmorrisdotca/chikyu-earth/realistic/element";
|
|
827
|
+
*
|
|
828
|
+
* const earth = document.querySelector("chikyu-earth-realistic") as ChikyuEarthRealistic;
|
|
829
|
+
* earth.seaNames = true;
|
|
830
|
+
* console.log(earth.seaNames);
|
|
831
|
+
* earth.seaNames = false;
|
|
832
|
+
* ```
|
|
833
|
+
*/
|
|
834
|
+
get seaNames() {
|
|
835
|
+
return readSeaNames(this.getAttribute("sea-names"));
|
|
836
|
+
}
|
|
837
|
+
set seaNames(value) {
|
|
838
|
+
if (value)
|
|
839
|
+
this.setAttribute("sea-names", "");
|
|
840
|
+
else
|
|
841
|
+
this.removeAttribute("sea-names");
|
|
842
|
+
}
|
|
801
843
|
/**
|
|
802
844
|
* Which borders are drawn (the attribute `borders`): the countries' at any size, and the regions' (provinces, states, prefectures) once the Earth is large enough on the screen to tell them apart.
|
|
803
845
|
* Setting it writes the attribute: both sets as `borders="countries regions"`, one as its own word, none takes the attribute away.
|
|
@@ -850,6 +892,7 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
850
892
|
#relayNames(cities, sky) {
|
|
851
893
|
if (cities && this.#nameFrame)
|
|
852
894
|
this.#cities?.frame(this.#nameFrame, this.#boxesBeforeCities());
|
|
895
|
+
this.#seaFrame();
|
|
853
896
|
this.#countryFrame();
|
|
854
897
|
if (sky)
|
|
855
898
|
this.#sky?.relayout();
|
|
@@ -872,17 +915,24 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
872
915
|
out.push(...(this.#placeLayer?.boxes ?? []));
|
|
873
916
|
for (const boxes of this.#claims.values())
|
|
874
917
|
out.push(...boxes);
|
|
875
|
-
out.push(...(this.#cities?.boxes ?? []));
|
|
918
|
+
out.push(...(this.#cities?.boxes ?? []), ...(this.#seas?.boxes ?? []));
|
|
876
919
|
return out;
|
|
877
920
|
}
|
|
878
921
|
/** The frame the names were last laid out on. */
|
|
879
922
|
#nameFrame = null;
|
|
880
|
-
/** Lays the
|
|
923
|
+
/** Lays the ocean, sea and continent names out on the last frame, clear of the places' and the cities' names. A city that was placed first keeps the space. */
|
|
924
|
+
#seaFrame() {
|
|
925
|
+
const seas = this.#seas;
|
|
926
|
+
if (!seas || !this.#nameFrame)
|
|
927
|
+
return;
|
|
928
|
+
seas.frame(this.#nameFrame, seas.stats.on ? [...(this.#placeLayer?.boxes ?? []), ...(this.#cities?.boxes ?? []), ...[...this.#claims.values()].flat()] : []);
|
|
929
|
+
}
|
|
930
|
+
/** Lays the countries' names out on the last frame, clear of the places', the cities' and the sea names as they are now. */
|
|
881
931
|
#countryFrame() {
|
|
882
932
|
const countries = this.#countries;
|
|
883
933
|
if (!countries || !this.#nameFrame)
|
|
884
934
|
return;
|
|
885
|
-
countries.frame(this.#nameFrame, countries.stats.on ? [...(this.#placeLayer?.boxes ?? []), ...(this.#cities?.boxes ?? []), ...[...this.#claims.values()].flat()] : []);
|
|
935
|
+
countries.frame(this.#nameFrame, countries.stats.on ? [...(this.#placeLayer?.boxes ?? []), ...(this.#cities?.boxes ?? []), ...(this.#seas?.boxes ?? []), ...[...this.#claims.values()].flat()] : []);
|
|
886
936
|
}
|
|
887
937
|
/** Puts the name's settings and text right from the attributes (`body-label` and its family, `lang`). */
|
|
888
938
|
#applyBodyLabel() {
|
|
@@ -1097,6 +1147,7 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
1097
1147
|
grid: { ...this.#model.grid.stats },
|
|
1098
1148
|
route: { ...this.#model.route.stats },
|
|
1099
1149
|
countryNames: this.#countries?.stats ?? { on: false, max: 0, countries: 0, names: 0, renders: 0, failed: false },
|
|
1150
|
+
seaNames: this.#seas?.stats ?? { on: false, radius: 0, names: 0, renders: 0 },
|
|
1100
1151
|
};
|
|
1101
1152
|
}
|
|
1102
1153
|
/**
|
|
@@ -1130,6 +1181,27 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
1130
1181
|
else
|
|
1131
1182
|
this.removeAttribute("satellite-tint");
|
|
1132
1183
|
}
|
|
1184
|
+
/**
|
|
1185
|
+
* 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
|
|
1186
|
+
* 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.
|
|
1187
|
+
*
|
|
1188
|
+
* @example
|
|
1189
|
+
* ```ts
|
|
1190
|
+
* import "@johnmorrisdotca/chikyu-earth/realistic/element";
|
|
1191
|
+
*
|
|
1192
|
+
* const earth = document.querySelector("chikyu-earth-realistic")!;
|
|
1193
|
+
* earth.satelliteStreakMax = 12;
|
|
1194
|
+
* ```
|
|
1195
|
+
*/
|
|
1196
|
+
get satelliteStreakMax() {
|
|
1197
|
+
return this.#model.satellites.streakMax;
|
|
1198
|
+
}
|
|
1199
|
+
set satelliteStreakMax(value) {
|
|
1200
|
+
if (Number.isFinite(value) && value >= 0)
|
|
1201
|
+
this.setAttribute("satellite-streak-max", String(value));
|
|
1202
|
+
else
|
|
1203
|
+
this.removeAttribute("satellite-streak-max");
|
|
1204
|
+
}
|
|
1133
1205
|
/**
|
|
1134
1206
|
* Show a group of satellites (made by `createSatellites`) under a name, or take the group away with `null`. A group is one draw call however many satellites it holds, so every group of the catalogue can be shown at once. Giving the name of a group
|
|
1135
1207
|
* that is already shown replaces it. `style`: `color` and `size` (CSS pixels) of the dots, and `orbits` to draw every orbit (only for a group of 40 or fewer, such as the stations). The groups are placed by SGP4 about once a second and interpolated
|
|
@@ -1282,7 +1354,7 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
1282
1354
|
let epochMs = 0;
|
|
1283
1355
|
for (const group of this.#model.satellites.groups.values())
|
|
1284
1356
|
epochMs = Math.max(epochMs, group.satellites.newestEpochMs);
|
|
1285
|
-
return { groups: this.#model.satellites.groups.size, placed: drawn.placed, segments: drawn.segments, tooFast: drawn.tooFast, dotScale: drawn.dotScale, epochMs, propagations, lastBatchMs, maxBatchMs, updateMs: drawn.updateMs, maxUpdateMs: drawn.maxUpdateMs, averageUpdateMs: drawn.updates ? drawn.totalMs / drawn.updates : 0, updates: drawn.updates };
|
|
1357
|
+
return { groups: this.#model.satellites.groups.size, placed: drawn.placed, segments: drawn.segments, tooFast: drawn.tooFast, dotScale: drawn.dotScale, longestStreakPx: drawn.longestStreakPx, streakCapPx: drawn.streakCapPx, weight: drawn.weight, fade: drawn.fade, earthPx: drawn.earthPx, epochMs, propagations, lastBatchMs, maxBatchMs, updateMs: drawn.updateMs, maxUpdateMs: drawn.maxUpdateMs, averageUpdateMs: drawn.updates ? drawn.totalMs / drawn.updates : 0, updates: drawn.updates };
|
|
1286
1358
|
}
|
|
1287
1359
|
// A press that does not turn the view (under 6 pixels) on a satellite tells the page, which chooses it with `selectSatellite` if it likes.
|
|
1288
1360
|
#downX = 0;
|
|
@@ -17,4 +17,5 @@ export type { BorderData, BorderStats } from "../borders/layer.ts";
|
|
|
17
17
|
export { EARTH_TILT, GRID_ATTRIBUTES, GRID_FINE_RADIUS, gridLines, readGrid, type GridLines } from "../grid/lines.ts";
|
|
18
18
|
export type { GridStats } from "../grid/layer.ts";
|
|
19
19
|
export { COUNTRY_LETTER_SPACING, COUNTRY_NAMES_ATTRIBUTES, COUNTRY_NAMES_DEFAULT, COUNTRY_NAMES_MAX, countryNameBox, countryNameText, countrySpots, layoutCountryNames, readCountryNames, type CountryFrame, type CountryLayoutOptions, type CountryName, type CountrySpots, type NamedShape } from "../country-names/geometry.ts";
|
|
20
|
+
export { SEA_FEATURES, SEA_RADIUS, layoutSeaNames, readSeaNames, seaNamesFor, type SeaFeature, type SeaName } from "../sea-names/geometry.ts";
|
|
20
21
|
export type { CountryNamesStats, CountryNamesStyle } from "../country-names/host.ts";
|
package/dist/realistic/index.js
CHANGED
|
@@ -14,3 +14,4 @@ export { CITY_NAMES_ATTRIBUTES } from "../cities/host.js";
|
|
|
14
14
|
export { BORDER_ATTRIBUTES, BORDER_REGIONS_RADIUS, codesNear, readBorders, shapeBoxes, sharedEdges } from "../borders/lines.js";
|
|
15
15
|
export { EARTH_TILT, GRID_ATTRIBUTES, GRID_FINE_RADIUS, gridLines, readGrid } from "../grid/lines.js";
|
|
16
16
|
export { COUNTRY_LETTER_SPACING, COUNTRY_NAMES_ATTRIBUTES, COUNTRY_NAMES_DEFAULT, COUNTRY_NAMES_MAX, countryNameBox, countryNameText, countrySpots, layoutCountryNames, readCountryNames } from "../country-names/geometry.js";
|
|
17
|
+
export { SEA_FEATURES, SEA_RADIUS, layoutSeaNames, readSeaNames, seaNamesFor } from "../sea-names/geometry.js";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** The zoom limit of the package's own pictures (the element's `LIMITS.zoomMax`), sharp to about this many times. */
|
|
2
|
+
export declare const PICTURE_ZOOM = 5;
|
|
3
|
+
/** The width of the widest picture the tiles are laid over, which that limit is sharp to. */
|
|
4
|
+
export declare const PICTURE_WIDTH = 4096;
|
|
5
|
+
/**
|
|
6
|
+
* The zoom limit a tile set gives: as many times `PICTURE_ZOOM` as the finest day level is wider than the widest picture (16384 across, 4 times: 20; 32768, 8 times: 40), never below the pictures' own
|
|
7
|
+
* limit, and the pictures' own limit when the set has no day layer.
|
|
8
|
+
*
|
|
9
|
+
* @param layers - The width in pixels of the finest level of each layer of the set.
|
|
10
|
+
* @returns The limit, as the attribute's text.
|
|
11
|
+
*/
|
|
12
|
+
export declare const tilesZoomMax: (layers: Record<string, number>) => string;
|
|
13
|
+
/**
|
|
14
|
+
* The limit to write when a set has been read: the larger of the one written before and the set's own, so a source with fewer levels added later does not lower it (the view controls take a written
|
|
15
|
+
* attribute as a new limit and bring the view back to fit).
|
|
16
|
+
*
|
|
17
|
+
* @param written - What this element wrote before, or null.
|
|
18
|
+
* @param layers - The width of the finest level of each layer of the set read now.
|
|
19
|
+
* @returns The limit, as the attribute's text.
|
|
20
|
+
*/
|
|
21
|
+
export declare const raisedZoomMax: (written: string | null, layers: Record<string, number>) => string;
|
|
22
|
+
/**
|
|
23
|
+
* Whether the element may write the limit: when the page has set none, or the one there is the one the element wrote. A `zoom-max` a page sets itself is never overwritten.
|
|
24
|
+
*
|
|
25
|
+
* @param attribute - The `zoom-max` attribute now, or null.
|
|
26
|
+
* @param written - What this element wrote before, or null.
|
|
27
|
+
* @returns True when the element may write.
|
|
28
|
+
*/
|
|
29
|
+
export declare const mayWriteZoomMax: (attribute: string | null, written: string | null) => boolean;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// How far the realistic Earth may be zoomed once its tiles are found. Pure: the element reads and writes the `zoom-max` attribute, this says what to write.
|
|
2
|
+
/** The zoom limit of the package's own pictures (the element's `LIMITS.zoomMax`), sharp to about this many times. */
|
|
3
|
+
export const PICTURE_ZOOM = 5;
|
|
4
|
+
/** The width of the widest picture the tiles are laid over, which that limit is sharp to. */
|
|
5
|
+
export const PICTURE_WIDTH = 4096;
|
|
6
|
+
/**
|
|
7
|
+
* The zoom limit a tile set gives: as many times `PICTURE_ZOOM` as the finest day level is wider than the widest picture (16384 across, 4 times: 20; 32768, 8 times: 40), never below the pictures' own
|
|
8
|
+
* limit, and the pictures' own limit when the set has no day layer.
|
|
9
|
+
*
|
|
10
|
+
* @param layers - The width in pixels of the finest level of each layer of the set.
|
|
11
|
+
* @returns The limit, as the attribute's text.
|
|
12
|
+
*/
|
|
13
|
+
export const tilesZoomMax = (layers) => String(Math.max(PICTURE_ZOOM, Math.round((PICTURE_ZOOM * (layers["day"] ?? 0)) / PICTURE_WIDTH)));
|
|
14
|
+
/**
|
|
15
|
+
* The limit to write when a set has been read: the larger of the one written before and the set's own, so a source with fewer levels added later does not lower it (the view controls take a written
|
|
16
|
+
* attribute as a new limit and bring the view back to fit).
|
|
17
|
+
*
|
|
18
|
+
* @param written - What this element wrote before, or null.
|
|
19
|
+
* @param layers - The width of the finest level of each layer of the set read now.
|
|
20
|
+
* @returns The limit, as the attribute's text.
|
|
21
|
+
*/
|
|
22
|
+
export const raisedZoomMax = (written, layers) => String(Math.max(Number(written ?? 0), Number(tilesZoomMax(layers))));
|
|
23
|
+
/**
|
|
24
|
+
* Whether the element may write the limit: when the page has set none, or the one there is the one the element wrote. A `zoom-max` a page sets itself is never overwritten.
|
|
25
|
+
*
|
|
26
|
+
* @param attribute - The `zoom-max` attribute now, or null.
|
|
27
|
+
* @param written - What this element wrote before, or null.
|
|
28
|
+
* @returns True when the element may write.
|
|
29
|
+
*/
|
|
30
|
+
export const mayWriteZoomMax = (attribute, written) => attribute === null || attribute === written;
|
|
@@ -81,7 +81,57 @@ export declare const SATELLITE_GROUPS: readonly SatelliteGroupInfo[];
|
|
|
81
81
|
*/
|
|
82
82
|
export declare const CATALOGUE: readonly CatalogueEntry[];
|
|
83
83
|
/**
|
|
84
|
-
*
|
|
84
|
+
* One plain row a page can index, for its own search box. No DOM: a group or a satellite, with both languages on every row.
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```ts
|
|
88
|
+
* import type { CatalogueRow } from "@johnmorrisdotca/chikyu-earth/satellites";
|
|
89
|
+
*
|
|
90
|
+
* const row: CatalogueRow = { kind: "group", id: "weather", names: { en: "Weather", ja: "気象衛星" }, orbit: "mixed" };
|
|
91
|
+
* console.log(row.names.ja);
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
export interface CatalogueRow {
|
|
95
|
+
/** `group` for a button's group, `satellite` for one named satellite. */
|
|
96
|
+
kind: "satellite" | "group";
|
|
97
|
+
/** The group's id, or the satellite's NORAD number as a string. */
|
|
98
|
+
id: string;
|
|
99
|
+
/** The NORAD catalogue number. Only a satellite has one. */
|
|
100
|
+
noradId?: number;
|
|
101
|
+
/**
|
|
102
|
+
* Names in both languages. `ja` is the short Japanese name where {@link SHORT_NAMES} has one, and otherwise the English name:
|
|
103
|
+
* a name such as Sentinel-2A is written the same way in Japanese. `reading` is hiragana for a Japanese name that is not already kana.
|
|
104
|
+
*/
|
|
105
|
+
names: {
|
|
106
|
+
en: string;
|
|
107
|
+
ja: string;
|
|
108
|
+
reading?: string;
|
|
109
|
+
};
|
|
110
|
+
/** The group's id. Only a satellite has one. */
|
|
111
|
+
group?: string;
|
|
112
|
+
orbit: OrbitKind;
|
|
113
|
+
/** Other names already written in the catalogue, such as HST for Hubble. Absent when there are none. */
|
|
114
|
+
aka?: readonly string[];
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Plain rows for every group and every catalogue satellite, for a page to index. Both languages are on every row: `lang` says which language the page is showing and does not drop the other, so one index serves either.
|
|
118
|
+
* A satellite's Japanese name comes from {@link SHORT_NAMES} where that has one, and is otherwise the English name.
|
|
119
|
+
*
|
|
120
|
+
* @param lang - `en` or `ja`, the language the page is showing. Omit it for the same rows.
|
|
121
|
+
* @returns The groups in their own order, then the satellites in catalogue order.
|
|
122
|
+
* @example
|
|
123
|
+
* ```ts
|
|
124
|
+
* import { catalogueRows } from "@johnmorrisdotca/chikyu-earth/satellites";
|
|
125
|
+
*
|
|
126
|
+
* const hubble = catalogueRows("ja").find((row) => row.noradId === 20580);
|
|
127
|
+
* console.log(hubble?.names.ja, hubble?.aka?.join(", "));
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
export declare function catalogueRows(lang?: "en" | "ja"): CatalogueRow[];
|
|
131
|
+
/**
|
|
132
|
+
* Find catalogue entries by name, group name, NORAD number, Japanese name or a group's Japanese label: "hubble", "hst", "25544", "weather" or "ハッブル".
|
|
133
|
+
* An English or numeric query ignores case, spaces and punctuation, as before. Kana and kanji are matched as typed: only letter case and character width are folded (NFKC), and that same width fold is applied before the English comparison.
|
|
134
|
+
* A name that starts with the text comes before one that only has it inside.
|
|
85
135
|
*
|
|
86
136
|
* @param text - What the reader typed.
|
|
87
137
|
* @param limit - The most entries to give back (8 by default).
|
|
@@ -91,6 +141,7 @@ export declare const CATALOGUE: readonly CatalogueEntry[];
|
|
|
91
141
|
* import { findInCatalogue } from "@johnmorrisdotca/chikyu-earth/satellites";
|
|
92
142
|
*
|
|
93
143
|
* console.log(findInCatalogue("sentinel 2").map((entry) => entry.name));
|
|
144
|
+
* console.log(findInCatalogue("ハッブル").map((entry) => entry.name));
|
|
94
145
|
* ```
|
|
95
146
|
*/
|
|
96
147
|
export declare function findInCatalogue(text: string, limit?: number): CatalogueEntry[];
|