@azohra/meteo.station 0.5.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/client/climatology.js +1 -1
- package/dist/client/history.js +3 -11
- package/dist/client/live.d.ts +2 -1
- package/dist/client/live.js +7 -4
- package/dist/client/stores.js +10 -2
- package/dist/climatology.d.ts +1 -1
- package/dist/climatology.js +1 -1
- package/dist/connectivity.d.ts +2 -2
- package/dist/contract.d.ts +98 -98
- package/dist/derive.js +9 -8
- 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 +27 -94
- package/dist/elements/elements/WindHistoryChartElement.js +29 -189
- package/dist/elements/elements/WindRoseElement.d.ts +0 -1
- package/dist/elements/elements/WindRoseElement.js +6 -70
- 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/pinned-cursor.js +48 -0
- package/dist/elements/lib/render.js +30 -0
- package/dist/fixtures.d.ts +6 -2
- package/dist/fixtures.js +30 -2
- package/dist/format.js +7 -3
- package/dist/geometry.d.ts +1 -1
- package/dist/geometry.js +22 -9
- 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 +2 -3
- 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 +13 -86
- package/dist/react/components/WindArrow.d.ts +1 -1
- package/dist/react/components/WindArrow.js +3 -15
- package/dist/react/components/WindHistoryChart.js +12 -205
- package/dist/react/components/WindRose.d.ts +1 -3
- package/dist/react/components/WindRose.js +6 -89
- package/dist/react/components/WindSampleStrip.js +14 -139
- package/dist/react/components/atoms.d.ts +5 -5
- package/dist/react/components/atoms.js +12 -48
- package/dist/react/hooks/useStation.js +28 -50
- package/dist/react/hooks/useStationCurrent.js +3 -2
- package/dist/react/hooks/useStationFeed.d.ts +0 -1
- package/dist/react/hooks/useStationFeed.js +3 -2
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.js +7 -7
- package/dist/react/lib/cells.js +4 -24
- package/dist/react/lib/use-pinned-cursor.js +32 -0
- package/dist/samples.js +7 -43
- 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 -66
- 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 +10 -11
- package/dist/server/adapters/windnerd.js +3 -13
- package/dist/server/config.d.ts +48 -48
- package/dist/server/hologram.js +2 -1
- package/dist/server/index.d.ts +2 -2
- package/dist/server/index.js +2 -2
- package/dist/windnerd.d.ts +3 -1
- package/dist/windnerd.js +11 -1
- package/package.json +7 -12
- package/schema/README.md +3 -3
- 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
|
@@ -1,75 +1,35 @@
|
|
|
1
|
-
import { vectorMeanWind } from "../geometry.js";
|
|
2
1
|
import { optionalSpeed, roundSpeed } from "../format.js";
|
|
2
|
+
import { el, keyed } from "./node.js";
|
|
3
|
+
import { windArrowNode } from "./glyphs.js";
|
|
3
4
|
import { inDirectionArcs } from "@azohra/meteo.core";
|
|
4
5
|
//#region src/scene/recent-summaries.ts
|
|
5
6
|
const RECENT_SUMMARIES_CLASS = "meteo-recent-summaries";
|
|
6
|
-
/**
|
|
7
|
+
/** Null unless the source declares the capability; the no-samples words
|
|
7
8
|
* when the declared block is dark. */
|
|
8
|
-
function recentSummariesGate(station, summaries, words) {
|
|
9
|
-
const source = summaries ?? (station?.status === "ok" ? station.recentSummaries ?? null : null);
|
|
10
|
-
if (station != null && station.capabilities.recentSummaries !== true) return { kind: "hidden" };
|
|
11
|
-
if (source == null || source.length === 0) return {
|
|
12
|
-
kind: "note",
|
|
13
|
-
className: `${RECENT_SUMMARIES_CLASS} meteo-recent-summaries-na`,
|
|
14
|
-
text: words.noSamples
|
|
15
|
-
};
|
|
16
|
-
return {
|
|
17
|
-
kind: "draw",
|
|
18
|
-
summaries: source
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
9
|
function recentSummariesScene(input) {
|
|
22
|
-
const { favorableDirections,
|
|
10
|
+
const { favorableDirections, station, summaries, unit, words } = input;
|
|
11
|
+
const source = summaries ?? (station?.status === "ok" ? station.recentSummaries ?? null : null);
|
|
12
|
+
if (station != null && station.capabilities.recentSummaries !== true) return null;
|
|
13
|
+
if (source == null || source.length === 0) return el("div", {
|
|
14
|
+
class: "meteo-recent-summaries meteo-recent-summaries-na",
|
|
15
|
+
role: "note"
|
|
16
|
+
}, words.noSamples);
|
|
23
17
|
const arcs = favorableDirections ?? [];
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
},
|
|
40
|
-
stats: [
|
|
41
|
-
{
|
|
42
|
-
key: "avg",
|
|
43
|
-
className: "meteo-recent-summary-stat",
|
|
44
|
-
label: words.avgLabel,
|
|
45
|
-
value: avgMps == null ? "—" : `${roundSpeed(avgMps, unit)} ${words.speedUnits[unit]}`
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
key: "gust",
|
|
49
|
-
className: "meteo-recent-summary-stat",
|
|
50
|
-
label: words.gustLabel,
|
|
51
|
-
value: optionalSpeed(gusts.length === 0 ? null : Math.max(...gusts), unit)
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
key: "lull",
|
|
55
|
-
className: "meteo-recent-summary-stat",
|
|
56
|
-
label: words.lullLabel,
|
|
57
|
-
value: optionalSpeed(lulls.length === 0 ? null : Math.min(...lulls), unit)
|
|
58
|
-
}
|
|
59
|
-
],
|
|
60
|
-
ghosts: points.flatMap((point) => {
|
|
61
|
-
if (point.windDirectionDeg == null) return [];
|
|
62
|
-
const verdict = arcs.length === 0 ? "" : inDirectionArcs(point.windDirectionDeg, arcs) ? " meteo-direction-favorable" : " meteo-direction-unfavorable";
|
|
63
|
-
return [{
|
|
64
|
-
key: point.observedAt,
|
|
65
|
-
className: `meteo-recent-summary-ghost${verdict}`,
|
|
66
|
-
deg: point.windDirectionDeg
|
|
67
|
-
}];
|
|
68
|
-
}),
|
|
69
|
-
meanDirectionDeg: mean.windDirectionDeg
|
|
70
|
-
};
|
|
71
|
-
})
|
|
72
|
-
};
|
|
18
|
+
const stat = (key, label, value) => keyed(key, "div", { class: "meteo-recent-summary-stat" }, el("dt", { class: "meteo-microlabel" }, label), el("dd", void 0, value));
|
|
19
|
+
return el("div", {
|
|
20
|
+
"aria-label": words.aria.recentSummaries(station?.name ?? ""),
|
|
21
|
+
class: RECENT_SUMMARIES_CLASS
|
|
22
|
+
}, source.map((block) => {
|
|
23
|
+
const points = block.points;
|
|
24
|
+
const avgMps = points.length === 0 ? null : points.reduce((sum, point) => sum + point.windAvgMps, 0) / points.length;
|
|
25
|
+
const gusts = points.map((point) => point.windGustMps).filter((gust) => gust != null);
|
|
26
|
+
const lulls = points.map((point) => point.windLullMps).filter((lull) => lull != null);
|
|
27
|
+
return keyed(String(block.windowMinutes), "section", { class: "meteo-recent-summary" }, el("h4", { class: "meteo-microlabel" }, words.recentWindowLabel(block.windowMinutes)), el("div", { class: "meteo-recent-summary-ghosts" }, points.flatMap((point) => {
|
|
28
|
+
if (point.windDirectionDeg == null) return [];
|
|
29
|
+
const verdict = arcs.length === 0 ? "" : inDirectionArcs(point.windDirectionDeg, arcs) ? " meteo-direction-favorable" : " meteo-direction-unfavorable";
|
|
30
|
+
return [keyed(point.observedAt, "span", { class: `meteo-recent-summary-ghost${verdict}` }, windArrowNode(point.windDirectionDeg, 12))];
|
|
31
|
+
})), el("dl", { class: "meteo-recent-summary-stats" }, stat("avg", words.avgLabel, avgMps == null ? "—" : `${roundSpeed(avgMps, unit)} ${words.speedUnits[unit]}`), stat("gust", words.gustLabel, optionalSpeed(gusts.length === 0 ? null : Math.max(...gusts), unit)), stat("lull", words.lullLabel, optionalSpeed(lulls.length === 0 ? null : Math.min(...lulls), unit))));
|
|
32
|
+
}));
|
|
73
33
|
}
|
|
74
34
|
//#endregion
|
|
75
|
-
export { RECENT_SUMMARIES_CLASS,
|
|
35
|
+
export { RECENT_SUMMARIES_CLASS, recentSummariesScene };
|
package/dist/scene/rose.js
CHANGED
|
@@ -1,135 +1,107 @@
|
|
|
1
1
|
import { normalizeDegrees, thresholdsToMps } from "../derive.js";
|
|
2
2
|
import { speedBand, windRose } from "../geometry.js";
|
|
3
3
|
import { ROSE_CARDINAL_LETTERS, ROSE_INTERCARDINAL_BEARINGS, ROSE_PETAL_FILL, roseBandPath, rosePetalPath, rosePolar, roseRingArcPath } from "../instruments.js";
|
|
4
|
+
import { el, keyed } from "./node.js";
|
|
4
5
|
//#region src/scene/rose.ts
|
|
5
6
|
const WIND_ROSE_CLASS = "meteo-wind-rose";
|
|
6
7
|
function windRoseSource(points, station) {
|
|
7
|
-
return points ?? (station?.status === "ok" ? station.history?.points
|
|
8
|
+
return points ?? (station?.status === "ok" ? station.history?.points : null) ?? [];
|
|
8
9
|
}
|
|
9
|
-
function
|
|
10
|
-
if (source.length === 0) return {
|
|
11
|
-
kind: "note",
|
|
12
|
-
className: `${WIND_ROSE_CLASS} meteo-wind-rose-na`,
|
|
13
|
-
text: words.noHistory
|
|
14
|
-
};
|
|
15
|
-
return { kind: "draw" };
|
|
16
|
-
}
|
|
17
|
-
function windRoseScene(input) {
|
|
10
|
+
function windRoseScene(input, extra = []) {
|
|
18
11
|
const { favorableDirections, source, stationName, thresholds, words } = input;
|
|
12
|
+
if (input.summary == null && source.length === 0) return el("div", {
|
|
13
|
+
class: "meteo-wind-rose meteo-wind-rose-na",
|
|
14
|
+
role: "note"
|
|
15
|
+
}, words.noHistory);
|
|
19
16
|
const boundsMps = thresholds == null ? null : thresholdsToMps(thresholds);
|
|
20
17
|
const rose = input.summary ?? windRose(source, input.sectorCount);
|
|
21
18
|
const sectorCount = rose.sectors.length;
|
|
22
19
|
const maxFrequency = Math.max(...rose.sectors.map((sector) => sector.frequency));
|
|
23
20
|
const halfWidthDeg = 360 / sectorCount / 2 * ROSE_PETAL_FILL;
|
|
24
|
-
const calmPercent = Math.round(rose.calmFraction * 100);
|
|
25
21
|
const [ringLabelX, ringLabelY] = rosePolar(135, 70);
|
|
26
22
|
const favorable = favorableDirections != null && favorableDirections.length > 0;
|
|
27
23
|
const baseLabel = stationName != null ? words.aria.rose(stationName) : words.aria.roseGeneric;
|
|
28
|
-
const roseLabel = favorable && favorableDirections != null ? `${baseLabel} ${words.aria.roseFavorable(favorableDirections.map((sector) => `${Math.round(normalizeDegrees(sector.fromDeg))}
|
|
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
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
ringLabel: maxFrequency > 0 ? {
|
|
110
|
-
className: "meteo-wind-rose-ring-label",
|
|
111
|
-
anchor: "start",
|
|
112
|
-
x: ringLabelX + 3,
|
|
113
|
-
y: ringLabelY + 9,
|
|
114
|
-
text: words.percentShare(Math.round(maxFrequency * 100))
|
|
115
|
-
} : null,
|
|
116
|
-
hub: {
|
|
117
|
-
className: "meteo-wind-rose-hub",
|
|
118
|
-
cx: 95,
|
|
119
|
-
cy: 95,
|
|
120
|
-
r: 16
|
|
121
|
-
},
|
|
122
|
-
dot: {
|
|
123
|
-
className: "meteo-wind-rose-dot",
|
|
124
|
-
cx: 95,
|
|
125
|
-
cy: 95,
|
|
126
|
-
r: 3
|
|
127
|
-
},
|
|
128
|
-
calmCaption: rose.calmFraction > 0 ? {
|
|
129
|
-
className: "meteo-wind-rose-calm",
|
|
130
|
-
text: words.percentCalm(calmPercent)
|
|
131
|
-
} : null
|
|
132
|
-
};
|
|
24
|
+
const roseLabel = favorable && favorableDirections != null ? `${baseLabel} ${words.aria.roseFavorable(favorableDirections.map((sector) => `${Math.round(normalizeDegrees(sector.fromDeg))}\u00b0\u2013${Math.round(normalizeDegrees(sector.toDeg))}\u00b0`).join(", "))}` : baseLabel;
|
|
25
|
+
const petals = rose.sectors.flatMap((sector) => {
|
|
26
|
+
if (sector.count === 0 || maxFrequency === 0) return [];
|
|
27
|
+
const radius = 16 + sector.frequency / maxFrequency * 54;
|
|
28
|
+
if (sector.bandCounts != null) {
|
|
29
|
+
let cumulative = 0;
|
|
30
|
+
return sector.bandCounts.flatMap((bandCount, band) => {
|
|
31
|
+
if (bandCount === 0) return [];
|
|
32
|
+
const innerRadius = 16 + cumulative / sector.count * (radius - 16);
|
|
33
|
+
cumulative += bandCount;
|
|
34
|
+
const outerRadius = 16 + cumulative / sector.count * (radius - 16);
|
|
35
|
+
return [keyed(`${sector.bearingDeg}-${band}`, "path", {
|
|
36
|
+
class: `meteo-wind-rose-petal meteo-band-${band}`,
|
|
37
|
+
d: roseBandPath(sector.bearingDeg, innerRadius, outerRadius, halfWidthDeg)
|
|
38
|
+
})];
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
const banded = boundsMps != null && sector.meanSpeedMps != null ? ` meteo-band-${speedBand(sector.meanSpeedMps, boundsMps)}` : "";
|
|
42
|
+
return [keyed(String(sector.bearingDeg), "path", {
|
|
43
|
+
class: `meteo-wind-rose-petal${banded}`,
|
|
44
|
+
d: rosePetalPath(sector.bearingDeg, radius, halfWidthDeg)
|
|
45
|
+
})];
|
|
46
|
+
});
|
|
47
|
+
return el("div", { class: WIND_ROSE_CLASS }, el("svg", {
|
|
48
|
+
"aria-label": roseLabel,
|
|
49
|
+
class: "meteo-wind-rose-svg",
|
|
50
|
+
height: 190,
|
|
51
|
+
role: "img",
|
|
52
|
+
viewBox: `0 0 190 190`,
|
|
53
|
+
width: 190
|
|
54
|
+
}, [
|
|
55
|
+
1,
|
|
56
|
+
2 / 3,
|
|
57
|
+
1 / 3
|
|
58
|
+
].map((fraction) => keyed(String(fraction), "circle", {
|
|
59
|
+
class: "meteo-wind-rose-grid",
|
|
60
|
+
cx: 95,
|
|
61
|
+
cy: 95,
|
|
62
|
+
r: 70 * fraction
|
|
63
|
+
})), favorable && favorableDirections != null ? [el("circle", {
|
|
64
|
+
class: "meteo-wind-rose-ring-unfavorable",
|
|
65
|
+
cx: 95,
|
|
66
|
+
cy: 95,
|
|
67
|
+
r: 75
|
|
68
|
+
}), ...favorableDirections.map((sector) => keyed(`${sector.fromDeg}-${sector.toDeg}`, "path", {
|
|
69
|
+
class: "meteo-wind-rose-ring-favorable",
|
|
70
|
+
d: roseRingArcPath(sector)
|
|
71
|
+
}))] : [], ROSE_INTERCARDINAL_BEARINGS.map((bearing) => {
|
|
72
|
+
const [x1, y1] = rosePolar(bearing, 66);
|
|
73
|
+
const [x2, y2] = rosePolar(bearing, 74);
|
|
74
|
+
return keyed(String(bearing), "line", {
|
|
75
|
+
class: "meteo-wind-rose-tick",
|
|
76
|
+
x1,
|
|
77
|
+
x2,
|
|
78
|
+
y1,
|
|
79
|
+
y2
|
|
80
|
+
});
|
|
81
|
+
}), ROSE_CARDINAL_LETTERS.map(({ bearing, letter }) => {
|
|
82
|
+
const [x, y] = rosePolar(bearing, 82);
|
|
83
|
+
return keyed(letter, "text", {
|
|
84
|
+
class: "meteo-wind-rose-letter",
|
|
85
|
+
"text-anchor": "middle",
|
|
86
|
+
x,
|
|
87
|
+
y: y + 4
|
|
88
|
+
}, letter);
|
|
89
|
+
}), petals, maxFrequency > 0 ? el("text", {
|
|
90
|
+
class: "meteo-wind-rose-ring-label",
|
|
91
|
+
"text-anchor": "start",
|
|
92
|
+
x: ringLabelX + 3,
|
|
93
|
+
y: ringLabelY + 9
|
|
94
|
+
}, words.percentShare(Math.round(maxFrequency * 100))) : null, el("circle", {
|
|
95
|
+
class: "meteo-wind-rose-hub",
|
|
96
|
+
cx: 95,
|
|
97
|
+
cy: 95,
|
|
98
|
+
r: 16
|
|
99
|
+
}), el("circle", {
|
|
100
|
+
class: "meteo-wind-rose-dot",
|
|
101
|
+
cx: 95,
|
|
102
|
+
cy: 95,
|
|
103
|
+
r: 3
|
|
104
|
+
})), rose.calmFraction > 0 ? el("p", { class: "meteo-wind-rose-calm" }, words.percentCalm(Math.round(rose.calmFraction * 100))) : null, extra);
|
|
133
105
|
}
|
|
134
106
|
//#endregion
|
|
135
|
-
export { WIND_ROSE_CLASS,
|
|
107
|
+
export { WIND_ROSE_CLASS, windRoseScene, windRoseSource };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { compassDirection, isCalm, speedToMps } from "../derive.js";
|
|
2
2
|
import { roundSpeed } from "../format.js";
|
|
3
3
|
import { samplePoints, sampleRuns, sampleScales, thinSampleVanes } from "../samples.js";
|
|
4
|
-
import {
|
|
4
|
+
import { el, keyed } from "./node.js";
|
|
5
|
+
import { calmNoteText, plotLine, speedGridLines, stretchedChartFrame, vaneCells, vaneGuideLines, vaneTickTexts, windRowLabels } from "./wind-plot.js";
|
|
5
6
|
//#region src/scene/sample-strip.ts
|
|
6
7
|
const SAMPLE_STRIP_CLASS = "meteo-sample-strip";
|
|
7
8
|
function sampleStripGate(samples, words) {
|
|
@@ -26,6 +27,7 @@ function sampleStripScene(input) {
|
|
|
26
27
|
});
|
|
27
28
|
const runs = sampleRuns(samples);
|
|
28
29
|
const vanes = thinSampleVanes(points);
|
|
30
|
+
const vaneCellList = vaneCells(vanes, frame, scales, (vane) => String(shown(vane.windAvgMps)), input.favorableDirections);
|
|
29
31
|
return {
|
|
30
32
|
frame,
|
|
31
33
|
scales,
|
|
@@ -41,33 +43,39 @@ function sampleStripScene(input) {
|
|
|
41
43
|
viewBox: `0 0 ${frame.width} ${frame.height}`,
|
|
42
44
|
width: frame.width
|
|
43
45
|
},
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
draw: (cursor, hit) => el("svg", {
|
|
47
|
+
"aria-label": words.aria.sampleStrip(stationName),
|
|
48
|
+
class: "meteo-sample-strip-svg",
|
|
49
|
+
height: frame.height,
|
|
50
|
+
role: "img",
|
|
51
|
+
viewBox: `0 0 ${frame.width} ${frame.height}`,
|
|
52
|
+
width: frame.width
|
|
53
|
+
}, speedGridLines(frame, scales, shown), vaneGuideLines(vanes, frame, scales), runs.map((run) => run.length === 1 ? keyed(run[0].observedAt, "circle", {
|
|
54
|
+
class: "meteo-sample-dot",
|
|
50
55
|
cx: scales.xAt(run[0].observedAt),
|
|
51
56
|
cy: scales.yAt(run[0].windMps),
|
|
52
57
|
r: 2
|
|
53
|
-
} : {
|
|
54
|
-
|
|
55
|
-
key: run[0].observedAt,
|
|
56
|
-
className: "meteo-sample-trace",
|
|
58
|
+
}) : keyed(run[0].observedAt, "polyline", {
|
|
59
|
+
class: "meteo-sample-trace",
|
|
57
60
|
points: samplePoints(run, scales)
|
|
58
|
-
}),
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
61
|
+
})), points.every((sample) => isCalm(sample.windMps)) ? calmNoteText(frame, words) : null, windRowLabels(frame, words)[0], vaneCellList.map((vane) => ({
|
|
62
|
+
...vane.mark,
|
|
63
|
+
key: String(vane.key)
|
|
64
|
+
})), vaneCellList.flatMap((vane) => vane.label == null ? [] : [{
|
|
65
|
+
...vane.label,
|
|
66
|
+
key: String(vane.key)
|
|
67
|
+
}]), windRowLabels(frame, words)[1], vaneCellList.flatMap((vane) => vane.value == null ? [] : [{
|
|
68
|
+
...vane.value,
|
|
69
|
+
key: String(vane.key)
|
|
70
|
+
}]), vaneTickTexts(vanes, frame, scales, (timeMs) => formatTime(new Date(timeMs))), cursor, el("rect", {
|
|
71
|
+
class: "meteo-hit",
|
|
65
72
|
fill: "transparent",
|
|
66
73
|
height: frame.height,
|
|
67
74
|
width: frame.width,
|
|
68
75
|
x: 0,
|
|
69
|
-
y: 0
|
|
70
|
-
|
|
76
|
+
y: 0,
|
|
77
|
+
...hit
|
|
78
|
+
})),
|
|
71
79
|
inspect: (activeIndex) => {
|
|
72
80
|
const active = activeIndex == null ? void 0 : points[activeIndex];
|
|
73
81
|
if (active == null) return {
|
|
@@ -78,7 +86,7 @@ function sampleStripScene(input) {
|
|
|
78
86
|
text: words.inspectHint
|
|
79
87
|
}]
|
|
80
88
|
},
|
|
81
|
-
cursor:
|
|
89
|
+
cursor: []
|
|
82
90
|
};
|
|
83
91
|
const lead = `${shown(active.windMps)} ${words.speedUnits[unit]} · `;
|
|
84
92
|
const span = isCalm(active.windMps) ? [{
|
|
@@ -107,21 +115,12 @@ function sampleStripScene(input) {
|
|
|
107
115
|
strong: formatTime(new Date(active.observedAt)),
|
|
108
116
|
span
|
|
109
117
|
},
|
|
110
|
-
cursor: {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
y2: frame.vaneRow + 9
|
|
117
|
-
},
|
|
118
|
-
dot: {
|
|
119
|
-
className: "meteo-cursor-dot",
|
|
120
|
-
cx: x,
|
|
121
|
-
cy: scales.yAt(active.windMps),
|
|
122
|
-
r: 3
|
|
123
|
-
}
|
|
124
|
-
}
|
|
118
|
+
cursor: [plotLine({ class: "meteo-cursor" }, x, x, frame.plotTop, frame.vaneRow + 9), el("circle", {
|
|
119
|
+
class: "meteo-cursor-dot",
|
|
120
|
+
cx: x,
|
|
121
|
+
cy: scales.yAt(active.windMps),
|
|
122
|
+
r: 3
|
|
123
|
+
})]
|
|
125
124
|
};
|
|
126
125
|
}
|
|
127
126
|
};
|
package/dist/scene/sparkline.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { thresholdsToMps } from "../derive.js";
|
|
2
2
|
import { speedBand } from "../geometry.js";
|
|
3
3
|
import { bandStrips, historyRuns, sparklineScale } from "../instruments.js";
|
|
4
|
+
import { el, keyed } from "./node.js";
|
|
4
5
|
//#region src/scene/sparkline.ts
|
|
5
6
|
const coordinate = (x, y) => `${x.toFixed(1)},${y.toFixed(1)}`;
|
|
6
7
|
function sparklineScene(input) {
|
|
@@ -8,66 +9,56 @@ function sparklineScene(input) {
|
|
|
8
9
|
const label = words.aria.sparkline(station.name);
|
|
9
10
|
const history = station.status === "ok" ? station.history : null;
|
|
10
11
|
if (!(station.capabilities.history && history != null && history.points.length >= 2) || history == null) return {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
...el("span", {
|
|
13
|
+
"aria-label": label,
|
|
14
|
+
class: "meteo-sparkline meteo-sparkline-na",
|
|
15
|
+
role: "img"
|
|
16
|
+
}, "—"),
|
|
17
|
+
style: {
|
|
18
|
+
height: `${height}px`,
|
|
19
|
+
width: `${width}px`
|
|
20
|
+
}
|
|
17
21
|
};
|
|
18
22
|
const points = history.points;
|
|
19
23
|
const { xAt, yAt } = sparklineScale(points, width, height);
|
|
20
24
|
const runs = historyRuns(points, history.periodMinutes);
|
|
21
25
|
const strips = showBand ? bandStrips(runs) : [];
|
|
22
26
|
const boundsMps = thresholds == null ? null : thresholdsToMps(thresholds);
|
|
23
|
-
const trace = boundsMps == null ? runs.map((segment) => segment.points.length === 1 ? {
|
|
24
|
-
|
|
25
|
-
key: segment.startedAt,
|
|
26
|
-
className: "meteo-sparkline-dot",
|
|
27
|
+
const trace = boundsMps == null ? runs.map((segment) => segment.points.length === 1 ? keyed(segment.startedAt, "circle", {
|
|
28
|
+
class: "meteo-sparkline-dot",
|
|
27
29
|
cx: xAt(Date.parse(segment.points[0].observedAt)),
|
|
28
30
|
cy: yAt(segment.points[0].windAvgMps),
|
|
29
31
|
r: 1.5
|
|
30
|
-
} : {
|
|
31
|
-
|
|
32
|
-
key: segment.startedAt,
|
|
33
|
-
className: "meteo-sparkline-line",
|
|
32
|
+
}) : keyed(segment.startedAt, "polyline", {
|
|
33
|
+
class: "meteo-sparkline-line",
|
|
34
34
|
points: segment.points.map((point) => coordinate(xAt(Date.parse(point.observedAt)), yAt(point.windAvgMps))).join(" ")
|
|
35
|
-
}) : runs.flatMap((segment) => segment.points.length === 1 ? [{
|
|
36
|
-
|
|
37
|
-
key: segment.startedAt,
|
|
38
|
-
className: `meteo-sparkline-dot meteo-band-${speedBand(segment.points[0].windAvgMps, boundsMps)}`,
|
|
35
|
+
})) : runs.flatMap((segment) => segment.points.length === 1 ? [keyed(segment.startedAt, "circle", {
|
|
36
|
+
class: `meteo-sparkline-dot meteo-band-${speedBand(segment.points[0].windAvgMps, boundsMps)}`,
|
|
39
37
|
cx: xAt(Date.parse(segment.points[0].observedAt)),
|
|
40
38
|
cy: yAt(segment.points[0].windAvgMps),
|
|
41
39
|
r: 1.5
|
|
42
|
-
}] : segment.points.slice(1).map((point, index) => {
|
|
40
|
+
})] : segment.points.slice(1).map((point, index) => {
|
|
43
41
|
const previous = segment.points[index];
|
|
44
42
|
const band = speedBand((previous.windAvgMps + point.windAvgMps) / 2, boundsMps);
|
|
45
|
-
return {
|
|
46
|
-
|
|
47
|
-
key: point.observedAt,
|
|
48
|
-
className: `meteo-sparkline-segment meteo-band-${band}`,
|
|
43
|
+
return keyed(point.observedAt, "line", {
|
|
44
|
+
class: `meteo-sparkline-segment meteo-band-${band}`,
|
|
49
45
|
x1: xAt(Date.parse(previous.observedAt)),
|
|
50
46
|
x2: xAt(Date.parse(point.observedAt)),
|
|
51
47
|
y1: yAt(previous.windAvgMps),
|
|
52
48
|
y2: yAt(point.windAvgMps)
|
|
53
|
-
};
|
|
49
|
+
});
|
|
54
50
|
}));
|
|
55
|
-
return {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
className: "meteo-sparkline-band",
|
|
67
|
-
points: [...strip.points.map((point) => coordinate(xAt(Date.parse(point.observedAt)), yAt(point.windGustMps))), ...[...strip.points].reverse().map((point) => coordinate(xAt(Date.parse(point.observedAt)), yAt(point.windLullMps)))].join(" ")
|
|
68
|
-
})),
|
|
69
|
-
trace
|
|
70
|
-
};
|
|
51
|
+
return el("svg", {
|
|
52
|
+
"aria-label": label,
|
|
53
|
+
class: "meteo-sparkline",
|
|
54
|
+
height,
|
|
55
|
+
role: "img",
|
|
56
|
+
viewBox: `0 0 ${width} ${height}`,
|
|
57
|
+
width
|
|
58
|
+
}, strips.filter((strip) => strip.points.length >= 2).map((strip) => keyed(strip.startedAt, "polygon", {
|
|
59
|
+
class: "meteo-sparkline-band",
|
|
60
|
+
points: [...strip.points.map((point) => coordinate(xAt(Date.parse(point.observedAt)), yAt(point.windGustMps))), ...[...strip.points].reverse().map((point) => coordinate(xAt(Date.parse(point.observedAt)), yAt(point.windLullMps)))].join(" ")
|
|
61
|
+
})), trace);
|
|
71
62
|
}
|
|
72
63
|
//#endregion
|
|
73
64
|
export { sparklineScene };
|
package/dist/scene/strip.js
CHANGED
|
@@ -1,63 +1,24 @@
|
|
|
1
1
|
import { optionalSpeed, roundSpeed, temperatureText } from "../format.js";
|
|
2
|
+
import { el } from "./node.js";
|
|
3
|
+
import { freshnessBadgeNode } from "./glyphs.js";
|
|
4
|
+
import { directionCellNodes, stationNameNode } from "./cells.js";
|
|
2
5
|
//#region src/scene/strip.ts
|
|
3
6
|
function stationStripScene(input) {
|
|
4
|
-
const { formatTime, station, unit, words } = input;
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
};
|
|
19
|
-
return {
|
|
20
|
-
root,
|
|
21
|
-
stationClassName: "meteo-strip-station",
|
|
22
|
-
body: {
|
|
23
|
-
kind: "reading",
|
|
24
|
-
wind: {
|
|
25
|
-
className: "meteo-strip-wind",
|
|
26
|
-
value: String(roundSpeed(station.reading.windAvgMps, unit)),
|
|
27
|
-
unitLabel: words.speedUnits[unit]
|
|
28
|
-
},
|
|
29
|
-
gustLull: station.capabilities.gustLull ? {
|
|
30
|
-
lull: {
|
|
31
|
-
className: "meteo-strip-lull",
|
|
32
|
-
labelClassName: "meteo-microlabel",
|
|
33
|
-
label: words.lullLabel,
|
|
34
|
-
value: optionalSpeed(station.reading.windLullMps, unit)
|
|
35
|
-
},
|
|
36
|
-
gust: {
|
|
37
|
-
className: "meteo-strip-gust",
|
|
38
|
-
labelClassName: "meteo-microlabel",
|
|
39
|
-
label: words.gustLabel,
|
|
40
|
-
value: optionalSpeed(station.reading.windGustMps, unit)
|
|
41
|
-
}
|
|
42
|
-
} : null,
|
|
43
|
-
from: {
|
|
44
|
-
className: "meteo-strip-from",
|
|
45
|
-
windAvgMps: station.reading.windAvgMps,
|
|
46
|
-
windDirectionDeg: station.reading.windDirectionDeg
|
|
47
|
-
},
|
|
48
|
-
temperature: station.capabilities.temperature ? {
|
|
49
|
-
className: "meteo-strip-temp",
|
|
50
|
-
text: temperatureText(station.reading.temperatureC, words)
|
|
51
|
-
} : null,
|
|
52
|
-
updated: {
|
|
53
|
-
className: "meteo-strip-updated",
|
|
54
|
-
time: {
|
|
55
|
-
className: "meteo-strip-time",
|
|
56
|
-
text: formatTime(new Date(station.reading.observedAt))
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
};
|
|
7
|
+
const { formatTime, freshness, station, unit, words } = input;
|
|
8
|
+
const labelled = (className, label, value) => el("span", { class: className }, el("small", { class: "meteo-microlabel" }, label), value);
|
|
9
|
+
const cells = station.status !== "ok" ? [el("span", { class: "meteo-strip-reason" }, words.reasons[station.reason])] : [
|
|
10
|
+
el("span", { class: "meteo-strip-wind" }, el("strong", void 0, String(roundSpeed(station.reading.windAvgMps, unit))), el("small", void 0, words.speedUnits[unit])),
|
|
11
|
+
...station.capabilities.gustLull ? [labelled("meteo-strip-lull", words.lullLabel, optionalSpeed(station.reading.windLullMps, unit)), labelled("meteo-strip-gust", words.gustLabel, optionalSpeed(station.reading.windGustMps, unit))] : [],
|
|
12
|
+
el("span", { class: "meteo-strip-from" }, directionCellNodes(station.reading.windAvgMps, station.reading.windDirectionDeg, words)),
|
|
13
|
+
station.capabilities.temperature ? el("span", { class: "meteo-strip-temp" }, temperatureText(station.reading.temperatureC, words)) : null,
|
|
14
|
+
el("span", { class: "meteo-strip-updated" }, el("span", { class: "meteo-strip-time" }, formatTime(new Date(station.reading.observedAt))), freshness != null ? freshnessBadgeNode(freshness, words) : null)
|
|
15
|
+
];
|
|
16
|
+
return el("div", {
|
|
17
|
+
"aria-label": words.aria.strip(station.name),
|
|
18
|
+
class: "meteo-strip",
|
|
19
|
+
"data-status": station.status,
|
|
20
|
+
role: "group"
|
|
21
|
+
}, el("span", { class: "meteo-strip-station" }, stationNameNode(station)), cells);
|
|
61
22
|
}
|
|
62
23
|
//#endregion
|
|
63
24
|
export { stationStripScene };
|