@azohra/meteo.station 0.3.1 → 0.4.2
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/dist/client/climatology.d.ts +27 -0
- package/dist/client/climatology.js +83 -0
- package/dist/client/history.d.ts +53 -0
- package/dist/client/history.js +114 -0
- package/dist/client/index.d.ts +3 -1
- package/dist/client/index.js +3 -1
- package/dist/client/live.js +15 -0
- package/dist/climatology.d.ts +61 -0
- package/dist/climatology.js +208 -0
- package/dist/contract-climatology.d.ts +69 -0
- package/dist/contract-climatology.js +50 -0
- package/dist/contract.d.ts +234 -1
- package/dist/contract.js +52 -4
- package/dist/derive.d.ts +23 -1
- package/dist/derive.js +43 -4
- package/dist/display.d.ts +4 -0
- package/dist/display.js +2 -1
- package/dist/elements/elements/AirExtremesElement.d.ts +8 -0
- package/dist/elements/elements/AirExtremesElement.js +33 -0
- package/dist/elements/elements/ClimatologyDailyPatternElement.d.ts +15 -0
- package/dist/elements/elements/ClimatologyDailyPatternElement.js +84 -0
- package/dist/elements/elements/ClimatologyRoseElement.d.ts +14 -0
- package/dist/elements/elements/ClimatologyRoseElement.js +51 -0
- package/dist/elements/elements/CompassFanElement.d.ts +14 -0
- package/dist/elements/elements/CompassFanElement.js +92 -0
- package/dist/elements/elements/DailyPatternElement.d.ts +1 -0
- package/dist/elements/elements/DailyPatternElement.js +20 -12
- package/dist/elements/elements/DialElement.js +14 -3
- package/dist/elements/elements/FavorableShareElement.d.ts +14 -0
- package/dist/elements/elements/FavorableShareElement.js +47 -0
- package/dist/elements/elements/RecentSummariesElement.d.ts +14 -0
- package/dist/elements/elements/RecentSummariesElement.js +54 -0
- package/dist/elements/elements/StationFeedElement.d.ts +3 -0
- package/dist/elements/elements/StationFeedElement.js +13 -2
- package/dist/elements/elements/WindHistoryChartElement.js +16 -3
- package/dist/elements/elements/WindRoseElement.d.ts +1 -3
- package/dist/elements/elements/WindRoseElement.js +60 -62
- package/dist/elements/elements/atoms.js +3 -3
- package/dist/elements/index.d.ts +13 -1
- package/dist/elements/index.js +15 -3
- package/dist/elements/lib/ambient.d.ts +2 -0
- package/dist/elements/lib/attributes.js +24 -1
- package/dist/elements/lib/base.d.ts +3 -0
- package/dist/elements/lib/base.js +14 -2
- package/dist/endpoints.d.ts +7 -1
- package/dist/endpoints.js +13 -1
- package/dist/geometry.d.ts +22 -3
- package/dist/geometry.js +41 -5
- package/dist/index.d.ts +8 -6
- package/dist/index.js +8 -6
- package/dist/instruments.d.ts +7 -5
- package/dist/instruments.js +20 -7
- package/dist/merge-current.js +2 -1
- package/dist/react/components/AirExtremes.d.ts +16 -0
- package/dist/react/components/AirExtremes.js +38 -0
- package/dist/react/components/ClimatologyDailyPattern.d.ts +20 -0
- package/dist/react/components/ClimatologyDailyPattern.js +59 -0
- package/dist/react/components/ClimatologyRose.d.ts +18 -0
- package/dist/react/components/ClimatologyRose.js +45 -0
- package/dist/react/components/CompassFan.d.ts +17 -0
- package/dist/react/components/CompassFan.js +93 -0
- package/dist/react/components/DailyPattern.d.ts +4 -1
- package/dist/react/components/DailyPattern.js +13 -6
- package/dist/react/components/Dial.d.ts +3 -1
- package/dist/react/components/Dial.js +13 -2
- package/dist/react/components/FavorableShare.d.ts +14 -0
- package/dist/react/components/FavorableShare.js +43 -0
- package/dist/react/components/RecentSummaries.d.ts +19 -0
- package/dist/react/components/RecentSummaries.js +65 -0
- package/dist/react/components/StationFeedProvider.d.ts +4 -1
- package/dist/react/components/StationFeedProvider.js +5 -3
- package/dist/react/components/WindHistoryChart.d.ts +6 -1
- package/dist/react/components/WindHistoryChart.js +18 -3
- package/dist/react/components/WindRose.d.ts +4 -2
- package/dist/react/components/WindRose.js +80 -71
- package/dist/react/components/WindSampleStrip.d.ts +3 -1
- package/dist/react/components/WindSampleStrip.js +6 -3
- package/dist/react/components/atoms.d.ts +4 -1
- package/dist/react/components/atoms.js +6 -3
- package/dist/react/hooks/useStationClimatology.d.ts +18 -0
- package/dist/react/hooks/useStationClimatology.js +25 -0
- package/dist/react/index.d.ts +10 -3
- package/dist/react/index.js +9 -2
- package/dist/scene/air-extremes.d.ts +2 -0
- package/dist/scene/air-extremes.js +42 -0
- package/dist/scene/atoms.d.ts +2 -1
- package/dist/scene/atoms.js +6 -4
- package/dist/scene/climatology-pattern.d.ts +6 -0
- package/dist/scene/climatology-pattern.js +35 -0
- package/dist/scene/climatology-rose.d.ts +5 -0
- package/dist/scene/climatology-rose.js +49 -0
- package/dist/scene/compass-fan.d.ts +3 -0
- package/dist/scene/compass-fan.js +115 -0
- package/dist/scene/daily-pattern.d.ts +1 -0
- package/dist/scene/daily-pattern.js +20 -6
- package/dist/scene/dial.d.ts +1 -0
- package/dist/scene/dial.js +16 -3
- package/dist/scene/favorable-share.d.ts +3 -0
- package/dist/scene/favorable-share.js +41 -0
- package/dist/scene/index.d.ts +9 -3
- package/dist/scene/recent-summaries.d.ts +4 -0
- package/dist/scene/recent-summaries.js +75 -0
- package/dist/scene/rose.d.ts +2 -1
- package/dist/scene/rose.js +18 -3
- package/dist/scene/sample-strip.d.ts +1 -0
- package/dist/scene/sample-strip.js +1 -1
- package/dist/scene/wind-history.d.ts +1 -0
- package/dist/scene/wind-history.js +4 -3
- package/dist/scene/wind-plot.d.ts +1 -0
- package/dist/scene/wind-plot.js +30 -3
- package/dist/server/adapter.d.ts +2 -1
- package/dist/server/adapter.js +2 -1
- package/dist/server/adapters/windnerd-climatology.d.ts +33 -0
- package/dist/server/adapters/windnerd-climatology.js +81 -0
- package/dist/server/adapters/windnerd-live.js +21 -13
- package/dist/server/adapters/windnerd.d.ts +31 -4
- package/dist/server/adapters/windnerd.js +197 -19
- package/dist/server/feed.d.ts +44 -2
- package/dist/server/feed.js +63 -2
- package/dist/server/handler.d.ts +11 -1
- package/dist/server/handler.js +83 -2
- package/dist/server/index.d.ts +4 -3
- package/dist/server/index.js +4 -3
- package/dist/strings.d.ts +12 -0
- package/dist/strings.js +12 -0
- package/package.json +2 -2
- package/schema/example-climatology.json +86 -0
- package/schema/example-history.json +38 -0
- package/schema/stationclimatology.schema.json +195 -0
- package/schema/stationcurrent.schema.json +173 -0
- package/schema/stationfeed.schema.json +173 -0
- package/schema/stationhistory.schema.json +186 -0
- package/schema/stationlive.schema.json +202 -0
- package/styles.css +215 -0
package/dist/derive.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { KMH_PER_MPS, degreesToRadians, normalizeDegrees } from "@azohra/meteo.core";
|
|
1
|
+
import { KMH_PER_MPS, degreesToRadians, normalizeDegrees, solarEventsForDate } from "@azohra/meteo.core";
|
|
2
2
|
//#region src/derive.ts
|
|
3
3
|
const CALM_THRESHOLD_MPS = .5;
|
|
4
4
|
function isCalm(speedMps) {
|
|
@@ -97,7 +97,11 @@ function seaLevelPressureHpa(stationPressureHpa, elevationM, temperatureC = 15)
|
|
|
97
97
|
const factor = 1 - .0065 * elevationM / (temperature + .0065 * elevationM + 273.15);
|
|
98
98
|
return stationPressureHpa * Math.pow(factor, -5.257);
|
|
99
99
|
}
|
|
100
|
-
|
|
100
|
+
/** The signed sea-level pressure change over the trailing window, hPa —
|
|
101
|
+
* the number behind the tendency word. The reference is the carried point
|
|
102
|
+
* nearest the window's start, and a record covering under 60% of the
|
|
103
|
+
* window returns null rather than a delta over a shorter span. */
|
|
104
|
+
function pressureDeltaHpa(points, { windowHours = 3 } = {}) {
|
|
101
105
|
const carrying = points.filter((point) => point.seaLevelPressureHpa != null);
|
|
102
106
|
const last = carrying[carrying.length - 1];
|
|
103
107
|
if (!last) return null;
|
|
@@ -105,11 +109,46 @@ function pressureTendency(points, { windowHours = 3, thresholdHpa = 1.5 } = {})
|
|
|
105
109
|
let reference = null;
|
|
106
110
|
for (const point of carrying) if (reference == null || Math.abs(Date.parse(point.observedAt) - targetMs) < Math.abs(Date.parse(reference.observedAt) - targetMs)) reference = point;
|
|
107
111
|
if (reference == null || Date.parse(last.observedAt) - Date.parse(reference.observedAt) < windowHours * 36e5 * .6) return null;
|
|
108
|
-
|
|
112
|
+
return last.seaLevelPressureHpa - reference.seaLevelPressureHpa;
|
|
113
|
+
}
|
|
114
|
+
function pressureTendency(points, { windowHours = 3, thresholdHpa = 1.5 } = {}) {
|
|
115
|
+
const delta = pressureDeltaHpa(points, { windowHours });
|
|
116
|
+
if (delta == null) return null;
|
|
109
117
|
if (delta >= thresholdHpa) return "rising";
|
|
110
118
|
if (delta <= -thresholdHpa) return "falling";
|
|
111
119
|
return "steady";
|
|
112
120
|
}
|
|
121
|
+
/** The lowest temperature of the most recent completed night — the previous
|
|
122
|
+
* sunset to the latest sunrise, from real astronomy. Null without
|
|
123
|
+
* coordinates (never a guessed night), under a polar sky, or when no
|
|
124
|
+
* carried temperature falls inside the window. */
|
|
125
|
+
function lastNightLowC(points, latitude, longitude, nowMs) {
|
|
126
|
+
if (latitude == null || longitude == null) return null;
|
|
127
|
+
const dayMs = 864e5;
|
|
128
|
+
const dateKey = (ms) => new Date(ms).toISOString().slice(0, 10);
|
|
129
|
+
for (let dayStart = Math.floor(nowMs / dayMs) * dayMs; dayStart >= nowMs - 3 * dayMs; dayStart -= dayMs) {
|
|
130
|
+
const today = solarEventsForDate(dateKey(dayStart), latitude, longitude);
|
|
131
|
+
if (today == null) return null;
|
|
132
|
+
if (today.sunrise.getTime() > nowMs) continue;
|
|
133
|
+
const yesterday = solarEventsForDate(dateKey(dayStart - dayMs), latitude, longitude);
|
|
134
|
+
if (yesterday == null) return null;
|
|
135
|
+
const fromMs = yesterday.sunset.getTime();
|
|
136
|
+
const toMs = today.sunrise.getTime();
|
|
137
|
+
let lowC = null;
|
|
138
|
+
for (const point of points) {
|
|
139
|
+
if (point.temperatureC == null) continue;
|
|
140
|
+
const observedMs = Date.parse(point.observedAt);
|
|
141
|
+
if (observedMs < fromMs || observedMs > toMs) continue;
|
|
142
|
+
lowC = lowC == null ? point.temperatureC : Math.min(lowC, point.temperatureC);
|
|
143
|
+
}
|
|
144
|
+
return lowC == null ? null : {
|
|
145
|
+
lowC,
|
|
146
|
+
fromMs,
|
|
147
|
+
toMs
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
113
152
|
const DEFAULT_FRESHNESS_THRESHOLDS = {
|
|
114
153
|
currentForMs: 10 * 6e4,
|
|
115
154
|
staleAfterMs: 45 * 6e4
|
|
@@ -131,4 +170,4 @@ function freshness(input, thresholds = DEFAULT_FRESHNESS_THRESHOLDS) {
|
|
|
131
170
|
return "stale";
|
|
132
171
|
}
|
|
133
172
|
//#endregion
|
|
134
|
-
export { CALM_THRESHOLD_MPS, COMPASS_POINTS, DEFAULT_FRESHNESS_THRESHOLDS, KMH_PER_MPS, SPEED_UNITS, compassDirection, freshness, isCalm, normalizeDegrees, periodSummary, pressureTendency, radians, seaLevelPressureHpa, speedFromMps, speedToMps, speedUnitLabel, stationFreshnessThresholds, thresholdsToMps };
|
|
173
|
+
export { CALM_THRESHOLD_MPS, COMPASS_POINTS, DEFAULT_FRESHNESS_THRESHOLDS, KMH_PER_MPS, SPEED_UNITS, compassDirection, freshness, isCalm, lastNightLowC, normalizeDegrees, periodSummary, pressureDeltaHpa, pressureTendency, radians, seaLevelPressureHpa, speedFromMps, speedToMps, speedUnitLabel, stationFreshnessThresholds, thresholdsToMps };
|
package/dist/display.d.ts
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
import { Station, StationFeed } from "./contract.js";
|
|
2
2
|
import { SpeedThresholds, SpeedUnit } from "./derive.js";
|
|
3
3
|
import { FormatTime, StationStringOverrides, StationStrings } from "./strings.js";
|
|
4
|
+
import { FavorableDirection } from "./instruments.js";
|
|
4
5
|
//#region src/display.d.ts
|
|
5
6
|
type DisplayDefaults = {
|
|
6
7
|
strings?: StationStringOverrides | undefined;
|
|
7
8
|
unit?: SpeedUnit | undefined;
|
|
8
9
|
formatTime?: FormatTime | undefined;
|
|
9
10
|
thresholds?: SpeedThresholds | undefined;
|
|
11
|
+
favorableDirections?: FavorableDirection[] | undefined;
|
|
10
12
|
};
|
|
11
13
|
type DisplayProps = {
|
|
12
14
|
strings?: StationStringOverrides | undefined;
|
|
13
15
|
unit?: SpeedUnit | undefined;
|
|
14
16
|
formatTime?: FormatTime | undefined;
|
|
15
17
|
thresholds?: SpeedThresholds | null | undefined;
|
|
18
|
+
favorableDirections?: FavorableDirection[] | null | undefined;
|
|
16
19
|
};
|
|
17
20
|
type ResolvedDisplay = {
|
|
18
21
|
strings: StationStringOverrides | undefined;
|
|
@@ -20,6 +23,7 @@ type ResolvedDisplay = {
|
|
|
20
23
|
unit: SpeedUnit;
|
|
21
24
|
formatTime: FormatTime;
|
|
22
25
|
thresholds: SpeedThresholds | undefined;
|
|
26
|
+
favorableDirections: FavorableDirection[] | undefined;
|
|
23
27
|
};
|
|
24
28
|
declare function resolveDisplay(defaults: DisplayDefaults | null | undefined, props: DisplayProps): ResolvedDisplay;
|
|
25
29
|
declare function resolveStation(feed: StationFeed | null | undefined, stationId: string | undefined): Station | null;
|
package/dist/display.js
CHANGED
|
@@ -7,7 +7,8 @@ function resolveDisplay(defaults, props) {
|
|
|
7
7
|
words: resolveStrings(strings),
|
|
8
8
|
unit: props.unit ?? defaults?.unit ?? "kmh",
|
|
9
9
|
formatTime: props.formatTime ?? defaults?.formatTime ?? defaultFormatTime,
|
|
10
|
-
thresholds: props.thresholds === void 0 ? defaults?.thresholds : props.thresholds ?? void 0
|
|
10
|
+
thresholds: props.thresholds === void 0 ? defaults?.thresholds : props.thresholds ?? void 0,
|
|
11
|
+
favorableDirections: props.favorableDirections === void 0 ? defaults?.favorableDirections : props.favorableDirections ?? void 0
|
|
11
12
|
};
|
|
12
13
|
}
|
|
13
14
|
function resolveStation(feed, stationId) {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { MeteoStationElement } from "../lib/base.js";
|
|
2
|
+
//#region src/elements/elements/AirExtremesElement.d.ts
|
|
3
|
+
declare class AirExtremesElement extends MeteoStationElement {
|
|
4
|
+
static readonly observedAttributes: string[];
|
|
5
|
+
protected render(): void;
|
|
6
|
+
}
|
|
7
|
+
//#endregion
|
|
8
|
+
export { AirExtremesElement };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { resolveStation } from "../../display.js";
|
|
2
|
+
import { airExtremesGate, airExtremesScene } from "../../scene/air-extremes.js";
|
|
3
|
+
import { MeteoStationElement } from "../lib/base.js";
|
|
4
|
+
import { h } from "../lib/h.js";
|
|
5
|
+
//#region src/elements/elements/AirExtremesElement.ts
|
|
6
|
+
var AirExtremesElement = class extends MeteoStationElement {
|
|
7
|
+
static observedAttributes = ["now-ms", "station-id"];
|
|
8
|
+
render() {
|
|
9
|
+
const station = this.station ?? resolveStation(this.ambient()?.feed ?? null, this.getAttribute("station-id") ?? void 0) ?? void 0;
|
|
10
|
+
const { words } = this.display();
|
|
11
|
+
const gate = airExtremesGate(station);
|
|
12
|
+
if (gate.kind === "hidden") {
|
|
13
|
+
this.replaceChildren();
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const nowAttribute = Number(this.getAttribute("now-ms"));
|
|
17
|
+
const scene = airExtremesScene({
|
|
18
|
+
nowMs: Number.isFinite(nowAttribute) && nowAttribute > 0 ? nowAttribute : Date.now(),
|
|
19
|
+
station: gate.station,
|
|
20
|
+
words
|
|
21
|
+
});
|
|
22
|
+
if (scene == null) {
|
|
23
|
+
this.replaceChildren();
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
this.replaceChildren(h("dl", {
|
|
27
|
+
"aria-label": scene.ariaLabel,
|
|
28
|
+
class: scene.className
|
|
29
|
+
}, scene.tiles.map((tile) => h("div", { class: tile.className }, h("dt", { class: "meteo-microlabel" }, tile.label), h("dd", { class: "meteo-air-extremes-value" }, tile.value)))));
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
//#endregion
|
|
33
|
+
export { AirExtremesElement };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { StationClimatology } from "../../contract-climatology.js";
|
|
2
|
+
import "../../index.js";
|
|
3
|
+
import { MeteoStationElement } from "../lib/base.js";
|
|
4
|
+
//#region src/elements/elements/ClimatologyDailyPatternElement.d.ts
|
|
5
|
+
declare class ClimatologyDailyPatternElement extends MeteoStationElement {
|
|
6
|
+
#private;
|
|
7
|
+
static readonly observedAttributes: string[];
|
|
8
|
+
constructor();
|
|
9
|
+
get document(): StationClimatology | null | undefined;
|
|
10
|
+
set document(value: StationClimatology | null | undefined);
|
|
11
|
+
protected disconnected(): void;
|
|
12
|
+
protected render(): void;
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { ClimatologyDailyPatternElement };
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { measuredChartWidth } from "../../geometry.js";
|
|
2
|
+
import { CLIMATOLOGY_PATTERN_CLASS, climatologyPatternGate, climatologyPatternScene } from "../../scene/climatology-pattern.js";
|
|
3
|
+
import { numberAttribute, parseMonthsAttribute } from "../lib/attributes.js";
|
|
4
|
+
import { MeteoStationElement } from "../lib/base.js";
|
|
5
|
+
import { h } from "../lib/h.js";
|
|
6
|
+
import { dailyPatternSceneDom } from "./DailyPatternElement.js";
|
|
7
|
+
//#region src/elements/elements/ClimatologyDailyPatternElement.ts
|
|
8
|
+
let hatchCounter = 0;
|
|
9
|
+
var ClimatologyDailyPatternElement = class extends MeteoStationElement {
|
|
10
|
+
static observedAttributes = [
|
|
11
|
+
"favorable-directions",
|
|
12
|
+
"months",
|
|
13
|
+
"plot-height",
|
|
14
|
+
"station-name",
|
|
15
|
+
"thresholds",
|
|
16
|
+
"unit"
|
|
17
|
+
];
|
|
18
|
+
#document;
|
|
19
|
+
#width = null;
|
|
20
|
+
#observer = null;
|
|
21
|
+
constructor() {
|
|
22
|
+
super();
|
|
23
|
+
for (const name of ["document"]) this.upgradeProperty(name);
|
|
24
|
+
}
|
|
25
|
+
get document() {
|
|
26
|
+
return this.#document;
|
|
27
|
+
}
|
|
28
|
+
set document(value) {
|
|
29
|
+
this.#document = value;
|
|
30
|
+
this.requestRender();
|
|
31
|
+
}
|
|
32
|
+
disconnected() {
|
|
33
|
+
this.#observer?.disconnect();
|
|
34
|
+
this.#observer = null;
|
|
35
|
+
}
|
|
36
|
+
render() {
|
|
37
|
+
const { favorableDirections, thresholds, unit, words } = this.display();
|
|
38
|
+
const gate = climatologyPatternGate(this.#document, words);
|
|
39
|
+
if (gate.kind === "note") {
|
|
40
|
+
this.#observer?.disconnect();
|
|
41
|
+
this.#observer = null;
|
|
42
|
+
this.replaceChildren(h("div", {
|
|
43
|
+
class: gate.className,
|
|
44
|
+
role: "note"
|
|
45
|
+
}, gate.text));
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const wrap = h("div", { class: CLIMATOLOGY_PATTERN_CLASS });
|
|
49
|
+
this.replaceChildren(wrap);
|
|
50
|
+
this.#observe(wrap);
|
|
51
|
+
if (this.#width == null) return;
|
|
52
|
+
const { caption, svg } = dailyPatternSceneDom(climatologyPatternScene({
|
|
53
|
+
document: gate.document,
|
|
54
|
+
favorableDirections,
|
|
55
|
+
filters: { months: parseMonthsAttribute(this.getAttribute("months")) },
|
|
56
|
+
hatchId: `meteo-climatology-hatch-e${++hatchCounter}`,
|
|
57
|
+
plotHeight: numberAttribute(this.getAttribute("plot-height")),
|
|
58
|
+
stationName: this.getAttribute("station-name") ?? void 0,
|
|
59
|
+
thresholds,
|
|
60
|
+
unit,
|
|
61
|
+
width: this.#width,
|
|
62
|
+
words
|
|
63
|
+
}));
|
|
64
|
+
wrap.replaceChildren(caption, svg);
|
|
65
|
+
}
|
|
66
|
+
#observe(wrap) {
|
|
67
|
+
this.#observer?.disconnect();
|
|
68
|
+
if (typeof ResizeObserver === "undefined") {
|
|
69
|
+
this.#width = 360;
|
|
70
|
+
this.#observer = null;
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
this.#observer = new ResizeObserver((entries) => {
|
|
74
|
+
const width = measuredChartWidth(entries[0]?.contentRect.width ?? 0);
|
|
75
|
+
if (width !== this.#width) {
|
|
76
|
+
this.#width = width;
|
|
77
|
+
this.requestRender();
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
this.#observer.observe(wrap);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
//#endregion
|
|
84
|
+
export { ClimatologyDailyPatternElement };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { StationClimatology } from "../../contract-climatology.js";
|
|
2
|
+
import "../../index.js";
|
|
3
|
+
import { MeteoStationElement } from "../lib/base.js";
|
|
4
|
+
//#region src/elements/elements/ClimatologyRoseElement.d.ts
|
|
5
|
+
declare class ClimatologyRoseElement extends MeteoStationElement {
|
|
6
|
+
#private;
|
|
7
|
+
static readonly observedAttributes: string[];
|
|
8
|
+
constructor();
|
|
9
|
+
get document(): StationClimatology | null | undefined;
|
|
10
|
+
set document(value: StationClimatology | null | undefined);
|
|
11
|
+
protected render(): void;
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { ClimatologyRoseElement };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { climatologyRoseGate, climatologyRoseScene } from "../../scene/climatology-rose.js";
|
|
2
|
+
import { parseMonthsAttribute, parseSlotsAttribute } from "../lib/attributes.js";
|
|
3
|
+
import { MeteoStationElement } from "../lib/base.js";
|
|
4
|
+
import { h } from "../lib/h.js";
|
|
5
|
+
import { windRoseSceneDom } from "./WindRoseElement.js";
|
|
6
|
+
//#region src/elements/elements/ClimatologyRoseElement.ts
|
|
7
|
+
var ClimatologyRoseElement = class extends MeteoStationElement {
|
|
8
|
+
static observedAttributes = [
|
|
9
|
+
"favorable-directions",
|
|
10
|
+
"months",
|
|
11
|
+
"slots",
|
|
12
|
+
"station-name"
|
|
13
|
+
];
|
|
14
|
+
#document;
|
|
15
|
+
constructor() {
|
|
16
|
+
super();
|
|
17
|
+
for (const name of ["document"]) this.upgradeProperty(name);
|
|
18
|
+
}
|
|
19
|
+
get document() {
|
|
20
|
+
return this.#document;
|
|
21
|
+
}
|
|
22
|
+
set document(value) {
|
|
23
|
+
this.#document = value;
|
|
24
|
+
this.requestRender();
|
|
25
|
+
}
|
|
26
|
+
render() {
|
|
27
|
+
const { favorableDirections, words } = this.display();
|
|
28
|
+
const gate = climatologyRoseGate(this.#document, words);
|
|
29
|
+
if (gate.kind === "note") {
|
|
30
|
+
this.replaceChildren(h("div", {
|
|
31
|
+
class: gate.className,
|
|
32
|
+
role: "note"
|
|
33
|
+
}, gate.text));
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const filters = {
|
|
37
|
+
months: parseMonthsAttribute(this.getAttribute("months")),
|
|
38
|
+
slots: parseSlotsAttribute(this.getAttribute("slots"))
|
|
39
|
+
};
|
|
40
|
+
const scene = climatologyRoseScene({
|
|
41
|
+
document: gate.document,
|
|
42
|
+
favorableDirections,
|
|
43
|
+
filters,
|
|
44
|
+
stationName: this.getAttribute("station-name") ?? void 0,
|
|
45
|
+
words
|
|
46
|
+
});
|
|
47
|
+
this.replaceChildren(h("div", { class: scene.className }, windRoseSceneDom(scene.rose, ...scene.captions.map((caption) => h("p", { class: caption.className }, caption.text)))));
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
//#endregion
|
|
51
|
+
export { ClimatologyRoseElement };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { LiveSamples } from "../../contract.js";
|
|
2
|
+
import "../../index.js";
|
|
3
|
+
import { MeteoStationElement } from "../lib/base.js";
|
|
4
|
+
//#region src/elements/elements/CompassFanElement.d.ts
|
|
5
|
+
declare class CompassFanElement extends MeteoStationElement {
|
|
6
|
+
#private;
|
|
7
|
+
static readonly observedAttributes: string[];
|
|
8
|
+
constructor();
|
|
9
|
+
get samples(): LiveSamples | null | undefined;
|
|
10
|
+
set samples(value: LiveSamples | null | undefined);
|
|
11
|
+
protected render(): void;
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { CompassFanElement };
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { resolveStation } from "../../display.js";
|
|
2
|
+
import { compassFanGate, compassFanScene, compassFanSource } from "../../scene/compass-fan.js";
|
|
3
|
+
import { MeteoStationElement } from "../lib/base.js";
|
|
4
|
+
import { h, hs } from "../lib/h.js";
|
|
5
|
+
//#region src/elements/elements/CompassFanElement.ts
|
|
6
|
+
var CompassFanElement = class extends MeteoStationElement {
|
|
7
|
+
static observedAttributes = ["favorable-directions", "station-id"];
|
|
8
|
+
#samples;
|
|
9
|
+
constructor() {
|
|
10
|
+
super();
|
|
11
|
+
for (const name of ["samples"]) this.upgradeProperty(name);
|
|
12
|
+
}
|
|
13
|
+
get samples() {
|
|
14
|
+
return this.#samples;
|
|
15
|
+
}
|
|
16
|
+
set samples(value) {
|
|
17
|
+
this.#samples = value;
|
|
18
|
+
this.requestRender();
|
|
19
|
+
}
|
|
20
|
+
render() {
|
|
21
|
+
const station = this.station ?? (this.#samples == null ? resolveStation(this.ambient()?.feed ?? null, this.getAttribute("station-id") ?? void 0) ?? void 0 : void 0);
|
|
22
|
+
const { favorableDirections, words } = this.display();
|
|
23
|
+
const gate = compassFanGate(compassFanSource(this.#samples, station), station, words);
|
|
24
|
+
if (gate.kind === "hidden") {
|
|
25
|
+
this.replaceChildren();
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (gate.kind === "note") {
|
|
29
|
+
this.replaceChildren(h("div", {
|
|
30
|
+
class: gate.className,
|
|
31
|
+
role: "note"
|
|
32
|
+
}, gate.text));
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const scene = compassFanScene({
|
|
36
|
+
favorableDirections,
|
|
37
|
+
samples: gate.samples,
|
|
38
|
+
stationName: station?.name,
|
|
39
|
+
words
|
|
40
|
+
});
|
|
41
|
+
this.replaceChildren(hs("svg", {
|
|
42
|
+
"aria-label": scene.svg.ariaLabel,
|
|
43
|
+
class: scene.svg.className,
|
|
44
|
+
height: scene.svg.height,
|
|
45
|
+
role: "img",
|
|
46
|
+
viewBox: scene.svg.viewBox,
|
|
47
|
+
width: scene.svg.width
|
|
48
|
+
}, hs("circle", {
|
|
49
|
+
class: scene.ring.className,
|
|
50
|
+
cx: scene.ring.cx,
|
|
51
|
+
cy: scene.ring.cy,
|
|
52
|
+
r: scene.ring.r
|
|
53
|
+
}), scene.verdictRing != null ? [hs("circle", {
|
|
54
|
+
class: scene.verdictRing.unfavorable.className,
|
|
55
|
+
cx: scene.verdictRing.unfavorable.cx,
|
|
56
|
+
cy: scene.verdictRing.unfavorable.cy,
|
|
57
|
+
r: scene.verdictRing.unfavorable.r
|
|
58
|
+
}), scene.verdictRing.favorable.map((arc) => hs("path", {
|
|
59
|
+
class: arc.className,
|
|
60
|
+
d: arc.d
|
|
61
|
+
}))] : null, scene.ticks.map((tick) => hs("line", {
|
|
62
|
+
class: tick.className,
|
|
63
|
+
x1: tick.x1,
|
|
64
|
+
x2: tick.x2,
|
|
65
|
+
y1: tick.y1,
|
|
66
|
+
y2: tick.y2
|
|
67
|
+
})), scene.letters.map((letter) => hs("text", {
|
|
68
|
+
class: letter.className,
|
|
69
|
+
"text-anchor": letter.anchor,
|
|
70
|
+
x: letter.x,
|
|
71
|
+
y: letter.y
|
|
72
|
+
}, letter.text)), scene.ghosts.map((ghost) => hs("path", {
|
|
73
|
+
class: ghost.className,
|
|
74
|
+
d: ghost.d
|
|
75
|
+
})), scene.needle != null && hs("g", { class: scene.needle.className }, hs("polygon", {
|
|
76
|
+
class: scene.needle.blade.className,
|
|
77
|
+
points: scene.needle.blade.points
|
|
78
|
+
}), hs("circle", {
|
|
79
|
+
class: scene.needle.counterweight.className,
|
|
80
|
+
cx: scene.needle.counterweight.cx,
|
|
81
|
+
cy: scene.needle.counterweight.cy,
|
|
82
|
+
r: scene.needle.counterweight.r
|
|
83
|
+
})), hs("circle", {
|
|
84
|
+
class: scene.hub.className,
|
|
85
|
+
cx: scene.hub.cx,
|
|
86
|
+
cy: scene.hub.cy,
|
|
87
|
+
r: scene.hub.r
|
|
88
|
+
})));
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
//#endregion
|
|
92
|
+
export { CompassFanElement };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { HistoryPoint } from "../../contract.js";
|
|
2
2
|
import "../../index.js";
|
|
3
3
|
import { MeteoStationElement } from "../lib/base.js";
|
|
4
|
+
import "../../scene/index.js";
|
|
4
5
|
//#region src/elements/elements/DailyPatternElement.d.ts
|
|
5
6
|
declare class DailyPatternElement extends MeteoStationElement {
|
|
6
7
|
#private;
|
|
@@ -8,6 +8,7 @@ import { h, hs } from "../lib/h.js";
|
|
|
8
8
|
let hatchCounter = 0;
|
|
9
9
|
var DailyPatternElement = class extends MeteoStationElement {
|
|
10
10
|
static observedAttributes = [
|
|
11
|
+
"favorable-directions",
|
|
11
12
|
"plot-height",
|
|
12
13
|
"slot-minutes",
|
|
13
14
|
"station-id",
|
|
@@ -35,7 +36,7 @@ var DailyPatternElement = class extends MeteoStationElement {
|
|
|
35
36
|
}
|
|
36
37
|
render() {
|
|
37
38
|
const station = this.station ?? (this.#points == null ? resolveStation(this.ambient()?.feed ?? null, this.getAttribute("station-id") ?? void 0) ?? void 0 : void 0);
|
|
38
|
-
const { thresholds, unit, words } = this.display();
|
|
39
|
+
const { favorableDirections, thresholds, unit, words } = this.display();
|
|
39
40
|
const { source, periodMinutes } = dailyPatternSource(this.#points, station);
|
|
40
41
|
const gate = dailyPatternGate(source, words);
|
|
41
42
|
if (gate.kind === "note") {
|
|
@@ -51,7 +52,7 @@ var DailyPatternElement = class extends MeteoStationElement {
|
|
|
51
52
|
this.replaceChildren(wrap);
|
|
52
53
|
this.#observe(wrap);
|
|
53
54
|
if (this.#width == null) return;
|
|
54
|
-
this.#buildChart(wrap, source, periodMinutes, thresholds, unit, words, this.#width, station?.name);
|
|
55
|
+
this.#buildChart(wrap, source, periodMinutes, thresholds, favorableDirections, unit, words, this.#width, station?.name);
|
|
55
56
|
}
|
|
56
57
|
#observe(wrap) {
|
|
57
58
|
this.#observer?.disconnect();
|
|
@@ -69,8 +70,9 @@ var DailyPatternElement = class extends MeteoStationElement {
|
|
|
69
70
|
});
|
|
70
71
|
this.#observer.observe(wrap);
|
|
71
72
|
}
|
|
72
|
-
#buildChart(wrap, points, periodMinutes, thresholds, unit, words, width, stationName) {
|
|
73
|
-
const
|
|
73
|
+
#buildChart(wrap, points, periodMinutes, thresholds, favorableDirections, unit, words, width, stationName) {
|
|
74
|
+
const { caption, svg } = dailyPatternSceneDom(dailyPatternScene({
|
|
75
|
+
favorableDirections,
|
|
74
76
|
hatchId: `meteo-daily-pattern-hatch-e${++hatchCounter}`,
|
|
75
77
|
periodMinutes,
|
|
76
78
|
plotHeight: numberAttribute(this.getAttribute("plot-height")),
|
|
@@ -82,9 +84,16 @@ var DailyPatternElement = class extends MeteoStationElement {
|
|
|
82
84
|
utcOffsetMinutes: numberAttribute(this.getAttribute("utc-offset-minutes")) ?? 0,
|
|
83
85
|
width,
|
|
84
86
|
words
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
|
|
87
|
+
}));
|
|
88
|
+
wrap.replaceChildren(caption, svg);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
/** One scene, one drawing — shared by the history-fed pattern above and the
|
|
92
|
+
* climatology-fed twin. */
|
|
93
|
+
function dailyPatternSceneDom(scene) {
|
|
94
|
+
return {
|
|
95
|
+
caption: h("output", { class: scene.caption.className }, scene.caption.text),
|
|
96
|
+
svg: hs("svg", {
|
|
88
97
|
"aria-label": scene.svg.ariaLabel,
|
|
89
98
|
class: scene.svg.className,
|
|
90
99
|
height: scene.svg.height,
|
|
@@ -191,9 +200,8 @@ var DailyPatternElement = class extends MeteoStationElement {
|
|
|
191
200
|
"text-anchor": tick.anchor,
|
|
192
201
|
x: tick.x,
|
|
193
202
|
y: tick.y
|
|
194
|
-
}, tick.text)))
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
};
|
|
203
|
+
}, tick.text)))
|
|
204
|
+
};
|
|
205
|
+
}
|
|
198
206
|
//#endregion
|
|
199
|
-
export { DailyPatternElement };
|
|
207
|
+
export { DailyPatternElement, dailyPatternSceneDom };
|
|
@@ -6,10 +6,11 @@ import { hs } from "../lib/h.js";
|
|
|
6
6
|
//#region src/elements/elements/DialElement.ts
|
|
7
7
|
let bezelCounter = 0;
|
|
8
8
|
function dialSvg(options) {
|
|
9
|
-
const { station, thresholds, unit, words, size = 160, calmWord = true } = options;
|
|
9
|
+
const { station, thresholds, favorableDirections, unit, words, size = 160, calmWord = true } = options;
|
|
10
10
|
const scene = dialScene({
|
|
11
11
|
bezelId: `meteo-bezel-e${++bezelCounter}`,
|
|
12
12
|
calmWord,
|
|
13
|
+
favorableDirections,
|
|
13
14
|
size,
|
|
14
15
|
station,
|
|
15
16
|
thresholds,
|
|
@@ -48,7 +49,15 @@ function dialSvg(options) {
|
|
|
48
49
|
cx: scene.ring.cx,
|
|
49
50
|
cy: scene.ring.cy,
|
|
50
51
|
r: scene.ring.r
|
|
51
|
-
}), scene.
|
|
52
|
+
}), scene.verdictRing != null ? [hs("circle", {
|
|
53
|
+
class: scene.verdictRing.unfavorable.className,
|
|
54
|
+
cx: scene.verdictRing.unfavorable.cx,
|
|
55
|
+
cy: scene.verdictRing.unfavorable.cy,
|
|
56
|
+
r: scene.verdictRing.unfavorable.r
|
|
57
|
+
}), scene.verdictRing.favorable.map((arc) => hs("path", {
|
|
58
|
+
class: arc.className,
|
|
59
|
+
d: arc.d
|
|
60
|
+
}))] : null, scene.arc != null && hs("path", {
|
|
52
61
|
class: scene.arc.className,
|
|
53
62
|
d: scene.arc.d
|
|
54
63
|
}), scene.ticks.map((tick) => hs("line", {
|
|
@@ -103,6 +112,7 @@ function dialSvg(options) {
|
|
|
103
112
|
}
|
|
104
113
|
var DialElement = class extends MeteoStationElement {
|
|
105
114
|
static observedAttributes = [
|
|
115
|
+
"favorable-directions",
|
|
106
116
|
"no-calm-word",
|
|
107
117
|
"received-at-ms",
|
|
108
118
|
"served-at",
|
|
@@ -113,10 +123,11 @@ var DialElement = class extends MeteoStationElement {
|
|
|
113
123
|
];
|
|
114
124
|
render() {
|
|
115
125
|
const station = this.requiredStation("meteo-dial");
|
|
116
|
-
const { thresholds, unit, words } = this.display();
|
|
126
|
+
const { favorableDirections, thresholds, unit, words } = this.display();
|
|
117
127
|
this.replaceChildren(dialSvg({
|
|
118
128
|
station,
|
|
119
129
|
thresholds,
|
|
130
|
+
favorableDirections,
|
|
120
131
|
unit,
|
|
121
132
|
words,
|
|
122
133
|
size: numberAttribute(this.getAttribute("size")) ?? 160,
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { HistoryPoint } from "../../contract.js";
|
|
2
|
+
import "../../index.js";
|
|
3
|
+
import { MeteoStationElement } from "../lib/base.js";
|
|
4
|
+
//#region src/elements/elements/FavorableShareElement.d.ts
|
|
5
|
+
declare class FavorableShareElement extends MeteoStationElement {
|
|
6
|
+
#private;
|
|
7
|
+
static readonly observedAttributes: string[];
|
|
8
|
+
constructor();
|
|
9
|
+
get points(): HistoryPoint[] | undefined;
|
|
10
|
+
set points(value: HistoryPoint[] | undefined);
|
|
11
|
+
protected render(): void;
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { FavorableShareElement };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { resolveStation } from "../../display.js";
|
|
2
|
+
import { favorableShareGate, favorableShareScene, favorableShareSource } from "../../scene/favorable-share.js";
|
|
3
|
+
import { MeteoStationElement } from "../lib/base.js";
|
|
4
|
+
import { h } from "../lib/h.js";
|
|
5
|
+
//#region src/elements/elements/FavorableShareElement.ts
|
|
6
|
+
var FavorableShareElement = class extends MeteoStationElement {
|
|
7
|
+
static observedAttributes = ["favorable-directions", "station-id"];
|
|
8
|
+
#points;
|
|
9
|
+
constructor() {
|
|
10
|
+
super();
|
|
11
|
+
for (const name of ["points"]) this.upgradeProperty(name);
|
|
12
|
+
}
|
|
13
|
+
get points() {
|
|
14
|
+
return this.#points;
|
|
15
|
+
}
|
|
16
|
+
set points(value) {
|
|
17
|
+
this.#points = value;
|
|
18
|
+
this.requestRender();
|
|
19
|
+
}
|
|
20
|
+
render() {
|
|
21
|
+
const station = this.station ?? (this.#points == null ? resolveStation(this.ambient()?.feed ?? null, this.getAttribute("station-id") ?? void 0) ?? void 0 : void 0);
|
|
22
|
+
const { favorableDirections, words } = this.display();
|
|
23
|
+
const gate = favorableShareGate(favorableShareSource(this.#points, station), favorableDirections, words);
|
|
24
|
+
if (gate.kind === "hidden") {
|
|
25
|
+
this.replaceChildren();
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (gate.kind === "note") {
|
|
29
|
+
this.replaceChildren(h("div", {
|
|
30
|
+
class: gate.className,
|
|
31
|
+
role: "note"
|
|
32
|
+
}, gate.text));
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const scene = favorableShareScene({
|
|
36
|
+
share: gate.share,
|
|
37
|
+
stationName: station?.name,
|
|
38
|
+
words
|
|
39
|
+
});
|
|
40
|
+
this.replaceChildren(h("div", {
|
|
41
|
+
"aria-label": scene.ariaLabel,
|
|
42
|
+
class: scene.className
|
|
43
|
+
}, h("span", { class: scene.label.className }, scene.label.text), " ", h("span", { class: scene.value.className }, scene.value.text)));
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
//#endregion
|
|
47
|
+
export { FavorableShareElement };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { RecentSummary } from "../../contract.js";
|
|
2
|
+
import "../../index.js";
|
|
3
|
+
import { MeteoStationElement } from "../lib/base.js";
|
|
4
|
+
//#region src/elements/elements/RecentSummariesElement.d.ts
|
|
5
|
+
declare class RecentSummariesElement extends MeteoStationElement {
|
|
6
|
+
#private;
|
|
7
|
+
static readonly observedAttributes: string[];
|
|
8
|
+
constructor();
|
|
9
|
+
get summaries(): RecentSummary[] | null | undefined;
|
|
10
|
+
set summaries(value: RecentSummary[] | null | undefined);
|
|
11
|
+
protected render(): void;
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { RecentSummariesElement };
|