@azohra/meteo.station 0.3.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/dist/client/climatology.d.ts +27 -0
  2. package/dist/client/climatology.js +83 -0
  3. package/dist/client/history.d.ts +53 -0
  4. package/dist/client/history.js +114 -0
  5. package/dist/client/index.d.ts +3 -1
  6. package/dist/client/index.js +3 -1
  7. package/dist/client/live.js +15 -0
  8. package/dist/climatology.d.ts +61 -0
  9. package/dist/climatology.js +208 -0
  10. package/dist/contract-climatology.d.ts +69 -0
  11. package/dist/contract-climatology.js +50 -0
  12. package/dist/contract.d.ts +234 -1
  13. package/dist/contract.js +52 -4
  14. package/dist/derive.d.ts +23 -1
  15. package/dist/derive.js +43 -4
  16. package/dist/display.d.ts +4 -0
  17. package/dist/display.js +2 -1
  18. package/dist/elements/elements/AirExtremesElement.d.ts +8 -0
  19. package/dist/elements/elements/AirExtremesElement.js +33 -0
  20. package/dist/elements/elements/ClimatologyDailyPatternElement.d.ts +15 -0
  21. package/dist/elements/elements/ClimatologyDailyPatternElement.js +84 -0
  22. package/dist/elements/elements/ClimatologyRoseElement.d.ts +14 -0
  23. package/dist/elements/elements/ClimatologyRoseElement.js +51 -0
  24. package/dist/elements/elements/CompassFanElement.d.ts +14 -0
  25. package/dist/elements/elements/CompassFanElement.js +92 -0
  26. package/dist/elements/elements/DailyPatternElement.d.ts +1 -0
  27. package/dist/elements/elements/DailyPatternElement.js +20 -12
  28. package/dist/elements/elements/DialElement.js +14 -3
  29. package/dist/elements/elements/FavorableShareElement.d.ts +14 -0
  30. package/dist/elements/elements/FavorableShareElement.js +47 -0
  31. package/dist/elements/elements/RecentSummariesElement.d.ts +14 -0
  32. package/dist/elements/elements/RecentSummariesElement.js +54 -0
  33. package/dist/elements/elements/StationFeedElement.d.ts +3 -0
  34. package/dist/elements/elements/StationFeedElement.js +13 -2
  35. package/dist/elements/elements/WindHistoryChartElement.js +16 -3
  36. package/dist/elements/elements/WindRoseElement.d.ts +1 -3
  37. package/dist/elements/elements/WindRoseElement.js +60 -62
  38. package/dist/elements/elements/atoms.js +3 -3
  39. package/dist/elements/index.d.ts +13 -1
  40. package/dist/elements/index.js +15 -3
  41. package/dist/elements/lib/ambient.d.ts +2 -0
  42. package/dist/elements/lib/attributes.js +24 -1
  43. package/dist/elements/lib/base.d.ts +3 -0
  44. package/dist/elements/lib/base.js +14 -2
  45. package/dist/endpoints.d.ts +7 -1
  46. package/dist/endpoints.js +13 -1
  47. package/dist/geometry.d.ts +22 -3
  48. package/dist/geometry.js +41 -5
  49. package/dist/index.d.ts +8 -6
  50. package/dist/index.js +8 -6
  51. package/dist/instruments.d.ts +7 -5
  52. package/dist/instruments.js +20 -7
  53. package/dist/merge-current.js +2 -1
  54. package/dist/react/components/AirExtremes.d.ts +16 -0
  55. package/dist/react/components/AirExtremes.js +38 -0
  56. package/dist/react/components/ClimatologyDailyPattern.d.ts +20 -0
  57. package/dist/react/components/ClimatologyDailyPattern.js +59 -0
  58. package/dist/react/components/ClimatologyRose.d.ts +18 -0
  59. package/dist/react/components/ClimatologyRose.js +45 -0
  60. package/dist/react/components/CompassFan.d.ts +17 -0
  61. package/dist/react/components/CompassFan.js +93 -0
  62. package/dist/react/components/DailyPattern.d.ts +4 -1
  63. package/dist/react/components/DailyPattern.js +13 -6
  64. package/dist/react/components/Dial.d.ts +3 -1
  65. package/dist/react/components/Dial.js +13 -2
  66. package/dist/react/components/FavorableShare.d.ts +14 -0
  67. package/dist/react/components/FavorableShare.js +43 -0
  68. package/dist/react/components/RecentSummaries.d.ts +19 -0
  69. package/dist/react/components/RecentSummaries.js +65 -0
  70. package/dist/react/components/StationFeedProvider.d.ts +4 -1
  71. package/dist/react/components/StationFeedProvider.js +5 -3
  72. package/dist/react/components/WindHistoryChart.d.ts +6 -1
  73. package/dist/react/components/WindHistoryChart.js +18 -3
  74. package/dist/react/components/WindRose.d.ts +4 -2
  75. package/dist/react/components/WindRose.js +80 -71
  76. package/dist/react/components/WindSampleStrip.d.ts +3 -1
  77. package/dist/react/components/WindSampleStrip.js +6 -3
  78. package/dist/react/components/atoms.d.ts +4 -1
  79. package/dist/react/components/atoms.js +6 -3
  80. package/dist/react/hooks/useStationClimatology.d.ts +18 -0
  81. package/dist/react/hooks/useStationClimatology.js +25 -0
  82. package/dist/react/index.d.ts +10 -3
  83. package/dist/react/index.js +9 -2
  84. package/dist/scene/air-extremes.d.ts +2 -0
  85. package/dist/scene/air-extremes.js +42 -0
  86. package/dist/scene/atoms.d.ts +2 -1
  87. package/dist/scene/atoms.js +6 -4
  88. package/dist/scene/climatology-pattern.d.ts +6 -0
  89. package/dist/scene/climatology-pattern.js +35 -0
  90. package/dist/scene/climatology-rose.d.ts +5 -0
  91. package/dist/scene/climatology-rose.js +49 -0
  92. package/dist/scene/compass-fan.d.ts +3 -0
  93. package/dist/scene/compass-fan.js +115 -0
  94. package/dist/scene/daily-pattern.d.ts +1 -0
  95. package/dist/scene/daily-pattern.js +20 -6
  96. package/dist/scene/dial.d.ts +1 -0
  97. package/dist/scene/dial.js +16 -3
  98. package/dist/scene/favorable-share.d.ts +3 -0
  99. package/dist/scene/favorable-share.js +41 -0
  100. package/dist/scene/index.d.ts +9 -3
  101. package/dist/scene/recent-summaries.d.ts +4 -0
  102. package/dist/scene/recent-summaries.js +75 -0
  103. package/dist/scene/rose.d.ts +2 -1
  104. package/dist/scene/rose.js +18 -3
  105. package/dist/scene/sample-strip.d.ts +1 -0
  106. package/dist/scene/sample-strip.js +1 -1
  107. package/dist/scene/wind-history.d.ts +1 -0
  108. package/dist/scene/wind-history.js +4 -3
  109. package/dist/scene/wind-plot.d.ts +1 -0
  110. package/dist/scene/wind-plot.js +30 -3
  111. package/dist/server/adapter.d.ts +2 -1
  112. package/dist/server/adapter.js +2 -1
  113. package/dist/server/adapters/windnerd-climatology.d.ts +33 -0
  114. package/dist/server/adapters/windnerd-climatology.js +81 -0
  115. package/dist/server/adapters/windnerd-live.js +21 -13
  116. package/dist/server/adapters/windnerd.d.ts +31 -4
  117. package/dist/server/adapters/windnerd.js +197 -19
  118. package/dist/server/feed.d.ts +44 -2
  119. package/dist/server/feed.js +63 -2
  120. package/dist/server/handler.d.ts +11 -1
  121. package/dist/server/handler.js +83 -2
  122. package/dist/server/index.d.ts +4 -3
  123. package/dist/server/index.js +4 -3
  124. package/dist/strings.d.ts +12 -0
  125. package/dist/strings.js +12 -0
  126. package/package.json +2 -2
  127. package/schema/example-climatology.json +86 -0
  128. package/schema/example-history.json +38 -0
  129. package/schema/stationclimatology.schema.json +195 -0
  130. package/schema/stationcurrent.schema.json +173 -0
  131. package/schema/stationfeed.schema.json +173 -0
  132. package/schema/stationhistory.schema.json +186 -0
  133. package/schema/stationlive.schema.json +202 -0
  134. package/styles.css +215 -0
@@ -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,7 @@
1
1
  import "../contract.js";
2
2
  import "../derive.js";
3
3
  import "../strings.js";
4
+ import "../instruments.js";
4
5
  import "../geometry.js";
5
6
  import "./chart.js";
6
7
  import "./wind-plot.js";
@@ -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 { hatchId, periodMinutes, plotHeight, points, slotMinutes, stationName, thresholds, unit, utcOffsetMinutes, width, words } = input;
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
+ expectedSamples
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, expectedSamples } = coverage;
47
61
  const frame = stretchedChartFrame(width, plotHeight);
48
62
  const scales = displaySpeedScales(synthetic, frame, unit);
49
63
  const vanes = thinVanes(synthetic);
@@ -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 };
@@ -1,4 +1,5 @@
1
1
  import "../contract.js";
2
2
  import "../derive.js";
3
3
  import "../strings.js";
4
+ import "../instruments.js";
4
5
  import "./wind-plot.js";
@@ -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 { DIAL_CARDINALS, DIAL_COUNTERWEIGHT_RADIUS, dialNeedlePoints, dialPolar, dialScaleMaxMps, dialSpeedArcPath } from "../instruments.js";
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,3 @@
1
+ import "../contract.js";
2
+ import "../strings.js";
3
+ import "../instruments.js";
@@ -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 };
@@ -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,4 @@
1
+ import "../contract.js";
2
+ import "../derive.js";
3
+ import "../strings.js";
4
+ import "../instruments.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 };
@@ -1,4 +1,5 @@
1
1
  import "../contract.js";
2
2
  import "../derive.js";
3
3
  import "../strings.js";
4
- import "../instruments.js";
4
+ import "../instruments.js";
5
+ import "../geometry.js";
@@ -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, sectorCount, source, stationName, thresholds, words } = input;
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,
@@ -1,6 +1,7 @@
1
1
  import "../contract.js";
2
2
  import "../derive.js";
3
3
  import "../strings.js";
4
+ import "../instruments.js";
4
5
  import "../geometry.js";
5
6
  import "./chart.js";
6
7
  import "./wind-plot.js";
@@ -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",
@@ -1,6 +1,7 @@
1
1
  import "../contract.js";
2
2
  import "../derive.js";
3
3
  import "../strings.js";
4
+ import "../instruments.js";
4
5
  import "../geometry.js";
5
6
  import "./chart.js";
6
7
  import "./wind-plot.js";
@@ -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 { calmNoteText, displaySpeedScales, gapHatchPattern, gapHatchRect, gradedMeanTrace, speedGridLines, stretchedChartFrame, vaneCells, vaneGuideLines, vaneTickTexts, windRowLabels, windThresholdGuides, windZoneRects } from "./wind-plot.js";
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",
@@ -1,5 +1,6 @@
1
1
  import "../contract.js";
2
2
  import "../derive.js";
3
3
  import "../strings.js";
4
+ import "../instruments.js";
4
5
  import "../geometry.js";
5
6
  import "./chart.js";
@@ -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,7 +166,33 @@ function windRowLabels(frame, words) {
165
166
  }
166
167
  };
167
168
  }
168
- function vaneCells(vanes, frame, scales, valueText) {
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
+ function vaneCells(vanes, frame, scales, valueText, favorableDirections) {
195
+ const verdict = (directionDeg) => favorableDirections == null || favorableDirections.length === 0 ? "" : inDirectionArcs(directionDeg, favorableDirections) ? " meteo-wind-vane-favorable" : " meteo-wind-vane-unfavorable";
169
196
  return vanes.map((vane) => ({
170
197
  key: vane.midMs,
171
198
  mark: vane.windDirectionDeg == null ? {
@@ -179,7 +206,7 @@ function vaneCells(vanes, frame, scales, valueText) {
179
206
  }
180
207
  } : {
181
208
  kind: "vane",
182
- className: "meteo-wind-vane",
209
+ className: `meteo-wind-vane${verdict(vane.windDirectionDeg)}`,
183
210
  d: vanePath(scales.xAtMs(vane.midMs), frame.vaneRow, vane.windDirectionDeg)
184
211
  },
185
212
  label: {
@@ -210,4 +237,4 @@ function vaneTickTexts(vanes, frame, scales, labelText) {
210
237
  }));
211
238
  }
212
239
  //#endregion
213
- export { calmNoteText, displaySpeedScales, gapHatchPattern, gapHatchRect, gradedMeanTrace, speedGridLines, stretchedChartFrame, vaneCells, vaneGuideLines, vaneTickTexts, windRowLabels, windThresholdGuides, windZoneRects };
240
+ export { calmNoteText, displaySpeedScales, gapHatchPattern, gapHatchRect, gradedMeanTrace, nightRects, speedGridLines, stretchedChartFrame, vaneCells, vaneGuideLines, vaneTickTexts, windRowLabels, windThresholdGuides, windZoneRects };
@@ -1,4 +1,4 @@
1
- import { History, LiveSamples, Reading, Station, StationMeta, StationTelemetry } from "../contract.js";
1
+ import { History, LiveSamples, Reading, RecentSummary, Station, StationMeta, StationTelemetry } from "../contract.js";
2
2
  import { ResolvedEnvironment, ServerEnvironment } from "./environment.js";
3
3
  //#region src/server/adapter.d.ts
4
4
  type StationAdapterMode = "full" | "current";
@@ -18,6 +18,7 @@ type StationAdapterResult = {
18
18
  readonly history: History | null;
19
19
  readonly telemetry?: StationTelemetry | null;
20
20
  readonly samples?: LiveSamples | null;
21
+ readonly recentSummaries?: RecentSummary[] | null;
21
22
  readonly meta?: Partial<StationMeta>;
22
23
  };
23
24
  type StationAdapterDefinition<C, O extends StationAdapterOptions = StationAdapterOptions> = {
@@ -22,7 +22,8 @@ function defineStationAdapter(definition) {
22
22
  reading: result.reading,
23
23
  history: mode === "current" ? null : result.history,
24
24
  telemetry: result.telemetry ?? null,
25
- samples: result.samples ?? null
25
+ samples: result.samples ?? null,
26
+ recentSummaries: result.recentSummaries ?? null
26
27
  };
27
28
  } catch (error) {
28
29
  logUpstreamFailure(environment, `${meta.name} live wind unavailable`, error, { station: meta.id });
@@ -0,0 +1,33 @@
1
+ import { StationClimatology } from "../../contract-climatology.js";
2
+ import { SpeedThresholds } from "../../derive.js";
3
+ import { ServerEnvironment } from "../environment.js";
4
+ import { WindnerdStationConfig } from "../config.js";
5
+ //#region src/server/adapters/windnerd-climatology.d.ts
6
+ declare const CLIMATOLOGY_RECORD_PERIOD_MINUTES = 180;
7
+ declare const CLIMATOLOGY_DEFAULT_YEARS = 8;
8
+ declare const CLIMATOLOGY_DEFAULT_SECTOR_COUNT = 16;
9
+ type WindnerdClimatologyOptions = {
10
+ /** The consumer's speed-band bounds — a judgment parameter with no
11
+ * default; it shapes every bandCounts stack and joins the cache key. */
12
+ thresholds: SpeedThresholds;
13
+ /** Calendar years to reach back, the current one included. */
14
+ years?: number;
15
+ sectorCount?: number;
16
+ /** Slot width in minutes: a multiple of the 180-minute record period that
17
+ * divides 1440 (180, 360, or 720). */
18
+ slotMinutes?: number;
19
+ environment?: ServerEnvironment;
20
+ recordsUrl?: string;
21
+ liveUrl?: string;
22
+ };
23
+ /**
24
+ * Builds the station's climatology cube from the vendor's yearly archive:
25
+ * one records request per calendar year (closed years cached ~30 days, the
26
+ * running year 6 hours), folded into (month, slot, sector) sums bucketed in
27
+ * the station's STANDARD time. Any year the upstream refuses fails the
28
+ * whole document — a silently missing year would read as an outage, and
29
+ * plausible-but-wrong is the named failure mode.
30
+ */
31
+ declare function loadWindnerdClimatology(config: WindnerdStationConfig, options: WindnerdClimatologyOptions): Promise<StationClimatology>;
32
+ //#endregion
33
+ export { CLIMATOLOGY_DEFAULT_SECTOR_COUNT, CLIMATOLOGY_DEFAULT_YEARS, CLIMATOLOGY_RECORD_PERIOD_MINUTES, WindnerdClimatologyOptions, loadWindnerdClimatology };