@azohra/meteo.station 0.6.0 → 0.7.1
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/air.d.ts +4 -7
- package/dist/air.js +1 -2
- package/dist/client/climatology.d.ts +4 -7
- package/dist/client/climatology.js +1 -2
- package/dist/client/history.d.ts +14 -17
- package/dist/client/history.js +1 -2
- package/dist/client/live.d.ts +9 -11
- package/dist/client/live.js +1 -2
- package/dist/client/poll.d.ts +9 -12
- package/dist/client/poll.js +1 -2
- package/dist/client/stores.d.ts +8 -10
- package/dist/client/stores.js +1 -2
- package/dist/client/ticker.d.ts +1 -4
- package/dist/client/ticker.js +1 -2
- package/dist/climatology.d.ts +13 -15
- package/dist/climatology.js +1 -2
- package/dist/connectivity.d.ts +9 -12
- package/dist/connectivity.js +1 -2
- package/dist/contract-climatology.d.ts +11 -14
- package/dist/contract-climatology.js +1 -2
- package/dist/contract.d.ts +148 -151
- package/dist/contract.js +1 -2
- package/dist/derive.d.ts +24 -26
- package/dist/derive.js +5 -6
- package/dist/display.d.ts +6 -9
- package/dist/display.js +1 -2
- package/dist/elements/elements/AirExtremesElement.d.ts +2 -5
- package/dist/elements/elements/AirExtremesElement.js +6 -20
- package/dist/elements/elements/AirMatrixElement.d.ts +2 -5
- package/dist/elements/elements/AirMatrixElement.js +7 -33
- package/dist/elements/elements/ClimatologyDailyPatternElement.d.ts +2 -5
- package/dist/elements/elements/ClimatologyDailyPatternElement.js +18 -14
- package/dist/elements/elements/ClimatologyRoseElement.d.ts +2 -5
- package/dist/elements/elements/ClimatologyRoseElement.js +6 -17
- package/dist/elements/elements/CompassFanElement.d.ts +2 -5
- package/dist/elements/elements/CompassFanElement.js +6 -66
- package/dist/elements/elements/CurrentConditionsElement.d.ts +2 -5
- package/dist/elements/elements/CurrentConditionsElement.js +8 -28
- package/dist/elements/elements/DailyPatternElement.d.ts +2 -6
- package/dist/elements/elements/DailyPatternElement.js +7 -122
- package/dist/elements/elements/DialElement.d.ts +2 -5
- package/dist/elements/elements/DialElement.js +4 -97
- package/dist/elements/elements/FavorableShareElement.d.ts +2 -5
- package/dist/elements/elements/FavorableShareElement.js +7 -23
- package/dist/elements/elements/FreshnessBadgeElement.d.ts +2 -5
- package/dist/elements/elements/FreshnessBadgeElement.js +1 -2
- package/dist/elements/elements/RecentSummariesElement.d.ts +2 -5
- package/dist/elements/elements/RecentSummariesElement.js +7 -25
- package/dist/elements/elements/SparklineElement.d.ts +2 -6
- package/dist/elements/elements/SparklineElement.js +5 -41
- package/dist/elements/elements/StationCardElement.d.ts +6 -8
- package/dist/elements/elements/StationCardElement.js +5 -20
- package/dist/elements/elements/StationFeedElement.d.ts +2 -5
- package/dist/elements/elements/StationFeedElement.js +5 -4
- package/dist/elements/elements/StationStripElement.d.ts +2 -5
- package/dist/elements/elements/StationStripElement.js +5 -20
- package/dist/elements/elements/StationTableElement.d.ts +3 -6
- package/dist/elements/elements/StationTableElement.js +16 -53
- package/dist/elements/elements/TrendChartElement.d.ts +2 -5
- package/dist/elements/elements/TrendChartElement.js +22 -71
- package/dist/elements/elements/WindArrowElement.d.ts +2 -5
- package/dist/elements/elements/WindArrowElement.js +1 -2
- package/dist/elements/elements/WindHistoryChartElement.d.ts +2 -5
- package/dist/elements/elements/WindHistoryChartElement.js +24 -166
- package/dist/elements/elements/WindRoseElement.d.ts +2 -6
- package/dist/elements/elements/WindRoseElement.js +7 -72
- package/dist/elements/elements/atoms.d.ts +10 -12
- package/dist/elements/elements/atoms.js +12 -40
- package/dist/elements/index.d.ts +3 -5
- package/dist/elements/index.js +4 -5
- package/dist/elements/lib/ambient.d.ts +2 -5
- package/dist/elements/lib/ambient.js +1 -2
- package/dist/elements/lib/attributes.js +1 -2
- package/dist/elements/lib/base.d.ts +3 -6
- package/dist/elements/lib/base.js +1 -2
- package/dist/elements/lib/context.js +1 -2
- package/dist/elements/lib/fragments.js +9 -39
- package/dist/elements/lib/h.js +2 -3
- package/dist/elements/lib/pinned-cursor.js +1 -2
- package/dist/elements/lib/render.js +29 -0
- package/dist/elements/register.js +1 -2
- package/dist/endpoints.d.ts +6 -9
- package/dist/endpoints.js +1 -2
- package/dist/fixtures.d.ts +7 -10
- package/dist/fixtures.js +1 -2
- package/dist/format.d.ts +11 -14
- package/dist/format.js +1 -2
- package/dist/geometry.d.ts +36 -38
- package/dist/geometry.js +3 -3
- package/dist/instruments.d.ts +37 -40
- package/dist/instruments.js +3 -4
- package/dist/merge-current.d.ts +4 -7
- package/dist/merge-current.js +1 -2
- package/dist/react/components/AirExtremes.d.ts +2 -5
- package/dist/react/components/AirExtremes.js +6 -24
- package/dist/react/components/AirMatrix.d.ts +2 -5
- package/dist/react/components/AirMatrix.js +11 -45
- package/dist/react/components/ClimatologyDailyPattern.d.ts +2 -5
- package/dist/react/components/ClimatologyDailyPattern.js +20 -15
- package/dist/react/components/ClimatologyRose.d.ts +2 -5
- package/dist/react/components/ClimatologyRose.js +12 -30
- package/dist/react/components/CompassFan.d.ts +2 -5
- package/dist/react/components/CompassFan.js +7 -75
- package/dist/react/components/CurrentConditions.d.ts +2 -5
- package/dist/react/components/CurrentConditions.js +12 -76
- package/dist/react/components/DailyPattern.d.ts +3 -8
- package/dist/react/components/DailyPattern.js +11 -151
- package/dist/react/components/Dial.d.ts +2 -5
- package/dist/react/components/Dial.js +6 -120
- package/dist/react/components/FavorableShare.d.ts +2 -5
- package/dist/react/components/FavorableShare.js +7 -29
- package/dist/react/components/FreshnessBadge.d.ts +2 -5
- package/dist/react/components/FreshnessBadge.js +6 -14
- package/dist/react/components/Readout.d.ts +2 -5
- package/dist/react/components/Readout.js +1 -2
- package/dist/react/components/RecentSummaries.d.ts +2 -5
- package/dist/react/components/RecentSummaries.js +7 -46
- package/dist/react/components/SceneTree.js +37 -0
- package/dist/react/components/Sparkline.d.ts +2 -5
- package/dist/react/components/Sparkline.js +4 -41
- package/dist/react/components/StationCard.d.ts +8 -10
- package/dist/react/components/StationCard.js +6 -47
- package/dist/react/components/StationFeedProvider.d.ts +3 -6
- package/dist/react/components/StationFeedProvider.js +1 -2
- package/dist/react/components/StationStrip.d.ts +2 -5
- package/dist/react/components/StationStrip.js +6 -62
- package/dist/react/components/StationTable.d.ts +3 -6
- package/dist/react/components/StationTable.js +22 -77
- package/dist/react/components/TrendChart.d.ts +2 -5
- package/dist/react/components/TrendChart.js +9 -65
- package/dist/react/components/WindArrow.d.ts +2 -5
- package/dist/react/components/WindArrow.js +4 -17
- package/dist/react/components/WindHistoryChart.d.ts +2 -5
- package/dist/react/components/WindHistoryChart.js +9 -184
- package/dist/react/components/WindRose.d.ts +2 -7
- package/dist/react/components/WindRose.js +7 -91
- package/dist/react/components/WindSampleStrip.d.ts +2 -5
- package/dist/react/components/WindSampleStrip.js +9 -117
- package/dist/react/components/atoms.d.ts +12 -14
- package/dist/react/components/atoms.js +13 -50
- package/dist/react/hooks/useFreshness.d.ts +1 -4
- package/dist/react/hooks/useFreshness.js +1 -2
- package/dist/react/hooks/useMeasuredChartWidth.d.ts +2 -5
- package/dist/react/hooks/useMeasuredChartWidth.js +1 -2
- package/dist/react/hooks/usePolledJson.js +1 -2
- package/dist/react/hooks/useStation.d.ts +2 -5
- package/dist/react/hooks/useStation.js +1 -2
- package/dist/react/hooks/useStationClimatology.d.ts +2 -5
- package/dist/react/hooks/useStationClimatology.js +1 -2
- package/dist/react/hooks/useStationCurrent.d.ts +2 -5
- package/dist/react/hooks/useStationCurrent.js +4 -4
- package/dist/react/hooks/useStationFeed.d.ts +2 -5
- package/dist/react/hooks/useStationFeed.js +4 -4
- package/dist/react/hooks/useStationLive.d.ts +2 -5
- package/dist/react/hooks/useStationLive.js +1 -2
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.js +5 -5
- package/dist/react/lib/cells.js +5 -26
- package/dist/react/lib/use-pinned-cursor.js +1 -2
- package/dist/samples.d.ts +8 -11
- package/dist/samples.js +1 -2
- package/dist/scene/air-extremes.js +13 -29
- package/dist/scene/air-matrix.js +46 -60
- package/dist/scene/atoms.js +1 -2
- package/dist/scene/card.js +15 -42
- package/dist/scene/cells.d.ts +4 -0
- package/dist/scene/cells.js +50 -0
- package/dist/scene/chart.d.ts +2 -5
- package/dist/scene/chart.js +3 -3
- package/dist/scene/climatology-pattern.d.ts +1 -2
- package/dist/scene/climatology-pattern.js +11 -13
- package/dist/scene/climatology-rose.d.ts +1 -2
- package/dist/scene/climatology-rose.js +15 -35
- package/dist/scene/compass-fan.js +29 -102
- package/dist/scene/current.d.ts +2 -1
- package/dist/scene/current.js +30 -58
- package/dist/scene/daily-pattern.d.ts +1 -3
- package/dist/scene/daily-pattern.js +21 -29
- package/dist/scene/dial-parts.d.ts +1 -0
- package/dist/scene/dial-parts.js +69 -0
- package/dist/scene/dial.d.ts +1 -2
- package/dist/scene/dial.js +49 -138
- package/dist/scene/favorable-share.js +17 -35
- package/dist/scene/glyphs.js +21 -18
- package/dist/scene/index.d.ts +5 -3
- package/dist/scene/node.js +18 -0
- package/dist/scene/recent-summaries.js +27 -65
- package/dist/scene/rose.js +90 -119
- package/dist/scene/sample-strip.d.ts +1 -2
- package/dist/scene/sample-strip.js +36 -38
- package/dist/scene/sparkline.js +32 -42
- package/dist/scene/strip.js +19 -59
- package/dist/scene/table.js +48 -71
- package/dist/scene/trend.d.ts +1 -2
- package/dist/scene/trend.js +30 -57
- package/dist/scene/wind-history.d.ts +1 -2
- package/dist/scene/wind-history.js +42 -53
- package/dist/scene/wind-plot.js +71 -142
- package/dist/server/adapter.d.ts +7 -10
- package/dist/server/adapter.js +1 -2
- package/dist/server/adapters/campbell.d.ts +18 -20
- package/dist/server/adapters/campbell.js +2 -3
- package/dist/server/adapters/ecowitt.d.ts +12 -15
- package/dist/server/adapters/ecowitt.js +1 -2
- package/dist/server/adapters/tempest.d.ts +10 -13
- package/dist/server/adapters/tempest.js +1 -2
- package/dist/server/adapters/windnerd-climatology.d.ts +5 -8
- package/dist/server/adapters/windnerd-climatology.js +5 -5
- package/dist/server/adapters/windnerd-live.d.ts +2 -5
- package/dist/server/adapters/windnerd-live.js +4 -4
- package/dist/server/adapters/windnerd.d.ts +30 -33
- package/dist/server/adapters/windnerd.js +2 -3
- package/dist/server/config.d.ts +61 -63
- package/dist/server/config.js +1 -2
- package/dist/server/environment.d.ts +20 -22
- package/dist/server/environment.js +1 -2
- package/dist/server/feed.d.ts +19 -21
- package/dist/server/feed.js +1 -2
- package/dist/server/handler.d.ts +4 -7
- package/dist/server/handler.js +1 -2
- package/dist/server/hologram.d.ts +9 -12
- package/dist/server/hologram.js +3 -3
- package/dist/server/live.d.ts +2 -5
- package/dist/server/live.js +1 -2
- package/dist/sse.js +1 -2
- package/dist/strings.d.ts +8 -11
- package/dist/strings.js +1 -2
- package/dist/windnerd.d.ts +4 -7
- package/dist/windnerd.js +1 -2
- package/package.json +12 -17
- package/schema/README.md +1 -1
- package/schema/stationclimatology.schema.json +64 -61
- package/schema/stationcurrent.schema.json +68 -156
- package/schema/stationfeed.schema.json +71 -163
- package/schema/stationhistory.schema.json +37 -46
- package/schema/stationlive.schema.json +221 -306
package/dist/scene/wind-plot.js
CHANGED
|
@@ -1,7 +1,26 @@
|
|
|
1
1
|
import { compassDirection, speedToMps } from "../derive.js";
|
|
2
2
|
import { averagePoints, chartFrame, chartScales, speedBand, stretchFrame, tickAnchor, vanePath, vaneTicks } from "../geometry.js";
|
|
3
|
+
import { el, keyed } from "./node.js";
|
|
3
4
|
import { inDirectionArcs, solarEventsForDate } from "@azohra/meteo.core";
|
|
4
|
-
|
|
5
|
+
// src/scene/wind-plot.ts
|
|
6
|
+
/** A plot label: the anchor is the SVG attribute, spelled as the DOM does. */
|
|
7
|
+
function plotText(attrs, anchor, x, y, text) {
|
|
8
|
+
return el("text", {
|
|
9
|
+
...attrs,
|
|
10
|
+
"text-anchor": anchor,
|
|
11
|
+
x,
|
|
12
|
+
y
|
|
13
|
+
}, text);
|
|
14
|
+
}
|
|
15
|
+
function plotLine(attrs, x1, x2, y1, y2) {
|
|
16
|
+
return el("line", {
|
|
17
|
+
...attrs,
|
|
18
|
+
x1,
|
|
19
|
+
x2,
|
|
20
|
+
y1,
|
|
21
|
+
y2
|
|
22
|
+
});
|
|
23
|
+
}
|
|
5
24
|
function stretchedChartFrame(width, plotHeight) {
|
|
6
25
|
const core = chartFrame(width);
|
|
7
26
|
const corePlotHeight = core.plotBottom - core.plotTop;
|
|
@@ -20,23 +39,7 @@ function speedGridLines(frame, scales, shown) {
|
|
|
20
39
|
1
|
|
21
40
|
].map((fraction) => {
|
|
22
41
|
const gridY = frame.plotBottom - fraction * (frame.plotBottom - frame.plotTop);
|
|
23
|
-
return {
|
|
24
|
-
key: fraction,
|
|
25
|
-
line: {
|
|
26
|
-
className: "meteo-grid-line",
|
|
27
|
-
x1: frame.left,
|
|
28
|
-
x2: frame.right,
|
|
29
|
-
y1: gridY,
|
|
30
|
-
y2: gridY
|
|
31
|
-
},
|
|
32
|
-
label: {
|
|
33
|
-
className: "meteo-grid-label",
|
|
34
|
-
anchor: "end",
|
|
35
|
-
x: frame.left - 6,
|
|
36
|
-
y: gridY + 5,
|
|
37
|
-
text: String(shown(scales.scaleMax * fraction))
|
|
38
|
-
}
|
|
39
|
-
};
|
|
42
|
+
return keyed(String(fraction), "g", void 0, plotLine({ class: "meteo-grid-line" }, frame.left, frame.right, gridY, gridY), plotText({ class: "meteo-grid-label" }, "end", frame.left - 6, gridY + 5, String(shown(scales.scaleMax * fraction))));
|
|
40
43
|
});
|
|
41
44
|
}
|
|
42
45
|
function windThresholdGuides(thresholds, boundsMps, unit, frame, scales, shown) {
|
|
@@ -44,23 +47,7 @@ function windThresholdGuides(thresholds, boundsMps, unit, frame, scales, shown)
|
|
|
44
47
|
return boundsMps.map((boundMps, index) => ({
|
|
45
48
|
boundMps,
|
|
46
49
|
label: unit === thresholds.unit ? String(thresholds.values[index]) : String(shown(boundMps))
|
|
47
|
-
})).filter(({ boundMps }) => boundMps > 0 && boundMps <= scales.scaleMax).map(({ boundMps, label }) => ({
|
|
48
|
-
key: boundMps,
|
|
49
|
-
line: {
|
|
50
|
-
className: `meteo-wind-threshold meteo-band-${speedBand(boundMps, boundsMps)}`,
|
|
51
|
-
x1: frame.left,
|
|
52
|
-
x2: frame.right,
|
|
53
|
-
y1: scales.yAt(boundMps),
|
|
54
|
-
y2: scales.yAt(boundMps)
|
|
55
|
-
},
|
|
56
|
-
label: {
|
|
57
|
-
className: `meteo-wind-threshold-label meteo-band-${speedBand(boundMps, boundsMps)}`,
|
|
58
|
-
anchor: "end",
|
|
59
|
-
x: frame.right - 3,
|
|
60
|
-
y: scales.yAt(boundMps) - 3,
|
|
61
|
-
text: label
|
|
62
|
-
}
|
|
63
|
-
}));
|
|
50
|
+
})).filter(({ boundMps }) => boundMps > 0 && boundMps <= scales.scaleMax).map(({ boundMps, label }) => keyed(String(boundMps), "g", void 0, plotLine({ class: `meteo-wind-threshold meteo-band-${speedBand(boundMps, boundsMps)}` }, frame.left, frame.right, scales.yAt(boundMps), scales.yAt(boundMps)), plotText({ class: `meteo-wind-threshold-label meteo-band-${speedBand(boundMps, boundsMps)}` }, "end", frame.right - 3, scales.yAt(boundMps) - 3, label)));
|
|
64
51
|
}
|
|
65
52
|
function windZoneRects(boundsMps, frame, scales) {
|
|
66
53
|
if (boundsMps == null) return [];
|
|
@@ -71,100 +58,70 @@ function windZoneRects(boundsMps, frame, scales) {
|
|
|
71
58
|
];
|
|
72
59
|
return cuts.slice(0, -1).map((lower, index) => {
|
|
73
60
|
const upper = cuts[index + 1];
|
|
74
|
-
return {
|
|
75
|
-
|
|
76
|
-
className: `meteo-wind-zone meteo-band-${speedBand((lower + upper) / 2, boundsMps)}`,
|
|
61
|
+
return keyed(String(lower), "rect", {
|
|
62
|
+
class: `meteo-wind-zone meteo-band-${speedBand((lower + upper) / 2, boundsMps)}`,
|
|
77
63
|
height: scales.yAt(lower) - scales.yAt(upper),
|
|
78
64
|
width: frame.right - frame.left,
|
|
79
65
|
x: frame.left,
|
|
80
66
|
y: scales.yAt(upper)
|
|
81
|
-
};
|
|
67
|
+
});
|
|
82
68
|
});
|
|
83
69
|
}
|
|
84
70
|
function vaneGuideLines(vanes, frame, scales) {
|
|
85
71
|
return vanes.map((vane) => ({
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
x1: scales.xAtMs(vane.midMs),
|
|
89
|
-
x2: scales.xAtMs(vane.midMs),
|
|
90
|
-
y1: frame.plotTop,
|
|
91
|
-
y2: frame.vaneRow - 9
|
|
72
|
+
...plotLine({ class: "meteo-wind-guide" }, scales.xAtMs(vane.midMs), scales.xAtMs(vane.midMs), frame.plotTop, frame.vaneRow - 9),
|
|
73
|
+
key: String(vane.midMs)
|
|
92
74
|
}));
|
|
93
75
|
}
|
|
94
76
|
function gapHatchPattern(hatchId) {
|
|
95
|
-
return {
|
|
96
|
-
id: hatchId,
|
|
97
|
-
width: "6",
|
|
77
|
+
return el("pattern", {
|
|
98
78
|
height: "6",
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
79
|
+
id: hatchId,
|
|
80
|
+
patternTransform: "rotate(45)",
|
|
81
|
+
patternUnits: "userSpaceOnUse",
|
|
82
|
+
width: "6"
|
|
83
|
+
}, el("line", {
|
|
84
|
+
class: "meteo-wind-gap-hatch",
|
|
85
|
+
x1: "0",
|
|
86
|
+
x2: "0",
|
|
87
|
+
y1: "0",
|
|
88
|
+
y2: "6"
|
|
89
|
+
}));
|
|
109
90
|
}
|
|
110
91
|
function gapHatchRect(hatchId, frame, key, x, width) {
|
|
111
|
-
return {
|
|
112
|
-
|
|
113
|
-
className: "meteo-wind-gap",
|
|
92
|
+
return keyed(String(key), "rect", {
|
|
93
|
+
class: "meteo-wind-gap",
|
|
114
94
|
fill: `url(#${hatchId})`,
|
|
115
95
|
height: frame.plotBottom - frame.plotTop,
|
|
116
96
|
width,
|
|
117
97
|
x,
|
|
118
98
|
y: frame.plotTop
|
|
119
|
-
};
|
|
99
|
+
});
|
|
120
100
|
}
|
|
121
101
|
function gradedMeanTrace(points, scales, boundsMps) {
|
|
122
|
-
if (boundsMps == null) return {
|
|
123
|
-
|
|
124
|
-
className: "meteo-wind-mean",
|
|
102
|
+
if (boundsMps == null) return [el("polyline", {
|
|
103
|
+
class: "meteo-wind-mean",
|
|
125
104
|
points: averagePoints(points, scales)
|
|
126
|
-
};
|
|
127
|
-
return {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
x1: scales.xAt(previous.observedAt),
|
|
135
|
-
x2: scales.xAt(point.observedAt),
|
|
136
|
-
y1: scales.yAt(previous.windAvgMps),
|
|
137
|
-
y2: scales.yAt(point.windAvgMps)
|
|
138
|
-
};
|
|
139
|
-
})
|
|
140
|
-
};
|
|
105
|
+
})];
|
|
106
|
+
return points.slice(1).map((point, index) => {
|
|
107
|
+
const previous = points[index];
|
|
108
|
+
return {
|
|
109
|
+
...plotLine({ class: `meteo-wind-mean-segment meteo-band-${speedBand((previous.windAvgMps + point.windAvgMps) / 2, boundsMps)}` }, scales.xAt(previous.observedAt), scales.xAt(point.observedAt), scales.yAt(previous.windAvgMps), scales.yAt(point.windAvgMps)),
|
|
110
|
+
key: point.observedAt
|
|
111
|
+
};
|
|
112
|
+
});
|
|
141
113
|
}
|
|
142
114
|
function calmNoteText(frame, words) {
|
|
143
|
-
return {
|
|
144
|
-
className: "meteo-wind-calm-note",
|
|
145
|
-
anchor: "middle",
|
|
146
|
-
x: (frame.left + frame.right) / 2,
|
|
147
|
-
y: (frame.plotTop + frame.plotBottom) / 2 + 4,
|
|
148
|
-
text: words.calmHistory
|
|
149
|
-
};
|
|
115
|
+
return plotText({ class: "meteo-wind-calm-note" }, "middle", (frame.left + frame.right) / 2, (frame.plotTop + frame.plotBottom) / 2 + 4, words.calmHistory);
|
|
150
116
|
}
|
|
151
117
|
function windRowLabels(frame, words) {
|
|
152
|
-
return {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
},
|
|
160
|
-
avg: {
|
|
161
|
-
className: "meteo-wind-row-label",
|
|
162
|
-
anchor: "end",
|
|
163
|
-
x: frame.left - 8,
|
|
164
|
-
y: frame.valueRow + 4,
|
|
165
|
-
text: words.avgLabel
|
|
166
|
-
}
|
|
167
|
-
};
|
|
118
|
+
return [{
|
|
119
|
+
...plotText({ class: "meteo-wind-row-label" }, "end", frame.left - 8, frame.vaneRow + 4, words.toLabel),
|
|
120
|
+
key: "to"
|
|
121
|
+
}, {
|
|
122
|
+
...plotText({ class: "meteo-wind-row-label" }, "end", frame.left - 8, frame.valueRow + 4, words.avgLabel),
|
|
123
|
+
key: "avg"
|
|
124
|
+
}];
|
|
168
125
|
}
|
|
169
126
|
function nightRects(points, frame, scales, night) {
|
|
170
127
|
if (night?.latitude == null || night?.longitude == null || points.length < 2) return [];
|
|
@@ -180,14 +137,13 @@ function nightRects(points, frame, scales, night) {
|
|
|
180
137
|
const darkTo = Math.min(tomorrow.sunrise.getTime(), endMs);
|
|
181
138
|
if (darkFrom >= darkTo) continue;
|
|
182
139
|
const x = scales.xAtMs(darkFrom);
|
|
183
|
-
rects.push({
|
|
184
|
-
|
|
185
|
-
className: "meteo-night",
|
|
140
|
+
rects.push(keyed(String(dayStart), "rect", {
|
|
141
|
+
class: "meteo-night",
|
|
186
142
|
height: frame.plotBottom - frame.plotTop,
|
|
187
143
|
width: scales.xAtMs(darkTo) - x,
|
|
188
144
|
x,
|
|
189
145
|
y: frame.plotTop
|
|
190
|
-
});
|
|
146
|
+
}));
|
|
191
147
|
}
|
|
192
148
|
return rects;
|
|
193
149
|
}
|
|
@@ -203,46 +159,19 @@ function vaneCells(vanes, frame, scales, valueText, favorableDirections) {
|
|
|
203
159
|
const speaks = (index, every) => (vanes.length - 1 - index) % every === 0;
|
|
204
160
|
return vanes.map((vane, index) => ({
|
|
205
161
|
key: vane.midMs,
|
|
206
|
-
mark: vane.windDirectionDeg == null ? {
|
|
207
|
-
|
|
208
|
-
text: {
|
|
209
|
-
className: "meteo-wind-vane-calm",
|
|
210
|
-
anchor: "middle",
|
|
211
|
-
x: scales.xAtMs(vane.midMs),
|
|
212
|
-
y: frame.vaneRow + 4,
|
|
213
|
-
text: "—"
|
|
214
|
-
}
|
|
215
|
-
} : {
|
|
216
|
-
kind: "vane",
|
|
217
|
-
className: `meteo-wind-vane${verdict(vane.windDirectionDeg)}`,
|
|
162
|
+
mark: vane.windDirectionDeg == null ? plotText({ class: "meteo-wind-vane-calm" }, "middle", scales.xAtMs(vane.midMs), frame.vaneRow + 4, "—") : el("path", {
|
|
163
|
+
class: `meteo-wind-vane${verdict(vane.windDirectionDeg)}`,
|
|
218
164
|
d: vanePath(scales.xAtMs(vane.midMs), frame.vaneRow, vane.windDirectionDeg)
|
|
219
|
-
},
|
|
220
|
-
label: speaks(index, labelStep) ? {
|
|
221
|
-
|
|
222
|
-
anchor: "middle",
|
|
223
|
-
x: scales.xAtMs(vane.midMs),
|
|
224
|
-
y: frame.vaneLabelRow + 4,
|
|
225
|
-
text: vane.windDirectionDeg == null ? "—" : compassDirection(vane.windDirectionDeg)
|
|
226
|
-
} : null,
|
|
227
|
-
value: speaks(index, valueStep) ? {
|
|
228
|
-
className: "meteo-wind-vane-value",
|
|
229
|
-
anchor: "middle",
|
|
230
|
-
x: scales.xAtMs(vane.midMs),
|
|
231
|
-
y: frame.valueRow + 4,
|
|
232
|
-
text: valueText(vane)
|
|
233
|
-
} : null
|
|
165
|
+
}),
|
|
166
|
+
label: speaks(index, labelStep) ? plotText({ class: "meteo-wind-vane-label" }, "middle", scales.xAtMs(vane.midMs), frame.vaneLabelRow + 4, vane.windDirectionDeg == null ? "—" : compassDirection(vane.windDirectionDeg)) : null,
|
|
167
|
+
value: speaks(index, valueStep) ? plotText({ class: "meteo-wind-vane-value" }, "middle", scales.xAtMs(vane.midMs), frame.valueRow + 4, valueText(vane)) : null
|
|
234
168
|
}));
|
|
235
169
|
}
|
|
236
170
|
function vaneTickTexts(vanes, frame, scales, labelText) {
|
|
237
171
|
const ticks = vaneTicks(vanes, scales, Math.floor((frame.right - frame.left) / TIME_LABEL_PX));
|
|
238
172
|
return ticks.map(({ index, timeMs, x }) => ({
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
anchor: tickAnchor(index, ticks.length - 1),
|
|
242
|
-
x,
|
|
243
|
-
y: frame.labelRow,
|
|
244
|
-
text: labelText(timeMs)
|
|
173
|
+
...plotText({ class: "meteo-tick" }, tickAnchor(index, ticks.length - 1), x, frame.labelRow, labelText(timeMs)),
|
|
174
|
+
key: String(index)
|
|
245
175
|
}));
|
|
246
176
|
}
|
|
247
|
-
|
|
248
|
-
export { calmNoteText, displaySpeedScales, gapHatchPattern, gapHatchRect, gradedMeanTrace, nightRects, speedGridLines, stretchedChartFrame, vaneCells, vaneGuideLines, vaneTickTexts, windRowLabels, windThresholdGuides, windZoneRects };
|
|
177
|
+
export { calmNoteText, displaySpeedScales, gapHatchPattern, gapHatchRect, gradedMeanTrace, nightRects, plotLine, plotText, speedGridLines, stretchedChartFrame, vaneCells, vaneGuideLines, vaneTickTexts, windRowLabels, windThresholdGuides, windZoneRects };
|
package/dist/server/adapter.d.ts
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import { History, LiveSamples, Reading, RecentSummary, Station, StationMeta, StationTelemetry } from "../contract.js";
|
|
2
2
|
import { ResolvedEnvironment, ServerEnvironment } from "./environment.js";
|
|
3
|
-
|
|
4
|
-
type
|
|
5
|
-
type StationAdapterOptions = {
|
|
3
|
+
export type StationAdapterMode = "full" | "current";
|
|
4
|
+
export type StationAdapterOptions = {
|
|
6
5
|
historyHours?: number;
|
|
7
6
|
mode?: StationAdapterMode;
|
|
8
7
|
environment?: ServerEnvironment;
|
|
9
8
|
};
|
|
10
|
-
type StationAdapterContext<O extends StationAdapterOptions = StationAdapterOptions> = {
|
|
9
|
+
export type StationAdapterContext<O extends StationAdapterOptions = StationAdapterOptions> = {
|
|
11
10
|
readonly environment: ResolvedEnvironment;
|
|
12
11
|
readonly historyHours: number;
|
|
13
12
|
readonly mode: StationAdapterMode;
|
|
14
13
|
readonly options: O;
|
|
15
14
|
};
|
|
16
|
-
type StationAdapterResult = {
|
|
15
|
+
export type StationAdapterResult = {
|
|
17
16
|
readonly reading: Reading;
|
|
18
17
|
readonly history: History | null;
|
|
19
18
|
readonly telemetry?: StationTelemetry | null;
|
|
@@ -21,11 +20,9 @@ type StationAdapterResult = {
|
|
|
21
20
|
readonly recentSummaries?: RecentSummary[] | null;
|
|
22
21
|
readonly meta?: Partial<StationMeta>;
|
|
23
22
|
};
|
|
24
|
-
type StationAdapterDefinition<C, O extends StationAdapterOptions = StationAdapterOptions> = {
|
|
23
|
+
export type StationAdapterDefinition<C, O extends StationAdapterOptions = StationAdapterOptions> = {
|
|
25
24
|
readonly meta: (config: C) => StationMeta;
|
|
26
25
|
readonly load: (config: C, context: StationAdapterContext<O>) => Promise<StationAdapterResult>;
|
|
27
26
|
};
|
|
28
|
-
type StationAdapter<C, O extends StationAdapterOptions = StationAdapterOptions> = (config: C, options?: O) => Promise<Station>;
|
|
29
|
-
declare function defineStationAdapter<C, O extends StationAdapterOptions = StationAdapterOptions>(definition: StationAdapterDefinition<C, O>): StationAdapter<C, O>;
|
|
30
|
-
//#endregion
|
|
31
|
-
export { StationAdapter, StationAdapterContext, StationAdapterDefinition, StationAdapterMode, StationAdapterOptions, StationAdapterResult, defineStationAdapter };
|
|
27
|
+
export type StationAdapter<C, O extends StationAdapterOptions = StationAdapterOptions> = (config: C, options?: O) => Promise<Station>;
|
|
28
|
+
export declare function defineStationAdapter<C, O extends StationAdapterOptions = StationAdapterOptions>(definition: StationAdapterDefinition<C, O>): StationAdapter<C, O>;
|
package/dist/server/adapter.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { unavailableStation } from "../contract.js";
|
|
2
2
|
import { logUpstreamFailure, resolveEnvironment, unavailableReasonForError } from "./environment.js";
|
|
3
3
|
import "./feed.js";
|
|
4
|
-
|
|
4
|
+
// src/server/adapter.ts
|
|
5
5
|
function defineStationAdapter(definition) {
|
|
6
6
|
return async (config, options) => {
|
|
7
7
|
const resolved = options ?? {};
|
|
@@ -31,5 +31,4 @@ function defineStationAdapter(definition) {
|
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
|
-
//#endregion
|
|
35
34
|
export { defineStationAdapter };
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { HistoryPoint, Reading, Station } from "../../contract.js";
|
|
2
2
|
import { CampbellStationConfig } from "../config.js";
|
|
3
3
|
import { StationAdapter, StationAdapterOptions } from "../adapter.js";
|
|
4
|
-
|
|
5
|
-
type CampbellAdapterOptions = StationAdapterOptions;
|
|
4
|
+
export type CampbellAdapterOptions = StationAdapterOptions;
|
|
6
5
|
type CampbellField = {
|
|
7
6
|
name: string;
|
|
8
7
|
process: string;
|
|
@@ -13,12 +12,12 @@ type CampbellRecord = {
|
|
|
13
12
|
time: string;
|
|
14
13
|
vals: unknown[];
|
|
15
14
|
};
|
|
16
|
-
type CampbellTable = {
|
|
15
|
+
export type CampbellTable = {
|
|
17
16
|
fields: CampbellField[];
|
|
18
17
|
records: CampbellRecord[];
|
|
19
18
|
};
|
|
20
19
|
type TableRole = "current" | "history";
|
|
21
|
-
declare const CAMPBELL_FIELD_CONTRACTS: {
|
|
20
|
+
export declare const CAMPBELL_FIELD_CONTRACTS: {
|
|
22
21
|
readonly current: readonly [{
|
|
23
22
|
readonly name: "Wind_Speed";
|
|
24
23
|
readonly process: "Avg";
|
|
@@ -72,14 +71,21 @@ declare const CAMPBELL_FIELD_CONTRACTS: {
|
|
|
72
71
|
readonly units: "kilometers/hour";
|
|
73
72
|
}];
|
|
74
73
|
};
|
|
75
|
-
type CampbellTableExpectation = {
|
|
74
|
+
export type CampbellTableExpectation = {
|
|
76
75
|
role: TableRole;
|
|
77
76
|
tableName: string;
|
|
78
77
|
stationName: string;
|
|
79
78
|
intervalMs: number;
|
|
80
79
|
subject: string;
|
|
81
80
|
};
|
|
82
|
-
declare const loadCampbellStation: StationAdapter<{
|
|
81
|
+
export declare const loadCampbellStation: StationAdapter<{
|
|
82
|
+
elevationM?: number | null | undefined;
|
|
83
|
+
latitude?: number | null | undefined;
|
|
84
|
+
longitude?: number | null | undefined;
|
|
85
|
+
id: string;
|
|
86
|
+
name: string;
|
|
87
|
+
pageUrl?: string | null | undefined;
|
|
88
|
+
vendor: "campbell";
|
|
83
89
|
baseUrl: string;
|
|
84
90
|
source: string;
|
|
85
91
|
timeZone: string;
|
|
@@ -88,25 +94,17 @@ declare const loadCampbellStation: StationAdapter<{
|
|
|
88
94
|
currentIntervalSeconds: number;
|
|
89
95
|
historyPeriodMinutes: number;
|
|
90
96
|
currentCacheTtlSeconds: number;
|
|
91
|
-
id: string;
|
|
92
|
-
name: string;
|
|
93
|
-
vendor: "campbell";
|
|
94
|
-
pageUrl?: string | null | undefined;
|
|
95
|
-
elevationM?: number | null | undefined;
|
|
96
|
-
latitude?: number | null | undefined;
|
|
97
|
-
longitude?: number | null | undefined;
|
|
98
97
|
}, StationAdapterOptions>;
|
|
99
|
-
declare function loadCampbellCurrent(config: CampbellStationConfig, options?: CampbellAdapterOptions): Promise<Station>;
|
|
100
|
-
declare function parseCampbellCurrent(value: string, config: CampbellStationConfig, nowMs?: number): Reading;
|
|
101
|
-
declare function parseCampbellHistory(value: string, config: CampbellStationConfig): {
|
|
98
|
+
export declare function loadCampbellCurrent(config: CampbellStationConfig, options?: CampbellAdapterOptions): Promise<Station>;
|
|
99
|
+
export declare function parseCampbellCurrent(value: string, config: CampbellStationConfig, nowMs?: number): Reading;
|
|
100
|
+
export declare function parseCampbellHistory(value: string, config: CampbellStationConfig): {
|
|
102
101
|
points: HistoryPoint[];
|
|
103
102
|
latestTemperatureC: number;
|
|
104
103
|
latestWindChillC: number;
|
|
105
104
|
};
|
|
106
|
-
declare function parseCampbellTable(value: string, expectation: CampbellTableExpectation): CampbellTable;
|
|
107
|
-
declare function naiveLocalToIso(naive: string, timeZone: string, context?: {
|
|
105
|
+
export declare function parseCampbellTable(value: string, expectation: CampbellTableExpectation): CampbellTable;
|
|
106
|
+
export declare function naiveLocalToIso(naive: string, timeZone: string, context?: {
|
|
108
107
|
afterMs?: number | null;
|
|
109
108
|
nearMs?: number;
|
|
110
109
|
}): string;
|
|
111
|
-
|
|
112
|
-
export { CAMPBELL_FIELD_CONTRACTS, CampbellAdapterOptions, CampbellTable, CampbellTableExpectation, loadCampbellCurrent, loadCampbellStation, naiveLocalToIso, parseCampbellCurrent, parseCampbellHistory, parseCampbellTable };
|
|
110
|
+
export {};
|
|
@@ -2,7 +2,7 @@ import { isCalm, normalizeDegrees } from "../../derive.js";
|
|
|
2
2
|
import { fetchUpstreamText, logUpstreamFailure } from "../environment.js";
|
|
3
3
|
import { defineStationAdapter } from "../adapter.js";
|
|
4
4
|
import { kmhToMps } from "@azohra/meteo.core";
|
|
5
|
-
|
|
5
|
+
// src/server/adapters/campbell.ts
|
|
6
6
|
const HISTORY_CACHE_TTL_SECONDS = 120;
|
|
7
7
|
const MAX_RESPONSE_BYTES = 524288;
|
|
8
8
|
const CAMPBELL_FIELD_CONTRACTS = {
|
|
@@ -191,7 +191,7 @@ function finiteOrNull(value) {
|
|
|
191
191
|
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
192
192
|
}
|
|
193
193
|
const HOUR_MS = 36e5;
|
|
194
|
-
const HOUR_SKEW_TOLERANCE_MS =
|
|
194
|
+
const HOUR_SKEW_TOLERANCE_MS = 3e5;
|
|
195
195
|
function warnOnHourSkew(environment, config, observedAtIso, nowMs) {
|
|
196
196
|
const skewMs = Math.abs(Date.parse(observedAtIso) - nowMs);
|
|
197
197
|
if (Math.abs(skewMs - HOUR_MS) > HOUR_SKEW_TOLERANCE_MS) return;
|
|
@@ -410,5 +410,4 @@ function naiveLocalToIso(naive, timeZone, context = {}) {
|
|
|
410
410
|
}
|
|
411
411
|
return new Date(high).toISOString();
|
|
412
412
|
}
|
|
413
|
-
//#endregion
|
|
414
413
|
export { CAMPBELL_FIELD_CONTRACTS, loadCampbellCurrent, loadCampbellStation, naiveLocalToIso, parseCampbellCurrent, parseCampbellHistory, parseCampbellTable };
|
|
@@ -1,28 +1,25 @@
|
|
|
1
1
|
import { Reading, StationTelemetry } from "../../contract.js";
|
|
2
2
|
import { EcowittStationConfig } from "../config.js";
|
|
3
3
|
import { StationAdapter, StationAdapterOptions } from "../adapter.js";
|
|
4
|
-
|
|
5
|
-
type EcowittAdapterOptions = StationAdapterOptions & {
|
|
4
|
+
export type EcowittAdapterOptions = StationAdapterOptions & {
|
|
6
5
|
realTimeUrl?: string;
|
|
7
6
|
};
|
|
8
|
-
type EcowittObservation = {
|
|
7
|
+
export type EcowittObservation = {
|
|
9
8
|
reading: Reading;
|
|
10
9
|
telemetry: StationTelemetry | null;
|
|
11
10
|
};
|
|
12
|
-
declare const loadEcowittStation: StationAdapter<{
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
hasBattery: boolean;
|
|
11
|
+
export declare const loadEcowittStation: StationAdapter<{
|
|
12
|
+
elevationM?: number | null | undefined;
|
|
13
|
+
latitude?: number | null | undefined;
|
|
14
|
+
longitude?: number | null | undefined;
|
|
17
15
|
id: string;
|
|
18
16
|
name: string;
|
|
19
|
-
vendor: "ecowitt";
|
|
20
17
|
timeZone?: string | null | undefined;
|
|
21
18
|
pageUrl?: string | null | undefined;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
vendor: "ecowitt";
|
|
20
|
+
applicationKey: string;
|
|
21
|
+
apiKey: string;
|
|
22
|
+
mac: string;
|
|
23
|
+
hasBattery: boolean;
|
|
25
24
|
}, EcowittAdapterOptions>;
|
|
26
|
-
declare function parseEcowittRealTime(value: string, config: Pick<EcowittStationConfig, "mac" | "elevationM">): EcowittObservation;
|
|
27
|
-
//#endregion
|
|
28
|
-
export { EcowittAdapterOptions, EcowittObservation, loadEcowittStation, parseEcowittRealTime };
|
|
25
|
+
export declare function parseEcowittRealTime(value: string, config: Pick<EcowittStationConfig, "mac" | "elevationM">): EcowittObservation;
|
|
@@ -3,7 +3,7 @@ import { isCalm, normalizeDegrees, seaLevelPressureHpa } from "../../derive.js";
|
|
|
3
3
|
import { fetchUpstreamText } from "../environment.js";
|
|
4
4
|
import { defineStationAdapter } from "../adapter.js";
|
|
5
5
|
import { UpstreamError, plausibleWindMps } from "@azohra/meteo.core";
|
|
6
|
-
|
|
6
|
+
// src/server/adapters/ecowitt.ts
|
|
7
7
|
const ECOWITT_REAL_TIME_URL = "https://api.ecowitt.net/api/v3/device/real_time";
|
|
8
8
|
const CACHE_TTL_SECONDS = 60;
|
|
9
9
|
const ECOWITT_CALL_BACK = "outdoor,wind,pressure,rainfall,rainfall_piezo,solar_and_uvi,battery";
|
|
@@ -146,5 +146,4 @@ function directionDegrees(value) {
|
|
|
146
146
|
if (value < 0 || value > 360) throw new Error("Ecowitt returned an invalid wind direction");
|
|
147
147
|
return value;
|
|
148
148
|
}
|
|
149
|
-
//#endregion
|
|
150
149
|
export { loadEcowittStation, parseEcowittRealTime };
|
|
@@ -1,27 +1,24 @@
|
|
|
1
1
|
import { Reading } from "../../contract.js";
|
|
2
2
|
import { StationAdapter, StationAdapterOptions } from "../adapter.js";
|
|
3
|
-
|
|
4
|
-
type TempestAdapterOptions = StationAdapterOptions & {
|
|
3
|
+
export type TempestAdapterOptions = StationAdapterOptions & {
|
|
5
4
|
observationsUrl?: string;
|
|
6
5
|
};
|
|
7
|
-
type TempestObservation = {
|
|
6
|
+
export type TempestObservation = {
|
|
8
7
|
reading: Reading;
|
|
9
8
|
elevationM: number | null;
|
|
10
9
|
latitude: number | null;
|
|
11
10
|
longitude: number | null;
|
|
12
11
|
};
|
|
13
|
-
declare const loadTempestStation: StationAdapter<{
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
export declare const loadTempestStation: StationAdapter<{
|
|
13
|
+
elevationM?: number | null | undefined;
|
|
14
|
+
latitude?: number | null | undefined;
|
|
15
|
+
longitude?: number | null | undefined;
|
|
16
16
|
id: string;
|
|
17
17
|
name: string;
|
|
18
|
-
vendor: "tempest";
|
|
19
18
|
timeZone?: string | null | undefined;
|
|
20
19
|
pageUrl?: string | null | undefined;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
vendor: "tempest";
|
|
21
|
+
stationId: number;
|
|
22
|
+
token: string;
|
|
24
23
|
}, TempestAdapterOptions>;
|
|
25
|
-
declare function parseTempestWind(value: string, expectedStationId: number): TempestObservation;
|
|
26
|
-
//#endregion
|
|
27
|
-
export { TempestAdapterOptions, TempestObservation, loadTempestStation, parseTempestWind };
|
|
24
|
+
export declare function parseTempestWind(value: string, expectedStationId: number): TempestObservation;
|
|
@@ -2,7 +2,7 @@ import { isCalm, normalizeDegrees } from "../../derive.js";
|
|
|
2
2
|
import { fetchUpstreamText } from "../environment.js";
|
|
3
3
|
import { defineStationAdapter } from "../adapter.js";
|
|
4
4
|
import { plausibleWindMps } from "@azohra/meteo.core";
|
|
5
|
-
|
|
5
|
+
// src/server/adapters/tempest.ts
|
|
6
6
|
const TEMPEST_OBSERVATIONS_URL = "https://swd.weatherflow.com/swd/rest/observations/station";
|
|
7
7
|
const CACHE_TTL_SECONDS = 60;
|
|
8
8
|
const loadTempestStation = defineStationAdapter({
|
|
@@ -133,5 +133,4 @@ function longitudeDegrees(value) {
|
|
|
133
133
|
if (value < -180 || value > 180) throw new Error("Tempest returned an invalid longitude");
|
|
134
134
|
return value === 180 ? -180 : value;
|
|
135
135
|
}
|
|
136
|
-
//#endregion
|
|
137
136
|
export { loadTempestStation, parseTempestWind };
|
|
@@ -2,11 +2,10 @@ import { StationClimatology } from "../../contract-climatology.js";
|
|
|
2
2
|
import { SpeedThresholds } from "../../derive.js";
|
|
3
3
|
import { ServerEnvironment } from "../environment.js";
|
|
4
4
|
import { WindnerdStationConfig } from "../config.js";
|
|
5
|
-
|
|
6
|
-
declare const
|
|
7
|
-
declare const
|
|
8
|
-
|
|
9
|
-
type WindnerdClimatologyOptions = {
|
|
5
|
+
export declare const CLIMATOLOGY_RECORD_PERIOD_MINUTES = 180;
|
|
6
|
+
export declare const CLIMATOLOGY_DEFAULT_YEARS = 8;
|
|
7
|
+
export declare const CLIMATOLOGY_DEFAULT_SECTOR_COUNT = 16;
|
|
8
|
+
export type WindnerdClimatologyOptions = {
|
|
10
9
|
/** The consumer's speed-band bounds — a judgment parameter with no
|
|
11
10
|
* default; it shapes every bandCounts stack and joins the cache key. */
|
|
12
11
|
thresholds: SpeedThresholds;
|
|
@@ -25,6 +24,4 @@ type WindnerdClimatologyOptions = {
|
|
|
25
24
|
* running year 6 hours), folded into (month, slot, sector) sums in the
|
|
26
25
|
* station's STANDARD time. Any refused year fails the whole document —
|
|
27
26
|
* a silently missing year would read as an outage. */
|
|
28
|
-
declare function loadWindnerdClimatology(config: WindnerdStationConfig, options: WindnerdClimatologyOptions): Promise<StationClimatology>;
|
|
29
|
-
//#endregion
|
|
30
|
-
export { CLIMATOLOGY_DEFAULT_SECTOR_COUNT, CLIMATOLOGY_DEFAULT_YEARS, CLIMATOLOGY_RECORD_PERIOD_MINUTES, WindnerdClimatologyOptions, loadWindnerdClimatology };
|
|
27
|
+
export declare function loadWindnerdClimatology(config: WindnerdStationConfig, options: WindnerdClimatologyOptions): Promise<StationClimatology>;
|
|
@@ -3,7 +3,7 @@ import "../../contract-climatology.js";
|
|
|
3
3
|
import { accumulatedCells, coveredSlotCountByYear, createClimatologyAccumulator, foldClimatologyPoints } from "../../climatology.js";
|
|
4
4
|
import { fetchUpstreamText, logUpstreamFailure, resolveEnvironment } from "../environment.js";
|
|
5
5
|
import { loadWindnerdLocation, parseWindnerdRecords, windnerdHistoryPoints } from "./windnerd.js";
|
|
6
|
-
|
|
6
|
+
// src/server/adapters/windnerd-climatology.ts
|
|
7
7
|
const CLIMATOLOGY_RECORD_PERIOD_MINUTES = 180;
|
|
8
8
|
const CLIMATOLOGY_DEFAULT_YEARS = 8;
|
|
9
9
|
const CLIMATOLOGY_DEFAULT_SECTOR_COUNT = 16;
|
|
@@ -40,17 +40,18 @@ async function loadWindnerdClimatology(config, options) {
|
|
|
40
40
|
url.searchParams.set("from", new Date(from).toISOString());
|
|
41
41
|
url.searchParams.set("to", new Date(Date.UTC(year + 1, 0, 1)).toISOString());
|
|
42
42
|
url.searchParams.set("period", String(180));
|
|
43
|
-
const
|
|
43
|
+
const records = parseWindnerdRecords(await fetchUpstreamText(environment, {
|
|
44
44
|
url,
|
|
45
45
|
cacheKey: `windnerd/climo/${config.locationId}/${year}/180`,
|
|
46
46
|
cacheTtlSeconds: year < currentYear ? CLOSED_YEAR_CACHE_TTL_SECONDS : CURRENT_YEAR_CACHE_TTL_SECONDS,
|
|
47
47
|
subject: `WindNerd location ${config.locationId} climatology ${year}`
|
|
48
|
-
}), config.locationId, config.hasPressure)
|
|
48
|
+
}), config.locationId, config.hasPressure);
|
|
49
|
+
const points = windnerdHistoryPoints(records, config);
|
|
49
50
|
foldClimatologyPoints(accumulator, points);
|
|
50
51
|
years.push({
|
|
51
52
|
year,
|
|
52
53
|
sampleCount: points.length,
|
|
53
|
-
expectedCount: Math.floor((to - from) /
|
|
54
|
+
expectedCount: Math.floor((to - from) / 108e5),
|
|
54
55
|
coveredSlotCount: 0,
|
|
55
56
|
expectedSlotCount: Math.floor((to - from) / (slotMinutes * 6e4))
|
|
56
57
|
});
|
|
@@ -78,5 +79,4 @@ async function standardOffsetMinutes(config, environment, options) {
|
|
|
78
79
|
return 0;
|
|
79
80
|
}
|
|
80
81
|
}
|
|
81
|
-
//#endregion
|
|
82
82
|
export { CLIMATOLOGY_DEFAULT_SECTOR_COUNT, CLIMATOLOGY_DEFAULT_YEARS, CLIMATOLOGY_RECORD_PERIOD_MINUTES, loadWindnerdClimatology };
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { StationLiveFrame } from "../../contract.js";
|
|
2
2
|
import { ServerEnvironment } from "../environment.js";
|
|
3
3
|
import { WindnerdStationConfig } from "../config.js";
|
|
4
|
-
|
|
5
|
-
type WindnerdLiveOptions = {
|
|
4
|
+
export type WindnerdLiveOptions = {
|
|
6
5
|
environment?: ServerEnvironment;
|
|
7
6
|
signal?: AbortSignal;
|
|
8
7
|
liveUrl?: string;
|
|
@@ -13,6 +12,4 @@ type WindnerdLiveOptions = {
|
|
|
13
12
|
* upstream init frame) rejects on failure; after that, failures degrade
|
|
14
13
|
* to a terminal unavailable frame. One call is one upstream connection;
|
|
15
14
|
* reconnect and fan-out belong to the caller. */
|
|
16
|
-
declare function openWindnerdLive(config: WindnerdStationConfig, options?: WindnerdLiveOptions): Promise<ReadableStream<StationLiveFrame>>;
|
|
17
|
-
//#endregion
|
|
18
|
-
export { WindnerdLiveOptions, openWindnerdLive };
|
|
15
|
+
export declare function openWindnerdLive(config: WindnerdStationConfig, options?: WindnerdLiveOptions): Promise<ReadableStream<StationLiveFrame>>;
|