@azohra/meteo.station 0.3.1 → 0.5.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/dist/client/climatology.d.ts +27 -0
- package/dist/client/climatology.js +83 -0
- package/dist/client/history.d.ts +47 -0
- package/dist/client/history.js +112 -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 +66 -0
- package/dist/climatology.js +230 -0
- package/dist/contract-climatology.d.ts +73 -0
- package/dist/contract-climatology.js +52 -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 +24 -16
- 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 +20 -7
- 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 +23 -4
- package/dist/geometry.js +44 -13
- 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 +15 -8
- 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 +18 -0
- package/dist/react/components/RecentSummaries.js +64 -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 +20 -5
- 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 +8 -5
- 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 +21 -7
- 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/trend.js +2 -7
- 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 +44 -9
- package/dist/server/adapter.d.ts +2 -1
- package/dist/server/adapter.js +2 -1
- package/dist/server/adapters/windnerd-climatology.d.ts +30 -0
- package/dist/server/adapters/windnerd-climatology.js +82 -0
- package/dist/server/adapters/windnerd-live.d.ts +5 -8
- package/dist/server/adapters/windnerd-live.js +26 -21
- package/dist/server/adapters/windnerd.d.ts +31 -4
- package/dist/server/adapters/windnerd.js +196 -19
- package/dist/server/environment.d.ts +4 -10
- package/dist/server/environment.js +4 -10
- 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 +13 -1
- package/dist/strings.js +13 -1
- package/package.json +2 -2
- package/schema/example-climatology.json +86 -0
- package/schema/example-history.json +38 -0
- package/schema/stationclimatology.schema.json +221 -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 +232 -19
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { climatologyCoverage, climatologyFavorableShare, climatologyRose } from "../climatology.js";
|
|
2
|
+
import { windRoseScene } from "./rose.js";
|
|
3
|
+
//#region src/scene/climatology-rose.ts
|
|
4
|
+
const CLIMATOLOGY_ROSE_CLASS = "meteo-climatology-rose";
|
|
5
|
+
function climatologyRoseGate(document, words) {
|
|
6
|
+
if (document == null || document.cells.length === 0) return {
|
|
7
|
+
kind: "note",
|
|
8
|
+
className: `${CLIMATOLOGY_ROSE_CLASS} meteo-climatology-rose-na`,
|
|
9
|
+
text: words.noClimatology
|
|
10
|
+
};
|
|
11
|
+
return {
|
|
12
|
+
kind: "draw",
|
|
13
|
+
document
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function climatologyRoseScene(input) {
|
|
17
|
+
const { document, favorableDirections, filters, stationName, words } = input;
|
|
18
|
+
const summary = climatologyRose(document, filters);
|
|
19
|
+
const rose = windRoseScene({
|
|
20
|
+
favorableDirections,
|
|
21
|
+
sectorCount: document.sectorCount,
|
|
22
|
+
source: [],
|
|
23
|
+
stationName,
|
|
24
|
+
summary,
|
|
25
|
+
thresholds: void 0,
|
|
26
|
+
words
|
|
27
|
+
});
|
|
28
|
+
const captions = [];
|
|
29
|
+
const arcs = favorableDirections ?? [];
|
|
30
|
+
const share = arcs.length === 0 ? null : climatologyFavorableShare(document, arcs, filters);
|
|
31
|
+
if (share != null) captions.push({
|
|
32
|
+
key: "favorable",
|
|
33
|
+
className: "meteo-climatology-caption meteo-climatology-caption-favorable",
|
|
34
|
+
text: words.percentFavorable(Math.round(share * 100))
|
|
35
|
+
});
|
|
36
|
+
const coverage = filters?.months == null && filters?.slots == null ? climatologyCoverage(document) : null;
|
|
37
|
+
captions.push({
|
|
38
|
+
key: "samples",
|
|
39
|
+
className: "meteo-climatology-caption",
|
|
40
|
+
text: coverage != null && coverage.ratio != null ? words.dailyPatternCoverage(summary.sampleCount, Math.round(coverage.ratio * 100)) : words.dailyPatternSamples(summary.sampleCount)
|
|
41
|
+
});
|
|
42
|
+
return {
|
|
43
|
+
className: CLIMATOLOGY_ROSE_CLASS,
|
|
44
|
+
rose,
|
|
45
|
+
captions
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
export { CLIMATOLOGY_ROSE_CLASS, climatologyRoseGate, climatologyRoseScene };
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { isCalm } from "../derive.js";
|
|
2
|
+
import { vanePath } from "../geometry.js";
|
|
3
|
+
import { DIAL_CARDINALS, DIAL_COUNTERWEIGHT_RADIUS, dialNeedlePoints, dialPolar, dialRingArcPath } from "../instruments.js";
|
|
4
|
+
//#region src/scene/compass-fan.ts
|
|
5
|
+
const COMPASS_FAN_CLASS = "meteo-compass-fan";
|
|
6
|
+
const FAN_RADIUS = 58;
|
|
7
|
+
const FAN_GHOST_STEPS = 10;
|
|
8
|
+
function compassFanSource(samples, station) {
|
|
9
|
+
return samples ?? (station?.status === "ok" ? station.samples ?? null : null);
|
|
10
|
+
}
|
|
11
|
+
/** hidden without the declared live capability (when judging a station);
|
|
12
|
+
* the no-samples words when the ring is empty. */
|
|
13
|
+
function compassFanGate(source, station, words) {
|
|
14
|
+
if (station != null && station.capabilities.live !== true) return { kind: "hidden" };
|
|
15
|
+
if (source == null || source.points.length === 0) return {
|
|
16
|
+
kind: "note",
|
|
17
|
+
className: `${COMPASS_FAN_CLASS} meteo-compass-fan-na`,
|
|
18
|
+
text: words.noSamples
|
|
19
|
+
};
|
|
20
|
+
return {
|
|
21
|
+
kind: "draw",
|
|
22
|
+
samples: source
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function compassFanScene(input) {
|
|
26
|
+
const { favorableDirections, samples, stationName, words } = input;
|
|
27
|
+
const points = samples.points;
|
|
28
|
+
const count = points.length;
|
|
29
|
+
const newest = points[count - 1];
|
|
30
|
+
const newestBlowing = newest != null && !isCalm(newest.windMps) && newest.windDirectionDeg != null;
|
|
31
|
+
return {
|
|
32
|
+
svg: {
|
|
33
|
+
ariaLabel: words.aria.compassFan(stationName ?? ""),
|
|
34
|
+
className: "meteo-compass-fan-svg",
|
|
35
|
+
height: 160,
|
|
36
|
+
viewBox: `0 0 160 160`,
|
|
37
|
+
width: 160
|
|
38
|
+
},
|
|
39
|
+
ring: {
|
|
40
|
+
className: "meteo-wind-dial-ring",
|
|
41
|
+
cx: 80,
|
|
42
|
+
cy: 80,
|
|
43
|
+
r: 70
|
|
44
|
+
},
|
|
45
|
+
verdictRing: favorableDirections != null && favorableDirections.length > 0 ? {
|
|
46
|
+
unfavorable: {
|
|
47
|
+
className: "meteo-wind-dial-ring-unfavorable",
|
|
48
|
+
cx: 80,
|
|
49
|
+
cy: 80,
|
|
50
|
+
r: 70
|
|
51
|
+
},
|
|
52
|
+
favorable: favorableDirections.map((sector) => ({
|
|
53
|
+
key: `${sector.fromDeg}-${sector.toDeg}`,
|
|
54
|
+
className: "meteo-wind-dial-ring-favorable",
|
|
55
|
+
d: dialRingArcPath(sector)
|
|
56
|
+
}))
|
|
57
|
+
} : null,
|
|
58
|
+
ticks: Array.from({ length: 16 }, (_, index) => {
|
|
59
|
+
const bearing = index * 22.5;
|
|
60
|
+
const cardinal = index % 4 === 0;
|
|
61
|
+
const [x1, y1] = dialPolar(bearing, 70);
|
|
62
|
+
const [x2, y2] = dialPolar(bearing, cardinal ? 58 : 64);
|
|
63
|
+
return {
|
|
64
|
+
key: bearing,
|
|
65
|
+
className: cardinal ? "meteo-wind-dial-tick meteo-wind-dial-tick-cardinal" : "meteo-wind-dial-tick",
|
|
66
|
+
x1,
|
|
67
|
+
x2,
|
|
68
|
+
y1,
|
|
69
|
+
y2
|
|
70
|
+
};
|
|
71
|
+
}),
|
|
72
|
+
letters: DIAL_CARDINALS.map(({ bearing, letter }) => {
|
|
73
|
+
const [x, y] = dialPolar(bearing, 46);
|
|
74
|
+
return {
|
|
75
|
+
key: letter,
|
|
76
|
+
className: "meteo-wind-dial-letter",
|
|
77
|
+
anchor: "middle",
|
|
78
|
+
x,
|
|
79
|
+
y: y + 3.5,
|
|
80
|
+
text: letter
|
|
81
|
+
};
|
|
82
|
+
}),
|
|
83
|
+
ghosts: points.slice(0, -1).flatMap((sample, index) => {
|
|
84
|
+
if (isCalm(sample.windMps) || sample.windDirectionDeg == null) return [];
|
|
85
|
+
const decile = Math.min(FAN_GHOST_STEPS - 1, Math.floor((count - 1 - index) / count * FAN_GHOST_STEPS));
|
|
86
|
+
const [cx, cy] = dialPolar(sample.windDirectionDeg, FAN_RADIUS);
|
|
87
|
+
return [{
|
|
88
|
+
key: sample.observedAt,
|
|
89
|
+
className: `meteo-fan-ghost-${decile}`,
|
|
90
|
+
d: vanePath(cx, cy, sample.windDirectionDeg)
|
|
91
|
+
}];
|
|
92
|
+
}),
|
|
93
|
+
needle: newestBlowing && newest.windDirectionDeg != null ? {
|
|
94
|
+
className: "meteo-wind-needle",
|
|
95
|
+
blade: {
|
|
96
|
+
className: "meteo-wind-needle-blade",
|
|
97
|
+
points: dialNeedlePoints(newest.windDirectionDeg)
|
|
98
|
+
},
|
|
99
|
+
counterweight: {
|
|
100
|
+
className: "meteo-wind-needle-counterweight",
|
|
101
|
+
cx: dialPolar(newest.windDirectionDeg, 46)[0],
|
|
102
|
+
cy: dialPolar(newest.windDirectionDeg, 46)[1],
|
|
103
|
+
r: DIAL_COUNTERWEIGHT_RADIUS
|
|
104
|
+
}
|
|
105
|
+
} : null,
|
|
106
|
+
hub: {
|
|
107
|
+
className: "meteo-wind-dial-hub",
|
|
108
|
+
cx: 80,
|
|
109
|
+
cy: 80,
|
|
110
|
+
r: 36
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
//#endregion
|
|
115
|
+
export { COMPASS_FAN_CLASS, compassFanGate, compassFanScene, compassFanSource };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isCalm, thresholdsToMps } from "../derive.js";
|
|
2
|
-
import { roundSpeed } from "../format.js";
|
|
3
2
|
import { dailyPattern, thinVanes } from "../geometry.js";
|
|
3
|
+
import { roundSpeed } from "../format.js";
|
|
4
4
|
import { calmNoteText, displaySpeedScales, gapHatchPattern, gapHatchRect, gradedMeanTrace, speedGridLines, stretchedChartFrame, vaneCells, vaneGuideLines, vaneTickTexts, windRowLabels, windThresholdGuides, windZoneRects } from "./wind-plot.js";
|
|
5
5
|
//#region src/scene/daily-pattern.ts
|
|
6
6
|
const DAILY_PATTERN_CLASS = "meteo-daily-pattern";
|
|
@@ -34,16 +34,30 @@ function formatMinuteOfDay(minuteOfDay) {
|
|
|
34
34
|
return `${String(Math.floor(clamped / 60)).padStart(2, "0")}:${String(clamped % 60).padStart(2, "0")}`;
|
|
35
35
|
}
|
|
36
36
|
function dailyPatternScene(input) {
|
|
37
|
-
const {
|
|
38
|
-
const shown = (speedMps) => roundSpeed(speedMps, unit);
|
|
37
|
+
const { periodMinutes, points, slotMinutes, utcOffsetMinutes } = input;
|
|
39
38
|
const slots = dailyPattern(points, {
|
|
40
39
|
slotMinutes,
|
|
41
40
|
utcOffsetMinutes
|
|
42
41
|
});
|
|
43
|
-
const synthetic = slots.map((slot) => slotPoint(slot, slotMinutes));
|
|
44
42
|
const totalSamples = slots.reduce((sum, slot) => sum + slot.sampleCount, 0);
|
|
45
43
|
const daysSpanned = points.length < 2 ? null : (Date.parse(points[points.length - 1].observedAt) - Date.parse(points[0].observedAt)) / 864e5;
|
|
46
44
|
const expectedSamples = periodMinutes != null && daysSpanned != null && daysSpanned > 0 ? Math.round(slotMinutes / periodMinutes * daysSpanned * slots.length) : null;
|
|
45
|
+
return dailyPatternSlotsScene({
|
|
46
|
+
...input,
|
|
47
|
+
slots,
|
|
48
|
+
coverage: {
|
|
49
|
+
totalSamples,
|
|
50
|
+
percent: expectedSamples != null && expectedSamples > 0 ? Math.round(totalSamples / expectedSamples * 100) : null
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
/** The same scene from pre-aggregated slots — the climatology cube's road:
|
|
55
|
+
* the caller owns the aggregation and the coverage words' inputs. */
|
|
56
|
+
function dailyPatternSlotsScene(input) {
|
|
57
|
+
const { coverage, hatchId, plotHeight, slotMinutes, slots, stationName, thresholds, unit, width, words } = input;
|
|
58
|
+
const shown = (speedMps) => roundSpeed(speedMps, unit);
|
|
59
|
+
const synthetic = slots.map((slot) => slotPoint(slot, slotMinutes));
|
|
60
|
+
const { totalSamples, percent } = coverage;
|
|
47
61
|
const frame = stretchedChartFrame(width, plotHeight);
|
|
48
62
|
const scales = displaySpeedScales(synthetic, frame, unit);
|
|
49
63
|
const vanes = thinVanes(synthetic);
|
|
@@ -55,7 +69,7 @@ function dailyPatternScene(input) {
|
|
|
55
69
|
scales,
|
|
56
70
|
caption: {
|
|
57
71
|
className: "meteo-daily-pattern-caption",
|
|
58
|
-
text:
|
|
72
|
+
text: percent != null ? words.dailyPatternCoverage(totalSamples, percent) : words.dailyPatternSamples(totalSamples)
|
|
59
73
|
},
|
|
60
74
|
svg: {
|
|
61
75
|
ariaLabel: stationName ? words.aria.dailyPattern(stationName) : words.aria.dailyPatternGeneric,
|
|
@@ -73,9 +87,9 @@ function dailyPatternScene(input) {
|
|
|
73
87
|
mean: gradedMeanTrace(synthetic, scales, boundsMps),
|
|
74
88
|
calmNote: calm ? calmNoteText(frame, words) : null,
|
|
75
89
|
rowLabels: windRowLabels(frame, words),
|
|
76
|
-
vanes: vaneCells(vanes, frame, scales, (vane) => slots.slice(vane.startIndex, vane.endIndex).every((slot) => slot.sampleCount === 0) ? "—" : String(shown(vane.windAvgMps))),
|
|
90
|
+
vanes: vaneCells(vanes, frame, scales, (vane) => slots.slice(vane.startIndex, vane.endIndex).every((slot) => slot.sampleCount === 0) ? "—" : String(shown(vane.windAvgMps)), input.favorableDirections),
|
|
77
91
|
ticks: vaneTickTexts(vanes, frame, scales, (timeMs) => formatMinuteOfDay((timeMs - SYNTHETIC_EPOCH_MS) / 6e4))
|
|
78
92
|
};
|
|
79
93
|
}
|
|
80
94
|
//#endregion
|
|
81
|
-
export { DAILY_PATTERN_CLASS, dailyPatternGate, dailyPatternScene, dailyPatternSource };
|
|
95
|
+
export { DAILY_PATTERN_CLASS, dailyPatternGate, dailyPatternScene, dailyPatternSlotsScene, dailyPatternSource };
|
package/dist/scene/dial.d.ts
CHANGED
package/dist/scene/dial.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { isCalm, thresholdsToMps } from "../derive.js";
|
|
2
|
-
import { roundSpeed } from "../format.js";
|
|
3
2
|
import { speedBand } from "../geometry.js";
|
|
4
|
-
import {
|
|
3
|
+
import { roundSpeed } from "../format.js";
|
|
4
|
+
import { DIAL_CARDINALS, DIAL_COUNTERWEIGHT_RADIUS, dialNeedlePoints, dialPolar, dialRingArcPath, dialScaleMaxMps, dialSpeedArcPath } from "../instruments.js";
|
|
5
5
|
//#region src/scene/dial.ts
|
|
6
6
|
function dialScene(input) {
|
|
7
|
-
const { bezelId, calmWord, size, station, thresholds, unit, words } = input;
|
|
7
|
+
const { bezelId, calmWord, favorableDirections, size, station, thresholds, unit, words } = input;
|
|
8
8
|
const shown = (windAvgMps) => roundSpeed(windAvgMps, unit);
|
|
9
9
|
const unitLabel = words.speedUnits[unit];
|
|
10
10
|
const reading = station.status === "ok" ? station.reading : null;
|
|
@@ -54,6 +54,19 @@ function dialScene(input) {
|
|
|
54
54
|
cy: 80,
|
|
55
55
|
r: 70
|
|
56
56
|
},
|
|
57
|
+
verdictRing: favorableDirections != null && favorableDirections.length > 0 ? {
|
|
58
|
+
unfavorable: {
|
|
59
|
+
className: "meteo-wind-dial-ring-unfavorable",
|
|
60
|
+
cx: 80,
|
|
61
|
+
cy: 80,
|
|
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,
|
|
57
70
|
arc: reading != null && arcFraction > 0 ? {
|
|
58
71
|
className: arcBand == null ? "meteo-wind-dial-arc" : `meteo-wind-dial-arc meteo-band-${arcBand}`,
|
|
59
72
|
d: dialSpeedArcPath(arcFraction)
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { favorableShare } from "../geometry.js";
|
|
2
|
+
//#region src/scene/favorable-share.ts
|
|
3
|
+
const FAVORABLE_SHARE_CLASS = "meteo-favorable-share";
|
|
4
|
+
function favorableShareSource(points, station) {
|
|
5
|
+
return points ?? (station?.status === "ok" ? station.history?.points ?? null : null) ?? [];
|
|
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
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function favorableShareScene(input) {
|
|
26
|
+
const { share, stationName, words } = input;
|
|
27
|
+
return {
|
|
28
|
+
className: FAVORABLE_SHARE_CLASS,
|
|
29
|
+
ariaLabel: stationName == null ? void 0 : words.aria.favorableShare(stationName),
|
|
30
|
+
label: {
|
|
31
|
+
className: "meteo-favorable-share-label",
|
|
32
|
+
text: words.favorableLabel
|
|
33
|
+
},
|
|
34
|
+
value: {
|
|
35
|
+
className: "meteo-favorable-share-value",
|
|
36
|
+
text: words.percentShare(Math.round(share * 100))
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
export { FAVORABLE_SHARE_CLASS, favorableShareGate, favorableShareScene, favorableShareSource };
|
package/dist/scene/index.d.ts
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
import { TickAnchor, measuredChartWidth, tickAnchor } from "../geometry.js";
|
|
2
|
+
import "./air-extremes.js";
|
|
2
3
|
import "./air-matrix.js";
|
|
3
4
|
import "./atoms.js";
|
|
5
|
+
import "./compass-fan.js";
|
|
4
6
|
import "./card.js";
|
|
5
7
|
import { ReadoutPart } from "./chart.js";
|
|
6
|
-
import "./current.js";
|
|
7
8
|
import "./wind-plot.js";
|
|
8
|
-
import "./dial.js";
|
|
9
|
-
import "./glyphs.js";
|
|
10
9
|
import "./daily-pattern.js";
|
|
10
|
+
import "./climatology-pattern.js";
|
|
11
11
|
import "./rose.js";
|
|
12
|
+
import "./climatology-rose.js";
|
|
13
|
+
import "./current.js";
|
|
14
|
+
import "./dial.js";
|
|
15
|
+
import "./favorable-share.js";
|
|
16
|
+
import "./glyphs.js";
|
|
17
|
+
import "./recent-summaries.js";
|
|
12
18
|
import "./sample-strip.js";
|
|
13
19
|
import "./sparkline.js";
|
|
14
20
|
import "./strip.js";
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { vectorMeanWind } from "../geometry.js";
|
|
2
|
+
import { optionalSpeed, roundSpeed } from "../format.js";
|
|
3
|
+
import { inDirectionArcs } from "@azohra/meteo.core";
|
|
4
|
+
//#region src/scene/recent-summaries.ts
|
|
5
|
+
const RECENT_SUMMARIES_CLASS = "meteo-recent-summaries";
|
|
6
|
+
/** hidden unless the source declares the capability; the no-samples words
|
|
7
|
+
* 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
|
+
function recentSummariesScene(input) {
|
|
22
|
+
const { favorableDirections, stationName, summaries, unit, words } = input;
|
|
23
|
+
const arcs = favorableDirections ?? [];
|
|
24
|
+
return {
|
|
25
|
+
className: RECENT_SUMMARIES_CLASS,
|
|
26
|
+
ariaLabel: words.aria.recentSummaries(stationName ?? ""),
|
|
27
|
+
panels: summaries.map((block) => {
|
|
28
|
+
const points = block.points;
|
|
29
|
+
const avgMps = points.length === 0 ? null : points.reduce((sum, point) => sum + point.windAvgMps, 0) / points.length;
|
|
30
|
+
const gusts = points.map((point) => point.windGustMps).filter((gust) => gust != null);
|
|
31
|
+
const lulls = points.map((point) => point.windLullMps).filter((lull) => lull != null);
|
|
32
|
+
const mean = vectorMeanWind(points);
|
|
33
|
+
return {
|
|
34
|
+
key: block.windowMinutes,
|
|
35
|
+
className: "meteo-recent-summary",
|
|
36
|
+
label: {
|
|
37
|
+
className: "meteo-microlabel",
|
|
38
|
+
text: words.recentWindowLabel(block.windowMinutes)
|
|
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
|
+
};
|
|
73
|
+
}
|
|
74
|
+
//#endregion
|
|
75
|
+
export { RECENT_SUMMARIES_CLASS, recentSummariesGate, recentSummariesScene };
|
package/dist/scene/rose.d.ts
CHANGED
package/dist/scene/rose.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { normalizeDegrees, thresholdsToMps } from "../derive.js";
|
|
2
2
|
import { speedBand, windRose } from "../geometry.js";
|
|
3
|
-
import { ROSE_CARDINAL_LETTERS, ROSE_INTERCARDINAL_BEARINGS, ROSE_PETAL_FILL, rosePetalPath, rosePolar, roseRingArcPath } from "../instruments.js";
|
|
3
|
+
import { ROSE_CARDINAL_LETTERS, ROSE_INTERCARDINAL_BEARINGS, ROSE_PETAL_FILL, roseBandPath, rosePetalPath, rosePolar, roseRingArcPath } from "../instruments.js";
|
|
4
4
|
//#region src/scene/rose.ts
|
|
5
5
|
const WIND_ROSE_CLASS = "meteo-wind-rose";
|
|
6
6
|
function windRoseSource(points, station) {
|
|
@@ -15,9 +15,10 @@ function windRoseGate(source, words) {
|
|
|
15
15
|
return { kind: "draw" };
|
|
16
16
|
}
|
|
17
17
|
function windRoseScene(input) {
|
|
18
|
-
const { favorableDirections,
|
|
18
|
+
const { favorableDirections, source, stationName, thresholds, words } = input;
|
|
19
19
|
const boundsMps = thresholds == null ? null : thresholdsToMps(thresholds);
|
|
20
|
-
const rose = windRose(source, sectorCount);
|
|
20
|
+
const rose = input.summary ?? windRose(source, input.sectorCount);
|
|
21
|
+
const sectorCount = rose.sectors.length;
|
|
21
22
|
const maxFrequency = Math.max(...rose.sectors.map((sector) => sector.frequency));
|
|
22
23
|
const halfWidthDeg = 360 / sectorCount / 2 * ROSE_PETAL_FILL;
|
|
23
24
|
const calmPercent = Math.round(rose.calmFraction * 100);
|
|
@@ -84,6 +85,20 @@ function windRoseScene(input) {
|
|
|
84
85
|
petals: rose.sectors.flatMap((sector) => {
|
|
85
86
|
if (sector.count === 0 || maxFrequency === 0) return [];
|
|
86
87
|
const radius = 16 + sector.frequency / maxFrequency * 54;
|
|
88
|
+
if (sector.bandCounts != null) {
|
|
89
|
+
let cumulative = 0;
|
|
90
|
+
return sector.bandCounts.flatMap((bandCount, band) => {
|
|
91
|
+
if (bandCount === 0) return [];
|
|
92
|
+
const innerRadius = 16 + cumulative / sector.count * (radius - 16);
|
|
93
|
+
cumulative += bandCount;
|
|
94
|
+
const outerRadius = 16 + cumulative / sector.count * (radius - 16);
|
|
95
|
+
return [{
|
|
96
|
+
key: `${sector.bearingDeg}-${band}`,
|
|
97
|
+
className: `meteo-wind-rose-petal meteo-band-${band}`,
|
|
98
|
+
d: roseBandPath(sector.bearingDeg, innerRadius, outerRadius, halfWidthDeg)
|
|
99
|
+
}];
|
|
100
|
+
});
|
|
101
|
+
}
|
|
87
102
|
const banded = boundsMps != null && sector.meanSpeedMps != null ? ` meteo-band-${speedBand(sector.meanSpeedMps, boundsMps)}` : "";
|
|
88
103
|
return [{
|
|
89
104
|
key: sector.bearingDeg,
|
|
@@ -58,7 +58,7 @@ function sampleStripScene(input) {
|
|
|
58
58
|
}),
|
|
59
59
|
calmNote: points.every((sample) => isCalm(sample.windMps)) ? calmNoteText(frame, words) : null,
|
|
60
60
|
rowLabels: windRowLabels(frame, words),
|
|
61
|
-
vanes: vaneCells(vanes, frame, scales, (vane) => String(shown(vane.windAvgMps))),
|
|
61
|
+
vanes: vaneCells(vanes, frame, scales, (vane) => String(shown(vane.windAvgMps)), input.favorableDirections),
|
|
62
62
|
ticks: vaneTickTexts(vanes, frame, scales, (timeMs) => formatTime(new Date(timeMs))),
|
|
63
63
|
hit: {
|
|
64
64
|
className: "meteo-hit",
|
package/dist/scene/trend.js
CHANGED
|
@@ -77,13 +77,8 @@ function trendScene(input) {
|
|
|
77
77
|
}
|
|
78
78
|
};
|
|
79
79
|
});
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
.25,
|
|
83
|
-
.5,
|
|
84
|
-
.75,
|
|
85
|
-
1
|
|
86
|
-
].map((fraction, index) => {
|
|
80
|
+
const tickCount = Math.max(2, Math.min(5, Math.floor((frame.right - frame.left) / 76)));
|
|
81
|
+
const ticks = Array.from({ length: tickCount }, (_, at) => at / (tickCount - 1)).map((fraction, index) => {
|
|
87
82
|
const timeMs = scales.startMs + fraction * scales.durationMs;
|
|
88
83
|
return {
|
|
89
84
|
key: index,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { compassDirection, isCalm, thresholdsToMps } from "../derive.js";
|
|
2
|
-
import { roundSpeed } from "../format.js";
|
|
3
2
|
import { bandPoints, compareTracePoints, compareWindow, historyGaps, isCalmHistory, thinVanes, windowPoints } from "../geometry.js";
|
|
4
|
-
import {
|
|
3
|
+
import { roundSpeed } from "../format.js";
|
|
4
|
+
import { calmNoteText, displaySpeedScales, gapHatchPattern, gapHatchRect, gradedMeanTrace, nightRects, speedGridLines, stretchedChartFrame, vaneCells, vaneGuideLines, vaneTickTexts, windRowLabels, windThresholdGuides, windZoneRects } from "./wind-plot.js";
|
|
5
5
|
//#region src/scene/wind-history.ts
|
|
6
6
|
const WIND_CHART_CLASS = "meteo-wind-chart";
|
|
7
7
|
function windChartGate(station, words) {
|
|
@@ -60,6 +60,7 @@ function windChartScene(input) {
|
|
|
60
60
|
}
|
|
61
61
|
},
|
|
62
62
|
zones: windZoneRects(boundsMps, frame, scales),
|
|
63
|
+
nightRects: nightRects(points, frame, scales, input.night),
|
|
63
64
|
grid: speedGridLines(frame, scales, shown),
|
|
64
65
|
thresholdGuides: windThresholdGuides(thresholds, boundsMps, unit, frame, scales, shown),
|
|
65
66
|
vaneGuides: vaneGuideLines(vanes, frame, scales),
|
|
@@ -76,7 +77,7 @@ function windChartScene(input) {
|
|
|
76
77
|
mean: gradedMeanTrace(points, scales, boundsMps),
|
|
77
78
|
calmNote: isCalmHistory(points) ? calmNoteText(frame, words) : null,
|
|
78
79
|
rowLabels: windRowLabels(frame, words),
|
|
79
|
-
vanes: vaneCells(vanes, frame, scales, (vane) => String(shown(vane.windAvgMps))),
|
|
80
|
+
vanes: vaneCells(vanes, frame, scales, (vane) => String(shown(vane.windAvgMps)), input.favorableDirections),
|
|
80
81
|
ticks: vaneTickTexts(vanes, frame, scales, (timeMs) => formatTime(new Date(timeMs))),
|
|
81
82
|
hit: {
|
|
82
83
|
className: "meteo-hit",
|
package/dist/scene/wind-plot.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { compassDirection, speedToMps } from "../derive.js";
|
|
2
2
|
import { averagePoints, chartFrame, chartScales, speedBand, stretchFrame, tickAnchor, vanePath, vaneTicks } from "../geometry.js";
|
|
3
|
+
import { inDirectionArcs, solarEventsForDate } from "@azohra/meteo.core";
|
|
3
4
|
//#region src/scene/wind-plot.ts
|
|
4
5
|
function stretchedChartFrame(width, plotHeight) {
|
|
5
6
|
const core = chartFrame(width);
|
|
@@ -165,8 +166,42 @@ function windRowLabels(frame, words) {
|
|
|
165
166
|
}
|
|
166
167
|
};
|
|
167
168
|
}
|
|
168
|
-
function
|
|
169
|
-
|
|
169
|
+
function nightRects(points, frame, scales, night) {
|
|
170
|
+
if (night?.latitude == null || night?.longitude == null || points.length < 2) return [];
|
|
171
|
+
const startMs = Date.parse(points[0].observedAt);
|
|
172
|
+
const endMs = Date.parse(points[points.length - 1].observedAt);
|
|
173
|
+
const rects = [];
|
|
174
|
+
const dayMs = 864e5;
|
|
175
|
+
for (let dayStart = Math.floor(startMs / dayMs - 1) * dayMs; dayStart <= endMs; dayStart += dayMs) {
|
|
176
|
+
const today = solarEventsForDate(new Date(dayStart).toISOString().slice(0, 10), night.latitude, night.longitude);
|
|
177
|
+
const tomorrow = solarEventsForDate(new Date(dayStart + dayMs).toISOString().slice(0, 10), night.latitude, night.longitude);
|
|
178
|
+
if (today == null || tomorrow == null) continue;
|
|
179
|
+
const darkFrom = Math.max(today.sunset.getTime(), startMs);
|
|
180
|
+
const darkTo = Math.min(tomorrow.sunrise.getTime(), endMs);
|
|
181
|
+
if (darkFrom >= darkTo) continue;
|
|
182
|
+
const x = scales.xAtMs(darkFrom);
|
|
183
|
+
rects.push({
|
|
184
|
+
key: dayStart,
|
|
185
|
+
className: "meteo-night",
|
|
186
|
+
height: frame.plotBottom - frame.plotTop,
|
|
187
|
+
width: scales.xAtMs(darkTo) - x,
|
|
188
|
+
x,
|
|
189
|
+
y: frame.plotTop
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
return rects;
|
|
193
|
+
}
|
|
194
|
+
const COMPASS_LABEL_PX = 30;
|
|
195
|
+
const VALUE_LABEL_PX = 24;
|
|
196
|
+
const TIME_LABEL_PX = 76;
|
|
197
|
+
function vaneCells(vanes, frame, scales, valueText, favorableDirections) {
|
|
198
|
+
const verdict = (directionDeg) => favorableDirections == null || favorableDirections.length === 0 ? "" : inDirectionArcs(directionDeg, favorableDirections) ? " meteo-wind-vane-favorable" : " meteo-wind-vane-unfavorable";
|
|
199
|
+
const pitch = vanes.length === 0 ? Infinity : (frame.right - frame.left) / vanes.length;
|
|
200
|
+
const step = (needPx) => Math.max(1, Math.ceil(needPx / pitch));
|
|
201
|
+
const labelStep = step(COMPASS_LABEL_PX);
|
|
202
|
+
const valueStep = step(VALUE_LABEL_PX);
|
|
203
|
+
const speaks = (index, every) => (vanes.length - 1 - index) % every === 0;
|
|
204
|
+
return vanes.map((vane, index) => ({
|
|
170
205
|
key: vane.midMs,
|
|
171
206
|
mark: vane.windDirectionDeg == null ? {
|
|
172
207
|
kind: "calm",
|
|
@@ -179,27 +214,27 @@ function vaneCells(vanes, frame, scales, valueText) {
|
|
|
179
214
|
}
|
|
180
215
|
} : {
|
|
181
216
|
kind: "vane",
|
|
182
|
-
className:
|
|
217
|
+
className: `meteo-wind-vane${verdict(vane.windDirectionDeg)}`,
|
|
183
218
|
d: vanePath(scales.xAtMs(vane.midMs), frame.vaneRow, vane.windDirectionDeg)
|
|
184
219
|
},
|
|
185
|
-
label: {
|
|
220
|
+
label: speaks(index, labelStep) ? {
|
|
186
221
|
className: "meteo-wind-vane-label",
|
|
187
222
|
anchor: "middle",
|
|
188
223
|
x: scales.xAtMs(vane.midMs),
|
|
189
224
|
y: frame.vaneLabelRow + 4,
|
|
190
225
|
text: vane.windDirectionDeg == null ? "—" : compassDirection(vane.windDirectionDeg)
|
|
191
|
-
},
|
|
192
|
-
value: {
|
|
226
|
+
} : null,
|
|
227
|
+
value: speaks(index, valueStep) ? {
|
|
193
228
|
className: "meteo-wind-vane-value",
|
|
194
229
|
anchor: "middle",
|
|
195
230
|
x: scales.xAtMs(vane.midMs),
|
|
196
231
|
y: frame.valueRow + 4,
|
|
197
232
|
text: valueText(vane)
|
|
198
|
-
}
|
|
233
|
+
} : null
|
|
199
234
|
}));
|
|
200
235
|
}
|
|
201
236
|
function vaneTickTexts(vanes, frame, scales, labelText) {
|
|
202
|
-
const ticks = vaneTicks(vanes, scales);
|
|
237
|
+
const ticks = vaneTicks(vanes, scales, Math.floor((frame.right - frame.left) / TIME_LABEL_PX));
|
|
203
238
|
return ticks.map(({ index, timeMs, x }) => ({
|
|
204
239
|
key: index,
|
|
205
240
|
className: "meteo-tick",
|
|
@@ -210,4 +245,4 @@ function vaneTickTexts(vanes, frame, scales, labelText) {
|
|
|
210
245
|
}));
|
|
211
246
|
}
|
|
212
247
|
//#endregion
|
|
213
|
-
export { calmNoteText, displaySpeedScales, gapHatchPattern, gapHatchRect, gradedMeanTrace, speedGridLines, stretchedChartFrame, vaneCells, vaneGuideLines, vaneTickTexts, windRowLabels, windThresholdGuides, windZoneRects };
|
|
248
|
+
export { calmNoteText, displaySpeedScales, gapHatchPattern, gapHatchRect, gradedMeanTrace, nightRects, speedGridLines, stretchedChartFrame, vaneCells, vaneGuideLines, vaneTickTexts, windRowLabels, windThresholdGuides, windZoneRects };
|