@azohra/meteo.station 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -17
- package/dist/client/climatology.js +1 -1
- package/dist/client/history.js +3 -11
- package/dist/client/live.d.ts +2 -1
- package/dist/client/live.js +7 -4
- package/dist/client/stores.js +10 -2
- package/dist/climatology.d.ts +1 -1
- package/dist/climatology.js +1 -1
- package/dist/connectivity.d.ts +2 -2
- package/dist/contract.d.ts +98 -98
- package/dist/derive.js +9 -8
- package/dist/elements/elements/AirExtremesElement.js +5 -18
- package/dist/elements/elements/AirMatrixElement.js +6 -31
- package/dist/elements/elements/ClimatologyDailyPatternElement.js +17 -12
- package/dist/elements/elements/ClimatologyRoseElement.js +5 -15
- package/dist/elements/elements/CompassFanElement.js +5 -64
- package/dist/elements/elements/CurrentConditionsElement.js +7 -26
- package/dist/elements/elements/DailyPatternElement.d.ts +0 -1
- package/dist/elements/elements/DailyPatternElement.js +6 -120
- package/dist/elements/elements/DialElement.js +3 -95
- package/dist/elements/elements/FavorableShareElement.js +6 -21
- package/dist/elements/elements/RecentSummariesElement.js +6 -23
- package/dist/elements/elements/SparklineElement.d.ts +0 -1
- package/dist/elements/elements/SparklineElement.js +4 -39
- package/dist/elements/elements/StationCardElement.js +4 -18
- package/dist/elements/elements/StationFeedElement.js +4 -2
- package/dist/elements/elements/StationStripElement.js +4 -18
- package/dist/elements/elements/StationTableElement.js +15 -51
- package/dist/elements/elements/TrendChartElement.js +27 -94
- package/dist/elements/elements/WindHistoryChartElement.js +29 -189
- package/dist/elements/elements/WindRoseElement.d.ts +0 -1
- package/dist/elements/elements/WindRoseElement.js +6 -70
- package/dist/elements/elements/atoms.js +11 -38
- package/dist/elements/index.js +3 -3
- package/dist/elements/lib/fragments.js +8 -37
- package/dist/elements/lib/h.js +1 -1
- package/dist/elements/lib/pinned-cursor.js +48 -0
- package/dist/elements/lib/render.js +30 -0
- package/dist/fixtures.d.ts +6 -2
- package/dist/fixtures.js +30 -2
- package/dist/format.js +7 -3
- package/dist/geometry.d.ts +1 -1
- package/dist/geometry.js +22 -9
- package/dist/instruments.js +2 -2
- package/dist/react/components/AirExtremes.d.ts +1 -1
- package/dist/react/components/AirExtremes.js +5 -22
- package/dist/react/components/AirMatrix.js +10 -43
- package/dist/react/components/ClimatologyDailyPattern.d.ts +1 -1
- package/dist/react/components/ClimatologyDailyPattern.js +19 -13
- package/dist/react/components/ClimatologyRose.d.ts +1 -1
- package/dist/react/components/ClimatologyRose.js +11 -28
- package/dist/react/components/CompassFan.d.ts +1 -1
- package/dist/react/components/CompassFan.js +6 -73
- package/dist/react/components/CurrentConditions.d.ts +1 -1
- package/dist/react/components/CurrentConditions.js +11 -74
- package/dist/react/components/DailyPattern.d.ts +1 -3
- package/dist/react/components/DailyPattern.js +10 -149
- package/dist/react/components/Dial.d.ts +2 -3
- package/dist/react/components/Dial.js +5 -118
- package/dist/react/components/FavorableShare.d.ts +1 -1
- package/dist/react/components/FavorableShare.js +6 -27
- package/dist/react/components/FreshnessBadge.d.ts +1 -1
- package/dist/react/components/FreshnessBadge.js +5 -12
- package/dist/react/components/RecentSummaries.d.ts +1 -1
- package/dist/react/components/RecentSummaries.js +6 -44
- package/dist/react/components/SceneTree.js +38 -0
- package/dist/react/components/Sparkline.d.ts +1 -1
- package/dist/react/components/Sparkline.js +3 -39
- package/dist/react/components/StationCard.d.ts +2 -2
- package/dist/react/components/StationCard.js +5 -45
- package/dist/react/components/StationStrip.d.ts +1 -1
- package/dist/react/components/StationStrip.js +5 -60
- package/dist/react/components/StationTable.js +21 -75
- package/dist/react/components/TrendChart.js +13 -86
- package/dist/react/components/WindArrow.d.ts +1 -1
- package/dist/react/components/WindArrow.js +3 -15
- package/dist/react/components/WindHistoryChart.js +12 -205
- package/dist/react/components/WindRose.d.ts +1 -3
- package/dist/react/components/WindRose.js +6 -89
- package/dist/react/components/WindSampleStrip.js +14 -139
- package/dist/react/components/atoms.d.ts +5 -5
- package/dist/react/components/atoms.js +12 -48
- package/dist/react/hooks/useStation.js +28 -50
- package/dist/react/hooks/useStationCurrent.js +3 -2
- package/dist/react/hooks/useStationFeed.d.ts +0 -1
- package/dist/react/hooks/useStationFeed.js +3 -2
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.js +7 -7
- package/dist/react/lib/cells.js +4 -24
- package/dist/react/lib/use-pinned-cursor.js +32 -0
- package/dist/samples.js +7 -43
- package/dist/scene/air-extremes.js +12 -27
- package/dist/scene/air-matrix.js +45 -58
- package/dist/scene/card.js +14 -40
- package/dist/scene/cells.d.ts +4 -0
- package/dist/scene/cells.js +51 -0
- package/dist/scene/chart.js +2 -1
- package/dist/scene/climatology-pattern.d.ts +1 -2
- package/dist/scene/climatology-pattern.js +10 -11
- package/dist/scene/climatology-rose.d.ts +1 -2
- package/dist/scene/climatology-rose.js +14 -33
- package/dist/scene/compass-fan.js +28 -100
- package/dist/scene/current.d.ts +2 -1
- package/dist/scene/current.js +29 -56
- package/dist/scene/daily-pattern.d.ts +1 -3
- package/dist/scene/daily-pattern.js +20 -27
- package/dist/scene/dial-parts.d.ts +1 -0
- package/dist/scene/dial-parts.js +70 -0
- package/dist/scene/dial.d.ts +1 -2
- package/dist/scene/dial.js +48 -136
- package/dist/scene/favorable-share.js +16 -33
- package/dist/scene/glyphs.js +20 -16
- package/dist/scene/index.d.ts +5 -3
- package/dist/scene/node.js +19 -0
- package/dist/scene/recent-summaries.js +26 -66
- package/dist/scene/rose.js +89 -117
- package/dist/scene/sample-strip.d.ts +1 -2
- package/dist/scene/sample-strip.js +35 -36
- package/dist/scene/sparkline.js +31 -40
- package/dist/scene/strip.js +18 -57
- package/dist/scene/table.js +47 -69
- package/dist/scene/trend.d.ts +1 -2
- package/dist/scene/trend.js +29 -55
- package/dist/scene/wind-history.d.ts +1 -2
- package/dist/scene/wind-history.js +41 -51
- package/dist/scene/wind-plot.js +70 -140
- package/dist/server/adapters/campbell.d.ts +7 -7
- package/dist/server/adapters/campbell.js +1 -1
- package/dist/server/adapters/ecowitt.d.ts +8 -8
- package/dist/server/adapters/tempest.d.ts +6 -6
- package/dist/server/adapters/windnerd-climatology.js +4 -3
- package/dist/server/adapters/windnerd-live.js +3 -2
- package/dist/server/adapters/windnerd.d.ts +10 -11
- package/dist/server/adapters/windnerd.js +3 -13
- package/dist/server/config.d.ts +48 -48
- package/dist/server/hologram.js +2 -1
- package/dist/server/index.d.ts +2 -2
- package/dist/server/index.js +2 -2
- package/dist/windnerd.d.ts +3 -1
- package/dist/windnerd.js +11 -1
- package/package.json +7 -12
- package/schema/README.md +3 -3
- package/schema/stationclimatology.schema.json +64 -61
- package/schema/stationcurrent.schema.json +68 -156
- package/schema/stationfeed.schema.json +71 -163
- package/schema/stationhistory.schema.json +37 -46
- package/schema/stationlive.schema.json +221 -306
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
|
//#region 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,20 @@ 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
177
|
//#endregion
|
|
248
|
-
export { calmNoteText, displaySpeedScales, gapHatchPattern, gapHatchRect, gradedMeanTrace, nightRects, speedGridLines, stretchedChartFrame, vaneCells, vaneGuideLines, vaneTickTexts, windRowLabels, windThresholdGuides, windZoneRects };
|
|
178
|
+
export { calmNoteText, displaySpeedScales, gapHatchPattern, gapHatchRect, gradedMeanTrace, nightRects, plotLine, plotText, speedGridLines, stretchedChartFrame, vaneCells, vaneGuideLines, vaneTickTexts, windRowLabels, windThresholdGuides, windZoneRects };
|
|
@@ -80,6 +80,13 @@ type CampbellTableExpectation = {
|
|
|
80
80
|
subject: string;
|
|
81
81
|
};
|
|
82
82
|
declare const loadCampbellStation: StationAdapter<{
|
|
83
|
+
elevationM?: number | null | undefined;
|
|
84
|
+
latitude?: number | null | undefined;
|
|
85
|
+
longitude?: number | null | undefined;
|
|
86
|
+
id: string;
|
|
87
|
+
name: string;
|
|
88
|
+
pageUrl?: string | null | undefined;
|
|
89
|
+
vendor: "campbell";
|
|
83
90
|
baseUrl: string;
|
|
84
91
|
source: string;
|
|
85
92
|
timeZone: string;
|
|
@@ -88,13 +95,6 @@ declare const loadCampbellStation: StationAdapter<{
|
|
|
88
95
|
currentIntervalSeconds: number;
|
|
89
96
|
historyPeriodMinutes: number;
|
|
90
97
|
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
98
|
}, StationAdapterOptions>;
|
|
99
99
|
declare function loadCampbellCurrent(config: CampbellStationConfig, options?: CampbellAdapterOptions): Promise<Station>;
|
|
100
100
|
declare function parseCampbellCurrent(value: string, config: CampbellStationConfig, nowMs?: number): Reading;
|
|
@@ -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;
|
|
@@ -10,18 +10,18 @@ type EcowittObservation = {
|
|
|
10
10
|
telemetry: StationTelemetry | null;
|
|
11
11
|
};
|
|
12
12
|
declare const loadEcowittStation: StationAdapter<{
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
hasBattery: boolean;
|
|
13
|
+
elevationM?: number | null | undefined;
|
|
14
|
+
latitude?: number | null | undefined;
|
|
15
|
+
longitude?: number | null | undefined;
|
|
17
16
|
id: string;
|
|
18
17
|
name: string;
|
|
19
|
-
vendor: "ecowitt";
|
|
20
18
|
timeZone?: string | null | undefined;
|
|
21
19
|
pageUrl?: string | null | undefined;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
vendor: "ecowitt";
|
|
21
|
+
applicationKey: string;
|
|
22
|
+
apiKey: string;
|
|
23
|
+
mac: string;
|
|
24
|
+
hasBattery: boolean;
|
|
25
25
|
}, EcowittAdapterOptions>;
|
|
26
26
|
declare function parseEcowittRealTime(value: string, config: Pick<EcowittStationConfig, "mac" | "elevationM">): EcowittObservation;
|
|
27
27
|
//#endregion
|
|
@@ -11,16 +11,16 @@ type TempestObservation = {
|
|
|
11
11
|
longitude: number | null;
|
|
12
12
|
};
|
|
13
13
|
declare const loadTempestStation: StationAdapter<{
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
elevationM?: number | null | undefined;
|
|
15
|
+
latitude?: number | null | undefined;
|
|
16
|
+
longitude?: number | null | undefined;
|
|
16
17
|
id: string;
|
|
17
18
|
name: string;
|
|
18
|
-
vendor: "tempest";
|
|
19
19
|
timeZone?: string | null | undefined;
|
|
20
20
|
pageUrl?: string | null | undefined;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
vendor: "tempest";
|
|
22
|
+
stationId: number;
|
|
23
|
+
token: string;
|
|
24
24
|
}, TempestAdapterOptions>;
|
|
25
25
|
declare function parseTempestWind(value: string, expectedStationId: number): TempestObservation;
|
|
26
26
|
//#endregion
|
|
@@ -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
|
});
|
|
@@ -20,11 +20,12 @@ async function openWindnerdLive(config, options = {}) {
|
|
|
20
20
|
let events;
|
|
21
21
|
let initFrame;
|
|
22
22
|
try {
|
|
23
|
-
|
|
23
|
+
const response = await fetchUpstreamStream(environment, {
|
|
24
24
|
url: windnerdLiveStreamUrl(config, options.liveUrl),
|
|
25
25
|
subject,
|
|
26
26
|
signal: upstream.signal
|
|
27
|
-
})
|
|
27
|
+
});
|
|
28
|
+
events = sseEvents(response.body, { signal: upstream.signal });
|
|
28
29
|
initFrame = await readInitFrame(events, config, environment, upstream, options, subject);
|
|
29
30
|
} catch (error) {
|
|
30
31
|
upstream.abort();
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { History, HistoryPoint, LiveSamples, Reading, RecentSummary, StationMeta, StationTelemetry } from "../../contract.js";
|
|
2
|
+
import { WindnerdRecordPeriodMinutes } from "../../windnerd.js";
|
|
2
3
|
import "../environment.js";
|
|
3
4
|
import { WindnerdStationConfig } from "../config.js";
|
|
4
5
|
import { StationAdapter, StationAdapterOptions } from "../adapter.js";
|
|
5
6
|
import { DirectionArc } from "@azohra/meteo.core";
|
|
6
7
|
//#region src/server/adapters/windnerd.d.ts
|
|
7
|
-
declare const WINDNERD_RECORD_PERIODS_MINUTES: readonly [1, 5, 10, 15, 30, 60, 180, 360];
|
|
8
|
-
type WindnerdRecordPeriodMinutes = (typeof WINDNERD_RECORD_PERIODS_MINUTES)[number];
|
|
9
8
|
declare const WINDNERD_LIVE_SAMPLE_INTERVAL_SECONDS = 3;
|
|
10
9
|
type WindnerdAdapterOptions = StationAdapterOptions & {
|
|
11
10
|
recordsUrl?: string;
|
|
@@ -28,19 +27,19 @@ type WindnerdRecords = {
|
|
|
28
27
|
stationPressureMaxHpa: Array<number | null>;
|
|
29
28
|
};
|
|
30
29
|
declare const loadWindnerdStation: StationAdapter<{
|
|
30
|
+
elevationM?: number | null | undefined;
|
|
31
|
+
latitude?: number | null | undefined;
|
|
32
|
+
longitude?: number | null | undefined;
|
|
33
|
+
id: string;
|
|
34
|
+
name: string;
|
|
35
|
+
timeZone?: string | null | undefined;
|
|
36
|
+
pageUrl?: string | null | undefined;
|
|
37
|
+
vendor: "windnerd";
|
|
31
38
|
stationKey: string;
|
|
32
39
|
locationId: number;
|
|
33
40
|
hasTemperature: boolean;
|
|
34
41
|
hasPressure: boolean;
|
|
35
42
|
hasBattery: boolean;
|
|
36
|
-
id: string;
|
|
37
|
-
name: string;
|
|
38
|
-
vendor: "windnerd";
|
|
39
|
-
timeZone?: string | null | undefined;
|
|
40
|
-
pageUrl?: string | null | undefined;
|
|
41
|
-
elevationM?: number | null | undefined;
|
|
42
|
-
latitude?: number | null | undefined;
|
|
43
|
-
longitude?: number | null | undefined;
|
|
44
43
|
}, WindnerdAdapterOptions>;
|
|
45
44
|
declare function windnerdHistoryPoints(records: WindnerdRecords, config: Pick<WindnerdStationConfig, "hasTemperature" | "hasPressure" | "elevationM">): HistoryPoint[];
|
|
46
45
|
type WindnerdHistoryQuery = {
|
|
@@ -94,4 +93,4 @@ declare function windnerdLiveSamples(records: WindnerdLiveSampleRecord[]): LiveS
|
|
|
94
93
|
declare function windnerdEnrichedMeta(config: Pick<WindnerdStationConfig, "latitude" | "longitude" | "timeZone" | "elevationM">, location: WindnerdLiveLocation | null, broadcastDelaySeconds: number | null): Partial<StationMeta>;
|
|
95
94
|
declare function parseWindnerdRecords(value: string, locationId: number, hasPressure?: boolean): WindnerdRecords;
|
|
96
95
|
//#endregion
|
|
97
|
-
export { WINDNERD_LIVE_SAMPLE_INTERVAL_SECONDS,
|
|
96
|
+
export { WINDNERD_LIVE_SAMPLE_INTERVAL_SECONDS, WindnerdAdapterOptions, WindnerdHistoryQuery, WindnerdLiveDigest, WindnerdLiveInit, WindnerdLiveLocation, WindnerdLiveSampleRecord, WindnerdRecords, loadWindnerdHistory, loadWindnerdStation, parseStandardTimeOffset, parseWindnerdLiveDigest, parseWindnerdLiveInit, parseWindnerdLiveLocation, parseWindnerdLiveSampleRecords, parseWindnerdRecentSummaries, parseWindnerdRecords, windnerdEnrichedMeta, windnerdHistoryPoints, windnerdLiveReading, windnerdLiveSamples, windnerdLiveStreamUrl };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { emptyConditions } from "../../contract.js";
|
|
2
2
|
import { isCalm, normalizeDegrees, pressureTendency, seaLevelPressureHpa } from "../../derive.js";
|
|
3
|
-
import { windnerdStationUrl } from "../../windnerd.js";
|
|
3
|
+
import { WINDNERD_RECORD_PERIODS_MINUTES, windnerdStationUrl } from "../../windnerd.js";
|
|
4
4
|
import { sseEvents } from "../../sse.js";
|
|
5
5
|
import { coalesceUpstreamLoad, fetchUpstreamStream, fetchUpstreamText, logUpstreamFailure, resolveEnvironment } from "../environment.js";
|
|
6
6
|
import { defineStationAdapter } from "../adapter.js";
|
|
@@ -9,16 +9,6 @@ import { UpstreamError } from "@azohra/meteo.core";
|
|
|
9
9
|
const WINDNERD_RECORDS_URL = "https://windnerd.net/api/records";
|
|
10
10
|
const WINDNERD_LIVE_URL = "https://windnerd.net/api/live-url";
|
|
11
11
|
const RECORD_PERIOD_MINUTES = 1;
|
|
12
|
-
const WINDNERD_RECORD_PERIODS_MINUTES = [
|
|
13
|
-
1,
|
|
14
|
-
5,
|
|
15
|
-
10,
|
|
16
|
-
15,
|
|
17
|
-
30,
|
|
18
|
-
60,
|
|
19
|
-
180,
|
|
20
|
-
360
|
|
21
|
-
];
|
|
22
12
|
const CACHE_TTL_SECONDS = 60;
|
|
23
13
|
const AGGREGATE_CACHE_TTL_SECONDS = 900;
|
|
24
14
|
const LIVE_CACHE_TTL_SECONDS = 15;
|
|
@@ -26,7 +16,7 @@ const LOCATION_CACHE_TTL_SECONDS = 21600;
|
|
|
26
16
|
const LOCATION_MISS_CACHE_TTL_SECONDS = 900;
|
|
27
17
|
const WINDNERD_LIVE_INIT_TIMEOUT_MS = 8e3;
|
|
28
18
|
const WINDNERD_LIVE_SAMPLE_INTERVAL_SECONDS = 3;
|
|
29
|
-
const SENSOR_VALUE_LOOKBACK_MS =
|
|
19
|
+
const SENSOR_VALUE_LOOKBACK_MS = 9e5;
|
|
30
20
|
const MAX_WIND_MPS = 140;
|
|
31
21
|
const STATION_PRESSURE_MIN_HPA = 300;
|
|
32
22
|
const STATION_PRESSURE_MAX_HPA = 1100;
|
|
@@ -495,4 +485,4 @@ function isRecord(value) {
|
|
|
495
485
|
return typeof value === "object" && value !== null;
|
|
496
486
|
}
|
|
497
487
|
//#endregion
|
|
498
|
-
export { WINDNERD_LIVE_INIT_TIMEOUT_MS, WINDNERD_LIVE_SAMPLE_INTERVAL_SECONDS, WINDNERD_RECORDS_URL,
|
|
488
|
+
export { WINDNERD_LIVE_INIT_TIMEOUT_MS, WINDNERD_LIVE_SAMPLE_INTERVAL_SECONDS, WINDNERD_RECORDS_URL, loadWindnerdHistory, loadWindnerdLocation, loadWindnerdStation, parseStandardTimeOffset, parseWindnerdLiveDigest, parseWindnerdLiveInit, parseWindnerdLiveLocation, parseWindnerdLiveSampleRecords, parseWindnerdRecentSummaries, parseWindnerdRecords, windnerdEnrichedMeta, windnerdHistoryPoints, windnerdLiveReading, windnerdLiveSamples, windnerdLiveStreamUrl, windnerdStationMeta };
|