@azohra/meteo.station 0.6.0 → 0.7.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/README.md +17 -17
- package/dist/connectivity.d.ts +2 -2
- package/dist/contract.d.ts +105 -105
- package/dist/derive.js +4 -4
- package/dist/elements/elements/AirExtremesElement.js +5 -18
- package/dist/elements/elements/AirMatrixElement.js +6 -31
- package/dist/elements/elements/ClimatologyDailyPatternElement.js +17 -12
- package/dist/elements/elements/ClimatologyRoseElement.js +5 -15
- package/dist/elements/elements/CompassFanElement.js +5 -64
- package/dist/elements/elements/CurrentConditionsElement.js +7 -26
- package/dist/elements/elements/DailyPatternElement.d.ts +0 -1
- package/dist/elements/elements/DailyPatternElement.js +6 -120
- package/dist/elements/elements/DialElement.js +3 -95
- package/dist/elements/elements/FavorableShareElement.js +6 -21
- package/dist/elements/elements/RecentSummariesElement.js +6 -23
- package/dist/elements/elements/SparklineElement.d.ts +0 -1
- package/dist/elements/elements/SparklineElement.js +4 -39
- package/dist/elements/elements/StationCardElement.js +4 -18
- package/dist/elements/elements/StationFeedElement.js +4 -2
- package/dist/elements/elements/StationStripElement.js +4 -18
- package/dist/elements/elements/StationTableElement.js +15 -51
- package/dist/elements/elements/TrendChartElement.js +21 -69
- package/dist/elements/elements/WindHistoryChartElement.js +23 -164
- package/dist/elements/elements/WindRoseElement.d.ts +0 -1
- package/dist/elements/elements/WindRoseElement.js +6 -70
- package/dist/elements/elements/atoms.d.ts +1 -1
- package/dist/elements/elements/atoms.js +11 -38
- package/dist/elements/index.js +3 -3
- package/dist/elements/lib/fragments.js +8 -37
- package/dist/elements/lib/h.js +1 -1
- package/dist/elements/lib/render.js +30 -0
- package/dist/geometry.js +2 -1
- package/dist/instruments.js +2 -2
- package/dist/react/components/AirExtremes.d.ts +1 -1
- package/dist/react/components/AirExtremes.js +5 -22
- package/dist/react/components/AirMatrix.js +10 -43
- package/dist/react/components/ClimatologyDailyPattern.d.ts +1 -1
- package/dist/react/components/ClimatologyDailyPattern.js +19 -13
- package/dist/react/components/ClimatologyRose.d.ts +1 -1
- package/dist/react/components/ClimatologyRose.js +11 -28
- package/dist/react/components/CompassFan.d.ts +1 -1
- package/dist/react/components/CompassFan.js +6 -73
- package/dist/react/components/CurrentConditions.d.ts +1 -1
- package/dist/react/components/CurrentConditions.js +11 -74
- package/dist/react/components/DailyPattern.d.ts +1 -3
- package/dist/react/components/DailyPattern.js +10 -149
- package/dist/react/components/Dial.d.ts +1 -1
- package/dist/react/components/Dial.js +5 -118
- package/dist/react/components/FavorableShare.d.ts +1 -1
- package/dist/react/components/FavorableShare.js +6 -27
- package/dist/react/components/FreshnessBadge.d.ts +1 -1
- package/dist/react/components/FreshnessBadge.js +5 -12
- package/dist/react/components/RecentSummaries.d.ts +1 -1
- package/dist/react/components/RecentSummaries.js +6 -44
- package/dist/react/components/SceneTree.js +38 -0
- package/dist/react/components/Sparkline.d.ts +1 -1
- package/dist/react/components/Sparkline.js +3 -39
- package/dist/react/components/StationCard.d.ts +2 -2
- package/dist/react/components/StationCard.js +5 -45
- package/dist/react/components/StationStrip.d.ts +1 -1
- package/dist/react/components/StationStrip.js +5 -60
- package/dist/react/components/StationTable.js +21 -75
- package/dist/react/components/TrendChart.js +8 -63
- package/dist/react/components/WindArrow.d.ts +1 -1
- package/dist/react/components/WindArrow.js +3 -15
- package/dist/react/components/WindHistoryChart.js +8 -182
- package/dist/react/components/WindRose.d.ts +1 -3
- package/dist/react/components/WindRose.js +6 -89
- package/dist/react/components/WindSampleStrip.js +8 -115
- package/dist/react/components/atoms.d.ts +5 -5
- package/dist/react/components/atoms.js +12 -48
- package/dist/react/hooks/useStationCurrent.js +3 -2
- package/dist/react/hooks/useStationFeed.js +3 -2
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.js +5 -5
- package/dist/react/lib/cells.js +4 -24
- package/dist/scene/air-extremes.js +12 -27
- package/dist/scene/air-matrix.js +45 -58
- package/dist/scene/card.js +14 -40
- package/dist/scene/cells.d.ts +4 -0
- package/dist/scene/cells.js +51 -0
- package/dist/scene/chart.js +2 -1
- package/dist/scene/climatology-pattern.d.ts +1 -2
- package/dist/scene/climatology-pattern.js +10 -11
- package/dist/scene/climatology-rose.d.ts +1 -2
- package/dist/scene/climatology-rose.js +14 -33
- package/dist/scene/compass-fan.js +28 -100
- package/dist/scene/current.d.ts +2 -1
- package/dist/scene/current.js +29 -56
- package/dist/scene/daily-pattern.d.ts +1 -3
- package/dist/scene/daily-pattern.js +20 -27
- package/dist/scene/dial-parts.d.ts +1 -0
- package/dist/scene/dial-parts.js +70 -0
- package/dist/scene/dial.d.ts +1 -2
- package/dist/scene/dial.js +48 -136
- package/dist/scene/favorable-share.js +16 -33
- package/dist/scene/glyphs.js +20 -16
- package/dist/scene/index.d.ts +5 -3
- package/dist/scene/node.js +19 -0
- package/dist/scene/recent-summaries.js +26 -63
- package/dist/scene/rose.js +89 -117
- package/dist/scene/sample-strip.d.ts +1 -2
- package/dist/scene/sample-strip.js +35 -36
- package/dist/scene/sparkline.js +31 -40
- package/dist/scene/strip.js +18 -57
- package/dist/scene/table.js +47 -69
- package/dist/scene/trend.d.ts +1 -2
- package/dist/scene/trend.js +29 -55
- package/dist/scene/wind-history.d.ts +1 -2
- package/dist/scene/wind-history.js +41 -51
- package/dist/scene/wind-plot.js +70 -140
- package/dist/server/adapters/campbell.d.ts +7 -7
- package/dist/server/adapters/campbell.js +1 -1
- package/dist/server/adapters/ecowitt.d.ts +8 -8
- package/dist/server/adapters/tempest.d.ts +6 -6
- package/dist/server/adapters/windnerd-climatology.js +4 -3
- package/dist/server/adapters/windnerd-live.js +3 -2
- package/dist/server/adapters/windnerd.d.ts +8 -8
- package/dist/server/adapters/windnerd.js +1 -1
- package/dist/server/config.d.ts +48 -48
- package/dist/server/hologram.js +2 -1
- package/package.json +6 -11
- package/schema/README.md +1 -1
- package/schema/stationclimatology.schema.json +64 -61
- package/schema/stationcurrent.schema.json +68 -156
- package/schema/stationfeed.schema.json +71 -163
- package/schema/stationhistory.schema.json +37 -46
- package/schema/stationlive.schema.json +221 -306
package/dist/scene/current.d.ts
CHANGED
package/dist/scene/current.js
CHANGED
|
@@ -1,66 +1,39 @@
|
|
|
1
1
|
import { compassDirection, isCalm } from "../derive.js";
|
|
2
2
|
import { roundSpeed, temperatureText, temperatureValue } from "../format.js";
|
|
3
|
+
import "../instruments.js";
|
|
4
|
+
import { el } from "./node.js";
|
|
5
|
+
import { freshnessBadgeNode, windArrowNode } from "./glyphs.js";
|
|
6
|
+
import { dialScene } from "./dial.js";
|
|
3
7
|
//#region src/scene/current.ts
|
|
4
8
|
function currentConditionsScene(input) {
|
|
5
|
-
const { formatTime, station, unit, words } = input;
|
|
9
|
+
const { bezelId, favorableDirections, formatTime, freshness, station, thresholds, unit, words } = input;
|
|
6
10
|
const reading = station.status === "ok" ? station.reading : null;
|
|
7
11
|
const calm = reading != null && isCalm(reading.windAvgMps);
|
|
8
12
|
const blowing = reading != null && !calm && reading.windDirectionDeg != null;
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
content: station.status === "unavailable" ? {
|
|
34
|
-
kind: "text",
|
|
35
|
-
text: words.reasons[station.reason]
|
|
36
|
-
} : blowing && reading.windDirectionDeg != null ? {
|
|
37
|
-
kind: "from",
|
|
38
|
-
labelClassName: "meteo-current-from-label",
|
|
39
|
-
label: words.fromLabel,
|
|
40
|
-
deg: reading.windDirectionDeg,
|
|
41
|
-
compass: compassDirection(reading.windDirectionDeg),
|
|
42
|
-
tail: ` ${Math.round(reading.windDirectionDeg)}°`
|
|
43
|
-
} : {
|
|
44
|
-
kind: "text",
|
|
45
|
-
text: calm ? words.calm : "—"
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
temperature: station.capabilities.temperature ? {
|
|
49
|
-
className: "meteo-current-temp",
|
|
50
|
-
text: temperatureText(reading?.temperatureC ?? null, words),
|
|
51
|
-
chill: reading?.windChillC != null ? {
|
|
52
|
-
className: "meteo-current-chill",
|
|
53
|
-
text: ` · ${words.feelsLikeLabel} ${temperatureValue(reading.windChillC)} ${words.degC}`
|
|
54
|
-
} : null
|
|
55
|
-
} : null,
|
|
56
|
-
footer: {
|
|
57
|
-
className: "meteo-current-footer",
|
|
58
|
-
observed: {
|
|
59
|
-
className: "meteo-current-observed",
|
|
60
|
-
text: reading == null ? "—" : formatTime(new Date(reading.observedAt))
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
};
|
|
13
|
+
const flank = (attrs, label, valueMps) => el("div", attrs, el("small", { class: "meteo-microlabel" }, label), el("strong", void 0, valueMps == null ? "—" : String(roundSpeed(valueMps, unit))));
|
|
14
|
+
const directionChildren = station.status === "unavailable" ? [words.reasons[station.reason]] : blowing && reading.windDirectionDeg != null ? [
|
|
15
|
+
el("span", { class: "meteo-current-from-label" }, words.fromLabel),
|
|
16
|
+
" ",
|
|
17
|
+
windArrowNode(reading.windDirectionDeg),
|
|
18
|
+
" ",
|
|
19
|
+
el("strong", void 0, compassDirection(reading.windDirectionDeg)),
|
|
20
|
+
` ${Math.round(reading.windDirectionDeg)}°`
|
|
21
|
+
] : [calm ? words.calm : "—"];
|
|
22
|
+
return el("div", {
|
|
23
|
+
"aria-label": words.aria.current(station.name),
|
|
24
|
+
class: "meteo-current",
|
|
25
|
+
"data-status": station.status,
|
|
26
|
+
role: "group"
|
|
27
|
+
}, el("div", { class: "meteo-current-instrument" }, station.capabilities.gustLull ? flank({ class: "meteo-current-flank meteo-current-flank-lull" }, words.lullLabel, reading?.windLullMps) : null, dialScene({
|
|
28
|
+
bezelId,
|
|
29
|
+
calmWord: false,
|
|
30
|
+
favorableDirections,
|
|
31
|
+
size: 160,
|
|
32
|
+
station,
|
|
33
|
+
thresholds,
|
|
34
|
+
unit,
|
|
35
|
+
words
|
|
36
|
+
}), station.capabilities.gustLull ? flank({ class: "meteo-current-flank meteo-current-flank-gust" }, words.gustLabel, reading?.windGustMps) : null), el("p", { class: "meteo-current-direction" }, directionChildren), station.capabilities.temperature ? el("p", { class: "meteo-current-temp" }, temperatureText(reading?.temperatureC ?? null, words), reading?.windChillC != null ? el("span", { class: "meteo-current-chill" }, ` · ${words.feelsLikeLabel} ${temperatureValue(reading.windChillC)} ${words.degC}`) : null) : null, el("p", { class: "meteo-current-footer" }, freshness != null ? freshnessBadgeNode(freshness, words) : null, el("span", { class: "meteo-current-observed" }, reading == null ? "—" : formatTime(new Date(reading.observedAt)))));
|
|
64
37
|
}
|
|
65
38
|
//#endregion
|
|
66
39
|
export { currentConditionsScene };
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { isCalm, thresholdsToMps } from "../derive.js";
|
|
2
2
|
import { dailyPattern, thinVanes } from "../geometry.js";
|
|
3
3
|
import { roundSpeed } from "../format.js";
|
|
4
|
+
import { el } from "./node.js";
|
|
4
5
|
import { calmNoteText, displaySpeedScales, gapHatchPattern, gapHatchRect, gradedMeanTrace, speedGridLines, stretchedChartFrame, vaneCells, vaneGuideLines, vaneTickTexts, windRowLabels, windThresholdGuides, windZoneRects } from "./wind-plot.js";
|
|
5
6
|
//#region src/scene/daily-pattern.ts
|
|
6
7
|
const DAILY_PATTERN_CLASS = "meteo-daily-pattern";
|
|
7
8
|
const SYNTHETIC_EPOCH_MS = Date.parse("2000-01-01T00:00:00Z");
|
|
8
9
|
function dailyPatternSource(points, station) {
|
|
9
10
|
return {
|
|
10
|
-
source: points ?? (station?.status === "ok" ? station.history?.points
|
|
11
|
+
source: points ?? (station?.status === "ok" ? station.history?.points : null) ?? [],
|
|
11
12
|
periodMinutes: points == null && station?.status === "ok" ? station.history?.periodMinutes ?? null : null
|
|
12
13
|
};
|
|
13
14
|
}
|
|
@@ -64,32 +65,24 @@ function dailyPatternSlotsScene(input) {
|
|
|
64
65
|
const calm = synthetic.every((point) => isCalm(point.windAvgMps));
|
|
65
66
|
const boundsMps = thresholds == null ? null : thresholdsToMps(thresholds);
|
|
66
67
|
const voidSpans = slots.filter((slot) => slot.sampleCount === 0).map((slot) => [scales.xAtMs(SYNTHETIC_EPOCH_MS + slot.startMinuteOfDay * 6e4), scales.xAtMs(SYNTHETIC_EPOCH_MS + (slot.startMinuteOfDay + slotMinutes) * 6e4)]);
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
vaneGuides: vaneGuideLines(vanes, frame, scales),
|
|
86
|
-
gaps: voidSpans.map(([startX, endX]) => gapHatchRect(hatchId, frame, startX, startX, endX - startX)),
|
|
87
|
-
mean: gradedMeanTrace(synthetic, scales, boundsMps),
|
|
88
|
-
calmNote: calm ? calmNoteText(frame, words) : null,
|
|
89
|
-
rowLabels: windRowLabels(frame, words),
|
|
90
|
-
vanes: vaneCells(vanes, frame, scales, (vane) => slots.slice(vane.startIndex, vane.endIndex).every((slot) => slot.sampleCount === 0) ? "—" : String(shown(vane.windAvgMps)), input.favorableDirections),
|
|
91
|
-
ticks: vaneTickTexts(vanes, frame, scales, (timeMs) => formatMinuteOfDay((timeMs - SYNTHETIC_EPOCH_MS) / 6e4))
|
|
92
|
-
};
|
|
68
|
+
const vaneCellList = vaneCells(vanes, frame, scales, (vane) => slots.slice(vane.startIndex, vane.endIndex).every((slot) => slot.sampleCount === 0) ? "—" : String(shown(vane.windAvgMps)), input.favorableDirections);
|
|
69
|
+
return [el("output", { class: "meteo-daily-pattern-caption" }, percent != null ? words.dailyPatternCoverage(totalSamples, percent) : words.dailyPatternSamples(totalSamples)), el("svg", {
|
|
70
|
+
"aria-label": stationName ? words.aria.dailyPattern(stationName) : words.aria.dailyPatternGeneric,
|
|
71
|
+
class: "meteo-daily-pattern-svg",
|
|
72
|
+
height: frame.height,
|
|
73
|
+
role: "img",
|
|
74
|
+
viewBox: `0 0 ${frame.width} ${frame.height}`,
|
|
75
|
+
width: frame.width
|
|
76
|
+
}, el("defs", void 0, gapHatchPattern(hatchId)), windZoneRects(boundsMps, frame, scales), speedGridLines(frame, scales, shown), windThresholdGuides(thresholds, boundsMps, unit, frame, scales, shown), vaneGuideLines(vanes, frame, scales), voidSpans.map(([startX, endX]) => gapHatchRect(hatchId, frame, startX, startX, endX - startX)), gradedMeanTrace(synthetic, scales, boundsMps), calm ? calmNoteText(frame, words) : null, windRowLabels(frame, words)[0], vaneCellList.map((vane) => ({
|
|
77
|
+
...vane.mark,
|
|
78
|
+
key: String(vane.key)
|
|
79
|
+
})), vaneCellList.flatMap((vane) => vane.label == null ? [] : [{
|
|
80
|
+
...vane.label,
|
|
81
|
+
key: String(vane.key)
|
|
82
|
+
}]), windRowLabels(frame, words)[1], vaneCellList.flatMap((vane) => vane.value == null ? [] : [{
|
|
83
|
+
...vane.value,
|
|
84
|
+
key: String(vane.key)
|
|
85
|
+
}]), vaneTickTexts(vanes, frame, scales, (timeMs) => formatMinuteOfDay((timeMs - SYNTHETIC_EPOCH_MS) / 6e4)))];
|
|
93
86
|
}
|
|
94
87
|
//#endregion
|
|
95
88
|
export { DAILY_PATTERN_CLASS, dailyPatternGate, dailyPatternScene, dailyPatternSlotsScene, dailyPatternSource };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "../instruments.js";
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { DIAL_CARDINALS, DIAL_COUNTERWEIGHT_RADIUS, dialNeedlePoints, dialPolar, dialRingArcPath } from "../instruments.js";
|
|
2
|
+
import { el, keyed } from "./node.js";
|
|
3
|
+
//#region src/scene/dial-parts.ts
|
|
4
|
+
function dialRing() {
|
|
5
|
+
return el("circle", {
|
|
6
|
+
class: "meteo-wind-dial-ring",
|
|
7
|
+
cx: 80,
|
|
8
|
+
cy: 80,
|
|
9
|
+
r: 70
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
function dialVerdictRing(arcs) {
|
|
13
|
+
if (arcs == null || arcs.length === 0) return [];
|
|
14
|
+
return [el("circle", {
|
|
15
|
+
class: "meteo-wind-dial-ring-unfavorable",
|
|
16
|
+
cx: 80,
|
|
17
|
+
cy: 80,
|
|
18
|
+
r: 70
|
|
19
|
+
}), ...arcs.map((sector) => keyed(`${sector.fromDeg}-${sector.toDeg}`, "path", {
|
|
20
|
+
class: "meteo-wind-dial-ring-favorable",
|
|
21
|
+
d: dialRingArcPath(sector)
|
|
22
|
+
}))];
|
|
23
|
+
}
|
|
24
|
+
function dialTicks() {
|
|
25
|
+
return Array.from({ length: 16 }, (_, index) => {
|
|
26
|
+
const bearing = index * 22.5;
|
|
27
|
+
const cardinal = index % 4 === 0;
|
|
28
|
+
const [x1, y1] = dialPolar(bearing, 70);
|
|
29
|
+
const [x2, y2] = dialPolar(bearing, cardinal ? 58 : 64);
|
|
30
|
+
return keyed(String(bearing), "line", {
|
|
31
|
+
class: cardinal ? "meteo-wind-dial-tick meteo-wind-dial-tick-cardinal" : "meteo-wind-dial-tick",
|
|
32
|
+
x1,
|
|
33
|
+
x2,
|
|
34
|
+
y1,
|
|
35
|
+
y2
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
function dialLetters() {
|
|
40
|
+
return DIAL_CARDINALS.map(({ bearing, letter }) => {
|
|
41
|
+
const [x, y] = dialPolar(bearing, 46);
|
|
42
|
+
return keyed(letter, "text", {
|
|
43
|
+
class: "meteo-wind-dial-letter",
|
|
44
|
+
"text-anchor": "middle",
|
|
45
|
+
x,
|
|
46
|
+
y: y + 3.5
|
|
47
|
+
}, letter);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
function dialNeedle(directionDeg) {
|
|
51
|
+
return el("g", { class: "meteo-wind-needle" }, el("polygon", {
|
|
52
|
+
class: "meteo-wind-needle-blade",
|
|
53
|
+
points: dialNeedlePoints(directionDeg)
|
|
54
|
+
}), el("circle", {
|
|
55
|
+
class: "meteo-wind-needle-counterweight",
|
|
56
|
+
cx: dialPolar(directionDeg, 46)[0],
|
|
57
|
+
cy: dialPolar(directionDeg, 46)[1],
|
|
58
|
+
r: DIAL_COUNTERWEIGHT_RADIUS
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
61
|
+
function dialHub() {
|
|
62
|
+
return el("circle", {
|
|
63
|
+
class: "meteo-wind-dial-hub",
|
|
64
|
+
cx: 80,
|
|
65
|
+
cy: 80,
|
|
66
|
+
r: 36
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
//#endregion
|
|
70
|
+
export { dialHub, dialLetters, dialNeedle, dialRing, dialTicks, dialVerdictRing };
|
package/dist/scene/dial.d.ts
CHANGED
package/dist/scene/dial.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { isCalm, thresholdsToMps } from "../derive.js";
|
|
2
2
|
import { speedBand } from "../geometry.js";
|
|
3
3
|
import { roundSpeed } from "../format.js";
|
|
4
|
-
import {
|
|
4
|
+
import { dialScaleMaxMps, dialSpeedArcPath } from "../instruments.js";
|
|
5
|
+
import { el, keyed } from "./node.js";
|
|
6
|
+
import { dialHub, dialLetters, dialNeedle, dialRing, dialTicks, dialVerdictRing } from "./dial-parts.js";
|
|
5
7
|
//#region src/scene/dial.ts
|
|
6
8
|
function dialScene(input) {
|
|
7
9
|
const { bezelId, calmWord, favorableDirections, size, station, thresholds, unit, words } = input;
|
|
@@ -14,141 +16,51 @@ function dialScene(input) {
|
|
|
14
16
|
const arcFraction = reading == null ? 0 : Math.min(1, Math.max(0, reading.windAvgMps) / dialMax);
|
|
15
17
|
const boundsMps = thresholds == null ? null : thresholdsToMps(thresholds);
|
|
16
18
|
const arcBand = reading != null && boundsMps != null ? speedBand(reading.windAvgMps, boundsMps) : null;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
r: 70
|
|
63
|
-
},
|
|
64
|
-
favorable: favorableDirections.map((sector) => ({
|
|
65
|
-
key: `${sector.fromDeg}-${sector.toDeg}`,
|
|
66
|
-
className: "meteo-wind-dial-ring-favorable",
|
|
67
|
-
d: dialRingArcPath(sector)
|
|
68
|
-
}))
|
|
69
|
-
} : null,
|
|
70
|
-
arc: reading != null && arcFraction > 0 ? {
|
|
71
|
-
className: arcBand == null ? "meteo-wind-dial-arc" : `meteo-wind-dial-arc meteo-band-${arcBand}`,
|
|
72
|
-
d: dialSpeedArcPath(arcFraction)
|
|
73
|
-
} : null,
|
|
74
|
-
ticks: Array.from({ length: 16 }, (_, index) => {
|
|
75
|
-
const bearing = index * 22.5;
|
|
76
|
-
const cardinal = index % 4 === 0;
|
|
77
|
-
const [x1, y1] = dialPolar(bearing, 70);
|
|
78
|
-
const [x2, y2] = dialPolar(bearing, cardinal ? 58 : 64);
|
|
79
|
-
return {
|
|
80
|
-
key: bearing,
|
|
81
|
-
className: cardinal ? "meteo-wind-dial-tick meteo-wind-dial-tick-cardinal" : "meteo-wind-dial-tick",
|
|
82
|
-
x1,
|
|
83
|
-
x2,
|
|
84
|
-
y1,
|
|
85
|
-
y2
|
|
86
|
-
};
|
|
87
|
-
}),
|
|
88
|
-
letters: DIAL_CARDINALS.map(({ bearing, letter }) => {
|
|
89
|
-
const [x, y] = dialPolar(bearing, 46);
|
|
90
|
-
return {
|
|
91
|
-
key: letter,
|
|
92
|
-
className: "meteo-wind-dial-letter",
|
|
93
|
-
anchor: "middle",
|
|
94
|
-
x,
|
|
95
|
-
y: y + 3.5,
|
|
96
|
-
text: letter
|
|
97
|
-
};
|
|
98
|
-
}),
|
|
99
|
-
needle: blowing && reading.windDirectionDeg != null ? {
|
|
100
|
-
className: "meteo-wind-needle",
|
|
101
|
-
blade: {
|
|
102
|
-
className: "meteo-wind-needle-blade",
|
|
103
|
-
points: dialNeedlePoints(reading.windDirectionDeg)
|
|
104
|
-
},
|
|
105
|
-
counterweight: {
|
|
106
|
-
className: "meteo-wind-needle-counterweight",
|
|
107
|
-
cx: dialPolar(reading.windDirectionDeg, 46)[0],
|
|
108
|
-
cy: dialPolar(reading.windDirectionDeg, 46)[1],
|
|
109
|
-
r: DIAL_COUNTERWEIGHT_RADIUS
|
|
110
|
-
}
|
|
111
|
-
} : null,
|
|
112
|
-
hub: {
|
|
113
|
-
className: "meteo-wind-dial-hub",
|
|
114
|
-
cx: 80,
|
|
115
|
-
cy: 80,
|
|
116
|
-
r: 36
|
|
117
|
-
},
|
|
118
|
-
centre: reading == null ? {
|
|
119
|
-
kind: "reason",
|
|
120
|
-
text: {
|
|
121
|
-
className: "meteo-wind-dial-reason",
|
|
122
|
-
anchor: "middle",
|
|
123
|
-
x: 80,
|
|
124
|
-
y: 84,
|
|
125
|
-
text: words.notReporting
|
|
126
|
-
}
|
|
127
|
-
} : {
|
|
128
|
-
kind: "reading",
|
|
129
|
-
calmWord: calm && calmWord ? {
|
|
130
|
-
className: "meteo-wind-dial-reason",
|
|
131
|
-
anchor: "middle",
|
|
132
|
-
x: 80,
|
|
133
|
-
y: 58,
|
|
134
|
-
text: words.calm
|
|
135
|
-
} : null,
|
|
136
|
-
speed: {
|
|
137
|
-
className: "meteo-wind-dial-speed",
|
|
138
|
-
anchor: "middle",
|
|
139
|
-
x: 80,
|
|
140
|
-
y: 88,
|
|
141
|
-
text: String(shown(reading.windAvgMps))
|
|
142
|
-
},
|
|
143
|
-
unit: {
|
|
144
|
-
className: "meteo-wind-dial-unit",
|
|
145
|
-
anchor: "middle",
|
|
146
|
-
x: 80,
|
|
147
|
-
y: 106,
|
|
148
|
-
text: unitLabel
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
};
|
|
19
|
+
const dialLabel = station.status === "unavailable" ? `${station.name}: ${words.reasons[station.reason]}` : calm ? `${station.name}: ${words.calm}, ${shown(station.reading.windAvgMps)} ${unitLabel}` : `${station.name}: ${shown(station.reading.windAvgMps)} ${unitLabel}`;
|
|
20
|
+
const centreText = (className, y, text) => el("text", {
|
|
21
|
+
class: className,
|
|
22
|
+
"text-anchor": "middle",
|
|
23
|
+
x: 80,
|
|
24
|
+
y
|
|
25
|
+
}, text);
|
|
26
|
+
const centre = reading == null ? [centreText("meteo-wind-dial-reason", 84, words.notReporting)] : [
|
|
27
|
+
calm && calmWord ? centreText("meteo-wind-dial-reason", 58, words.calm) : null,
|
|
28
|
+
centreText("meteo-wind-dial-speed", 88, String(shown(reading.windAvgMps))),
|
|
29
|
+
centreText("meteo-wind-dial-unit", 106, unitLabel)
|
|
30
|
+
];
|
|
31
|
+
return el("svg", {
|
|
32
|
+
"aria-label": dialLabel,
|
|
33
|
+
class: station.status === "unavailable" ? "meteo-wind-dial meteo-wind-dial-unavailable" : "meteo-wind-dial",
|
|
34
|
+
height: size,
|
|
35
|
+
role: "img",
|
|
36
|
+
viewBox: `0 0 160 160`,
|
|
37
|
+
width: size
|
|
38
|
+
}, el("defs", void 0, el("radialGradient", {
|
|
39
|
+
cx: "50%",
|
|
40
|
+
cy: "42%",
|
|
41
|
+
id: bezelId,
|
|
42
|
+
r: "68%"
|
|
43
|
+
}, keyed("55%", "stop", {
|
|
44
|
+
class: "meteo-wind-dial-bezel-in",
|
|
45
|
+
offset: "55%"
|
|
46
|
+
}), keyed("100%", "stop", {
|
|
47
|
+
class: "meteo-wind-dial-bezel-out",
|
|
48
|
+
offset: "100%"
|
|
49
|
+
}))), el("circle", {
|
|
50
|
+
class: "meteo-wind-dial-face",
|
|
51
|
+
cx: 80,
|
|
52
|
+
cy: 80,
|
|
53
|
+
r: 70
|
|
54
|
+
}), el("circle", {
|
|
55
|
+
class: "meteo-wind-dial-bezel",
|
|
56
|
+
cx: 80,
|
|
57
|
+
cy: 80,
|
|
58
|
+
fill: `url(#${bezelId})`,
|
|
59
|
+
r: 70
|
|
60
|
+
}), dialRing(), dialVerdictRing(favorableDirections), reading != null && arcFraction > 0 ? el("path", {
|
|
61
|
+
class: arcBand == null ? "meteo-wind-dial-arc" : `meteo-wind-dial-arc meteo-band-${arcBand}`,
|
|
62
|
+
d: dialSpeedArcPath(arcFraction)
|
|
63
|
+
}) : null, dialTicks(), dialLetters(), blowing && reading.windDirectionDeg != null ? dialNeedle(reading.windDirectionDeg) : null, dialHub(), centre);
|
|
152
64
|
}
|
|
153
65
|
//#endregion
|
|
154
66
|
export { dialScene };
|
|
@@ -1,41 +1,24 @@
|
|
|
1
1
|
import { favorableShare } from "../geometry.js";
|
|
2
|
+
import { el } from "./node.js";
|
|
2
3
|
//#region src/scene/favorable-share.ts
|
|
3
4
|
const FAVORABLE_SHARE_CLASS = "meteo-favorable-share";
|
|
4
5
|
function favorableShareSource(points, station) {
|
|
5
|
-
return points ?? (station?.status === "ok" ? station.history?.points
|
|
6
|
-
}
|
|
7
|
-
function favorableShareGate(source, favorableDirections, words) {
|
|
8
|
-
if (favorableDirections == null || favorableDirections.length === 0) return { kind: "hidden" };
|
|
9
|
-
if (source.length === 0) return {
|
|
10
|
-
kind: "note",
|
|
11
|
-
className: `${FAVORABLE_SHARE_CLASS} meteo-favorable-share-na`,
|
|
12
|
-
text: words.noHistory
|
|
13
|
-
};
|
|
14
|
-
const share = favorableShare(source, favorableDirections);
|
|
15
|
-
if (share == null) return {
|
|
16
|
-
kind: "note",
|
|
17
|
-
className: `${FAVORABLE_SHARE_CLASS} meteo-favorable-share-na`,
|
|
18
|
-
text: words.calm
|
|
19
|
-
};
|
|
20
|
-
return {
|
|
21
|
-
kind: "draw",
|
|
22
|
-
share
|
|
23
|
-
};
|
|
6
|
+
return points ?? (station?.status === "ok" ? station.history?.points : null) ?? [];
|
|
24
7
|
}
|
|
25
8
|
function favorableShareScene(input) {
|
|
26
|
-
const {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
};
|
|
9
|
+
const { favorableDirections, source, stationName, words } = input;
|
|
10
|
+
const note = (text) => el("div", {
|
|
11
|
+
class: `${FAVORABLE_SHARE_CLASS} meteo-favorable-share-na`,
|
|
12
|
+
role: "note"
|
|
13
|
+
}, text);
|
|
14
|
+
if (favorableDirections == null || favorableDirections.length === 0) return null;
|
|
15
|
+
if (source.length === 0) return note(words.noHistory);
|
|
16
|
+
const share = favorableShare(source, favorableDirections);
|
|
17
|
+
if (share == null) return note(words.calm);
|
|
18
|
+
return el("div", {
|
|
19
|
+
"aria-label": stationName == null ? void 0 : words.aria.favorableShare(stationName),
|
|
20
|
+
class: FAVORABLE_SHARE_CLASS
|
|
21
|
+
}, el("span", { class: "meteo-favorable-share-label" }, words.favorableLabel), " ", el("span", { class: "meteo-favorable-share-value" }, words.percentShare(Math.round(share * 100))));
|
|
39
22
|
}
|
|
40
23
|
//#endregion
|
|
41
|
-
export { FAVORABLE_SHARE_CLASS,
|
|
24
|
+
export { FAVORABLE_SHARE_CLASS, favorableShareScene, favorableShareSource };
|
package/dist/scene/glyphs.js
CHANGED
|
@@ -1,24 +1,28 @@
|
|
|
1
|
+
import { el } from "./node.js";
|
|
1
2
|
//#region src/scene/glyphs.ts
|
|
2
|
-
function
|
|
3
|
+
function windArrowNode(deg, size = 12) {
|
|
3
4
|
return {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
...el("svg", {
|
|
6
|
+
"aria-hidden": "true",
|
|
7
|
+
class: "meteo-wind-arrow",
|
|
8
|
+
height: size,
|
|
9
|
+
viewBox: "0 0 16 16",
|
|
10
|
+
width: size
|
|
11
|
+
}, el("path", {
|
|
10
12
|
d: "M8 1 L13 14 L8 10.6 L3 14 Z",
|
|
11
13
|
fill: "currentColor"
|
|
12
|
-
}
|
|
14
|
+
})),
|
|
15
|
+
style: { transform: `rotate(${deg + 180}deg)` }
|
|
13
16
|
};
|
|
14
17
|
}
|
|
15
|
-
function
|
|
16
|
-
return {
|
|
17
|
-
|
|
18
|
-
status
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
function freshnessBadgeNode(status, words) {
|
|
19
|
+
return el("span", {
|
|
20
|
+
class: "meteo-freshness",
|
|
21
|
+
"data-freshness": status
|
|
22
|
+
}, el("span", {
|
|
23
|
+
"aria-hidden": "true",
|
|
24
|
+
class: "meteo-freshness-dot"
|
|
25
|
+
}), words.freshness[status]);
|
|
22
26
|
}
|
|
23
27
|
//#endregion
|
|
24
|
-
export {
|
|
28
|
+
export { freshnessBadgeNode, windArrowNode };
|
package/dist/scene/index.d.ts
CHANGED
|
@@ -5,20 +5,22 @@ import "./atoms.js";
|
|
|
5
5
|
import "./compass-fan.js";
|
|
6
6
|
import "./card.js";
|
|
7
7
|
import { ReadoutPart } from "./chart.js";
|
|
8
|
-
import "./wind-plot.js";
|
|
9
|
-
import "./daily-pattern.js";
|
|
10
8
|
import "./climatology-pattern.js";
|
|
11
|
-
import "./rose.js";
|
|
12
9
|
import "./climatology-rose.js";
|
|
13
10
|
import "./current.js";
|
|
14
11
|
import "./dial.js";
|
|
15
12
|
import "./favorable-share.js";
|
|
13
|
+
import "./cells.js";
|
|
14
|
+
import "./dial-parts.js";
|
|
16
15
|
import "./glyphs.js";
|
|
16
|
+
import "./daily-pattern.js";
|
|
17
17
|
import "./recent-summaries.js";
|
|
18
|
+
import "./rose.js";
|
|
18
19
|
import "./sample-strip.js";
|
|
19
20
|
import "./sparkline.js";
|
|
20
21
|
import "./strip.js";
|
|
21
22
|
import "./table.js";
|
|
22
23
|
import "./trend.js";
|
|
23
24
|
import "./wind-history.js";
|
|
25
|
+
import "./wind-plot.js";
|
|
24
26
|
export { ReadoutPart };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region src/scene/node.ts
|
|
2
|
+
/** An element node; children may be nested arrays and are flattened by the walkers. */
|
|
3
|
+
function el(tag, attrs, ...children) {
|
|
4
|
+
const node = { tag };
|
|
5
|
+
if (attrs !== void 0) node.attrs = attrs;
|
|
6
|
+
if (children.length > 0) node.children = children.flat();
|
|
7
|
+
return node;
|
|
8
|
+
}
|
|
9
|
+
/** The same, carrying list identity. */
|
|
10
|
+
function keyed(key, tag, attrs, ...children) {
|
|
11
|
+
return {
|
|
12
|
+
...el(tag, attrs, ...children),
|
|
13
|
+
key
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/** Tags that open an SVG subtree; everything inside one stays in that namespace. */
|
|
17
|
+
const SVG_ROOT_TAGS = /* @__PURE__ */ new Set(["svg"]);
|
|
18
|
+
//#endregion
|
|
19
|
+
export { SVG_ROOT_TAGS, el, keyed };
|