@azohra/meteo.station 0.3.0 → 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.
- package/README.md +2 -2
- package/dist/client/climatology.d.ts +27 -0
- package/dist/client/climatology.js +83 -0
- package/dist/client/history.d.ts +53 -0
- package/dist/client/history.js +114 -0
- package/dist/client/index.d.ts +3 -1
- package/dist/client/index.js +3 -1
- package/dist/client/live.js +15 -0
- package/dist/climatology.d.ts +61 -0
- package/dist/climatology.js +208 -0
- package/dist/connectivity.d.ts +46 -0
- package/dist/connectivity.js +44 -0
- package/dist/contract-climatology.d.ts +69 -0
- package/dist/contract-climatology.js +50 -0
- package/dist/contract.d.ts +234 -1
- package/dist/contract.js +52 -4
- package/dist/derive.d.ts +23 -1
- package/dist/derive.js +43 -4
- package/dist/display.d.ts +4 -0
- package/dist/display.js +2 -1
- package/dist/elements/elements/AirExtremesElement.d.ts +8 -0
- package/dist/elements/elements/AirExtremesElement.js +33 -0
- package/dist/elements/elements/ClimatologyDailyPatternElement.d.ts +15 -0
- package/dist/elements/elements/ClimatologyDailyPatternElement.js +84 -0
- package/dist/elements/elements/ClimatologyRoseElement.d.ts +14 -0
- package/dist/elements/elements/ClimatologyRoseElement.js +51 -0
- package/dist/elements/elements/CompassFanElement.d.ts +14 -0
- package/dist/elements/elements/CompassFanElement.js +92 -0
- package/dist/elements/elements/DailyPatternElement.d.ts +1 -0
- package/dist/elements/elements/DailyPatternElement.js +20 -12
- package/dist/elements/elements/DialElement.js +14 -3
- package/dist/elements/elements/FavorableShareElement.d.ts +14 -0
- package/dist/elements/elements/FavorableShareElement.js +47 -0
- package/dist/elements/elements/RecentSummariesElement.d.ts +14 -0
- package/dist/elements/elements/RecentSummariesElement.js +54 -0
- package/dist/elements/elements/StationFeedElement.d.ts +3 -0
- package/dist/elements/elements/StationFeedElement.js +13 -2
- package/dist/elements/elements/WindHistoryChartElement.js +16 -3
- package/dist/elements/elements/WindRoseElement.d.ts +1 -3
- package/dist/elements/elements/WindRoseElement.js +60 -62
- package/dist/elements/elements/atoms.js +3 -3
- package/dist/elements/index.d.ts +13 -1
- package/dist/elements/index.js +15 -3
- package/dist/elements/lib/ambient.d.ts +2 -0
- package/dist/elements/lib/attributes.js +24 -1
- package/dist/elements/lib/base.d.ts +3 -0
- package/dist/elements/lib/base.js +14 -2
- package/dist/endpoints.d.ts +7 -1
- package/dist/endpoints.js +13 -1
- package/dist/geometry.d.ts +22 -3
- package/dist/geometry.js +41 -5
- package/dist/index.d.ts +9 -6
- package/dist/index.js +9 -6
- package/dist/instruments.d.ts +7 -5
- package/dist/instruments.js +20 -7
- package/dist/merge-current.js +2 -1
- package/dist/react/components/AirExtremes.d.ts +16 -0
- package/dist/react/components/AirExtremes.js +38 -0
- package/dist/react/components/ClimatologyDailyPattern.d.ts +20 -0
- package/dist/react/components/ClimatologyDailyPattern.js +59 -0
- package/dist/react/components/ClimatologyRose.d.ts +18 -0
- package/dist/react/components/ClimatologyRose.js +45 -0
- package/dist/react/components/CompassFan.d.ts +17 -0
- package/dist/react/components/CompassFan.js +93 -0
- package/dist/react/components/DailyPattern.d.ts +4 -1
- package/dist/react/components/DailyPattern.js +13 -6
- package/dist/react/components/Dial.d.ts +3 -1
- package/dist/react/components/Dial.js +13 -2
- package/dist/react/components/FavorableShare.d.ts +14 -0
- package/dist/react/components/FavorableShare.js +43 -0
- package/dist/react/components/RecentSummaries.d.ts +19 -0
- package/dist/react/components/RecentSummaries.js +65 -0
- package/dist/react/components/StationFeedProvider.d.ts +4 -1
- package/dist/react/components/StationFeedProvider.js +5 -3
- package/dist/react/components/WindHistoryChart.d.ts +6 -1
- package/dist/react/components/WindHistoryChart.js +18 -3
- package/dist/react/components/WindRose.d.ts +4 -2
- package/dist/react/components/WindRose.js +80 -71
- package/dist/react/components/WindSampleStrip.d.ts +3 -1
- package/dist/react/components/WindSampleStrip.js +6 -3
- package/dist/react/components/atoms.d.ts +4 -1
- package/dist/react/components/atoms.js +6 -3
- package/dist/react/hooks/useStationClimatology.d.ts +18 -0
- package/dist/react/hooks/useStationClimatology.js +25 -0
- package/dist/react/index.d.ts +10 -3
- package/dist/react/index.js +9 -2
- package/dist/scene/air-extremes.d.ts +2 -0
- package/dist/scene/air-extremes.js +42 -0
- package/dist/scene/atoms.d.ts +2 -1
- package/dist/scene/atoms.js +6 -4
- package/dist/scene/climatology-pattern.d.ts +6 -0
- package/dist/scene/climatology-pattern.js +35 -0
- package/dist/scene/climatology-rose.d.ts +5 -0
- package/dist/scene/climatology-rose.js +49 -0
- package/dist/scene/compass-fan.d.ts +3 -0
- package/dist/scene/compass-fan.js +115 -0
- package/dist/scene/daily-pattern.d.ts +1 -0
- package/dist/scene/daily-pattern.js +20 -6
- package/dist/scene/dial.d.ts +1 -0
- package/dist/scene/dial.js +16 -3
- package/dist/scene/favorable-share.d.ts +3 -0
- package/dist/scene/favorable-share.js +41 -0
- package/dist/scene/index.d.ts +9 -3
- package/dist/scene/recent-summaries.d.ts +4 -0
- package/dist/scene/recent-summaries.js +75 -0
- package/dist/scene/rose.d.ts +2 -1
- package/dist/scene/rose.js +18 -3
- package/dist/scene/sample-strip.d.ts +1 -0
- package/dist/scene/sample-strip.js +1 -1
- package/dist/scene/wind-history.d.ts +1 -0
- package/dist/scene/wind-history.js +4 -3
- package/dist/scene/wind-plot.d.ts +1 -0
- package/dist/scene/wind-plot.js +30 -3
- package/dist/server/adapter.d.ts +2 -1
- package/dist/server/adapter.js +2 -1
- package/dist/server/adapters/windnerd-climatology.d.ts +33 -0
- package/dist/server/adapters/windnerd-climatology.js +81 -0
- package/dist/server/adapters/windnerd-live.js +21 -13
- package/dist/server/adapters/windnerd.d.ts +31 -4
- package/dist/server/adapters/windnerd.js +197 -19
- package/dist/server/feed.d.ts +44 -2
- package/dist/server/feed.js +63 -2
- package/dist/server/handler.d.ts +11 -1
- package/dist/server/handler.js +83 -2
- package/dist/server/hologram.d.ts +22 -0
- package/dist/server/hologram.js +113 -0
- package/dist/server/index.d.ts +5 -3
- package/dist/server/index.js +5 -3
- package/dist/strings.d.ts +12 -0
- package/dist/strings.js +12 -0
- package/package.json +2 -2
- package/schema/example-climatology.json +86 -0
- package/schema/example-history.json +38 -0
- package/schema/stationclimatology.schema.json +195 -0
- package/schema/stationcurrent.schema.json +173 -0
- package/schema/stationfeed.schema.json +173 -0
- package/schema/stationhistory.schema.json +186 -0
- package/schema/stationlive.schema.json +202 -0
- package/styles.css +215 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Station } from "../../contract.js";
|
|
2
2
|
import { FreshnessStatus, SpeedThresholds } from "../../derive.js";
|
|
3
3
|
import { FormatTime, StationStringOverrides } from "../../strings.js";
|
|
4
|
+
import { FavorableDirection } from "../../instruments.js";
|
|
4
5
|
import { ResolvedDisplay } from "../../display.js";
|
|
5
6
|
import "../../index.js";
|
|
6
7
|
import { AmbientStationFeed } from "./ambient.js";
|
|
@@ -30,6 +31,8 @@ declare abstract class MeteoStationElement extends MeteoElement {
|
|
|
30
31
|
set formatTime(value: FormatTime | undefined);
|
|
31
32
|
get thresholds(): SpeedThresholds | null | undefined;
|
|
32
33
|
set thresholds(value: SpeedThresholds | null | undefined);
|
|
34
|
+
get favorableDirections(): FavorableDirection[] | null | undefined;
|
|
35
|
+
set favorableDirections(value: FavorableDirection[] | null | undefined);
|
|
33
36
|
protected display(): ResolvedDisplay;
|
|
34
37
|
protected requiredStation(component: string): Station;
|
|
35
38
|
get servedAt(): string | null | undefined;
|
|
@@ -2,7 +2,7 @@ import { freshness, stationFreshnessThresholds } from "../../derive.js";
|
|
|
2
2
|
import { requireResolved, resolveDisplay, resolveStation } from "../../display.js";
|
|
3
3
|
import { subscribeTicker } from "../../client/ticker.js";
|
|
4
4
|
import { ELEMENTS_AMBIENT_HINT, STATION_FEED_CONTEXT_KEY } from "./ambient.js";
|
|
5
|
-
import { numberAttribute, parseThresholdsAttribute, unitAttribute } from "./attributes.js";
|
|
5
|
+
import { numberAttribute, parseArcsAttribute, parseThresholdsAttribute, unitAttribute } from "./attributes.js";
|
|
6
6
|
import { requestContext } from "./context.js";
|
|
7
7
|
//#region src/elements/lib/base.ts
|
|
8
8
|
var MeteoElement = class extends HTMLElement {
|
|
@@ -56,6 +56,8 @@ var MeteoStationElement = class extends MeteoElement {
|
|
|
56
56
|
#formatTime;
|
|
57
57
|
#thresholds = void 0;
|
|
58
58
|
#thresholdsSet = false;
|
|
59
|
+
#favorableDirections = void 0;
|
|
60
|
+
#favorableDirectionsSet = false;
|
|
59
61
|
#servedAt = void 0;
|
|
60
62
|
#receivedAtMs = void 0;
|
|
61
63
|
constructor() {
|
|
@@ -65,6 +67,7 @@ var MeteoStationElement = class extends MeteoElement {
|
|
|
65
67
|
"strings",
|
|
66
68
|
"formatTime",
|
|
67
69
|
"thresholds",
|
|
70
|
+
"favorableDirections",
|
|
68
71
|
"servedAt",
|
|
69
72
|
"receivedAtMs"
|
|
70
73
|
]) this.upgradeProperty(name);
|
|
@@ -98,12 +101,21 @@ var MeteoStationElement = class extends MeteoElement {
|
|
|
98
101
|
this.#thresholdsSet = value !== void 0;
|
|
99
102
|
this.requestRender();
|
|
100
103
|
}
|
|
104
|
+
get favorableDirections() {
|
|
105
|
+
return this.#favorableDirections;
|
|
106
|
+
}
|
|
107
|
+
set favorableDirections(value) {
|
|
108
|
+
this.#favorableDirections = value;
|
|
109
|
+
this.#favorableDirectionsSet = value !== void 0;
|
|
110
|
+
this.requestRender();
|
|
111
|
+
}
|
|
101
112
|
display() {
|
|
102
113
|
return resolveDisplay(this.ambient(), {
|
|
103
114
|
strings: this.#strings,
|
|
104
115
|
unit: unitAttribute(this.getAttribute("unit")),
|
|
105
116
|
formatTime: this.#formatTime,
|
|
106
|
-
thresholds: this.#thresholdsSet ? this.#thresholds : parseThresholdsAttribute(this.getAttribute("thresholds"))
|
|
117
|
+
thresholds: this.#thresholdsSet ? this.#thresholds : parseThresholdsAttribute(this.getAttribute("thresholds")),
|
|
118
|
+
favorableDirections: this.#favorableDirectionsSet ? this.#favorableDirections : parseArcsAttribute(this.getAttribute("favorable-directions"))
|
|
107
119
|
});
|
|
108
120
|
}
|
|
109
121
|
requiredStation(component) {
|
package/dist/endpoints.d.ts
CHANGED
|
@@ -2,5 +2,11 @@
|
|
|
2
2
|
declare function feedEndpoint(base: string): string;
|
|
3
3
|
declare function currentEndpoint(base: string, stationId: string): string;
|
|
4
4
|
declare function liveEndpoint(base: string, stationId: string): string;
|
|
5
|
+
declare function climatologyEndpoint(base: string, stationId: string): string;
|
|
6
|
+
declare function historyEndpoint(base: string, stationId: string, query: {
|
|
7
|
+
fromMs: number;
|
|
8
|
+
toMs: number;
|
|
9
|
+
periodMinutes: number;
|
|
10
|
+
}): string;
|
|
5
11
|
//#endregion
|
|
6
|
-
export { currentEndpoint, feedEndpoint, liveEndpoint };
|
|
12
|
+
export { climatologyEndpoint, currentEndpoint, feedEndpoint, historyEndpoint, liveEndpoint };
|
package/dist/endpoints.js
CHANGED
|
@@ -9,5 +9,17 @@ function currentEndpoint(base, stationId) {
|
|
|
9
9
|
function liveEndpoint(base, stationId) {
|
|
10
10
|
return `${trimBase(base)}/live?station=${encodeURIComponent(stationId)}`;
|
|
11
11
|
}
|
|
12
|
+
function climatologyEndpoint(base, stationId) {
|
|
13
|
+
return `${trimBase(base)}/climatology?station=${encodeURIComponent(stationId)}`;
|
|
14
|
+
}
|
|
15
|
+
function historyEndpoint(base, stationId, query) {
|
|
16
|
+
const params = new URLSearchParams({
|
|
17
|
+
station: stationId,
|
|
18
|
+
from: new Date(query.fromMs).toISOString(),
|
|
19
|
+
to: new Date(query.toMs).toISOString(),
|
|
20
|
+
period: String(query.periodMinutes)
|
|
21
|
+
});
|
|
22
|
+
return `${trimBase(base)}/history?${params.toString()}`;
|
|
23
|
+
}
|
|
12
24
|
//#endregion
|
|
13
|
-
export { currentEndpoint, feedEndpoint, liveEndpoint };
|
|
25
|
+
export { climatologyEndpoint, currentEndpoint, feedEndpoint, historyEndpoint, liveEndpoint };
|
package/dist/geometry.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { History, HistoryPoint } from "./contract.js";
|
|
2
|
+
import { DirectionArc } from "@azohra/meteo.core";
|
|
2
3
|
//#region src/geometry.d.ts
|
|
3
4
|
type ChartFrame = {
|
|
4
5
|
height: number;
|
|
@@ -33,7 +34,7 @@ type ChartScaleOptions = {
|
|
|
33
34
|
declare function chartScales(points: ReadonlyArray<HistoryPoint>, frame: ChartFrame, options?: ChartScaleOptions): ChartScales;
|
|
34
35
|
declare function bandPoints(points: ReadonlyArray<HistoryPoint>, scales: ChartScales): string | null;
|
|
35
36
|
declare function averagePoints(points: ReadonlyArray<HistoryPoint>, scales: ChartScales): string;
|
|
36
|
-
declare function meanDirectionDeg(points: ReadonlyArray<HistoryPoint>): number | null;
|
|
37
|
+
declare function meanDirectionDeg$1(points: ReadonlyArray<HistoryPoint>): number | null;
|
|
37
38
|
type Vane = {
|
|
38
39
|
windAvgMps: number;
|
|
39
40
|
windDirectionDeg: number | null;
|
|
@@ -62,13 +63,18 @@ type RoseSector = {
|
|
|
62
63
|
meanSpeedMps: number | null;
|
|
63
64
|
maxGustMps: number | null;
|
|
64
65
|
count: number;
|
|
66
|
+
/** Non-calm records per speed band, present only when the caller passed
|
|
67
|
+
* bandThresholdsMps — stacking is a judgment the consumer supplies. */
|
|
68
|
+
bandCounts?: number[] | undefined;
|
|
65
69
|
};
|
|
66
70
|
type WindRoseSummary = {
|
|
67
71
|
sectors: RoseSector[];
|
|
68
72
|
calmFraction: number;
|
|
69
73
|
sampleCount: number;
|
|
70
74
|
};
|
|
71
|
-
declare function windRose(points: ReadonlyArray<HistoryPoint>, sectorCount?: number
|
|
75
|
+
declare function windRose(points: ReadonlyArray<HistoryPoint>, sectorCount?: number, options?: {
|
|
76
|
+
bandThresholdsMps?: ReadonlyArray<number>;
|
|
77
|
+
}): WindRoseSummary;
|
|
72
78
|
declare const DAILY_PATTERN_DEFAULT_SLOT_MINUTES = 180;
|
|
73
79
|
type DailyPatternSlot = {
|
|
74
80
|
startMinuteOfDay: number;
|
|
@@ -83,10 +89,23 @@ declare function dailyPattern(points: ReadonlyArray<HistoryPoint>, options?: {
|
|
|
83
89
|
declare const METEOROLOGICAL_SEASON_MONTHS: Record<"fall" | "spring" | "summer" | "winter", number[]>;
|
|
84
90
|
declare function filterByMonth(points: ReadonlyArray<HistoryPoint>, months: ReadonlyArray<number>, utcOffsetMinutes?: number): HistoryPoint[];
|
|
85
91
|
declare function filterByTimeOfDay(points: ReadonlyArray<HistoryPoint>, fromMinute: number, toMinute: number, utcOffsetMinutes?: number): HistoryPoint[];
|
|
92
|
+
/** The share of non-calm history blowing from inside the consumer's arcs;
|
|
93
|
+
* null when nothing non-calm was measured — absence over a fabricated zero. */
|
|
94
|
+
declare function favorableShare(points: ReadonlyArray<HistoryPoint>, arcs: ReadonlyArray<DirectionArc>): number | null;
|
|
95
|
+
type HistoryCoverage = {
|
|
96
|
+
actualCount: number;
|
|
97
|
+
expectedCount: number;
|
|
98
|
+
ratio: number;
|
|
99
|
+
};
|
|
100
|
+
/** Coverage of a requested window: points held against the count the period
|
|
101
|
+
* implies for [fromMs, toMs). Expected comes from the request, never from the
|
|
102
|
+
* first-to-last point span, so leading and trailing dropouts lower the ratio
|
|
103
|
+
* instead of hiding. */
|
|
104
|
+
declare function historyCoverage(points: ReadonlyArray<HistoryPoint>, periodMinutes: number, fromMs: number, toMs: number): HistoryCoverage;
|
|
86
105
|
declare function historyGaps(history: History, toleranceFactor?: number): Array<[number, number]>;
|
|
87
106
|
type TrendSeries = "temperature" | "pressure";
|
|
88
107
|
declare function windowPoints(points: ReadonlyArray<HistoryPoint>, hours?: number): ReadonlyArray<HistoryPoint>;
|
|
89
108
|
declare function compareWindow(points: ReadonlyArray<HistoryPoint>, offsetDays: number, windowHours?: number): HistoryPoint[] | null;
|
|
90
109
|
declare function compareTracePoints(comparePoints: ReadonlyArray<HistoryPoint>, scales: ChartScales, offsetDays: number): string;
|
|
91
110
|
//#endregion
|
|
92
|
-
export { CHART_FALLBACK_WIDTH, ChartFrame, ChartScaleOptions, ChartScales, ChartTick, DAILY_PATTERN_DEFAULT_SLOT_MINUTES, DailyPatternSlot, METEOROLOGICAL_SEASON_MONTHS, RoseSector, TickAnchor, TrendSeries, Vane, WindRoseSummary, averagePoints, bandPoints, chartFrame, chartScales, compareTracePoints, compareWindow, dailyPattern, filterByMonth, filterByTimeOfDay, historyGaps, meanDirectionDeg, measuredChartWidth, nearestIndex, speedBand, thinVanes, tickAnchor, vanePath, vaneTicks, windRose, windowPoints };
|
|
111
|
+
export { CHART_FALLBACK_WIDTH, ChartFrame, ChartScaleOptions, ChartScales, ChartTick, DAILY_PATTERN_DEFAULT_SLOT_MINUTES, DailyPatternSlot, HistoryCoverage, METEOROLOGICAL_SEASON_MONTHS, RoseSector, TickAnchor, TrendSeries, Vane, WindRoseSummary, averagePoints, bandPoints, chartFrame, chartScales, compareTracePoints, compareWindow, dailyPattern, favorableShare, filterByMonth, filterByTimeOfDay, historyCoverage, historyGaps, meanDirectionDeg$1 as meanDirectionDeg, measuredChartWidth, nearestIndex, speedBand, thinVanes, tickAnchor, vanePath, vaneTicks, windRose, windowPoints };
|
package/dist/geometry.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { KMH_PER_MPS, isCalm, normalizeDegrees, radians } from "./derive.js";
|
|
2
|
-
import { componentsToWind, meanDirectionDeg, windToComponents } from "@azohra/meteo.core";
|
|
2
|
+
import { componentsToWind, inDirectionArcs, meanDirectionDeg, windToComponents } from "@azohra/meteo.core";
|
|
3
3
|
//#region src/geometry.ts
|
|
4
4
|
const CHART_FALLBACK_WIDTH = 360;
|
|
5
5
|
const CHART_AXIS_GUTTER = 46;
|
|
@@ -164,12 +164,14 @@ function speedBand(speedMps, thresholdsMps) {
|
|
|
164
164
|
}
|
|
165
165
|
return band;
|
|
166
166
|
}
|
|
167
|
-
function windRose(points, sectorCount = 16) {
|
|
167
|
+
function windRose(points, sectorCount = 16, options = {}) {
|
|
168
168
|
const sectorWidth = 360 / sectorCount;
|
|
169
|
+
const bounds = options.bandThresholdsMps ?? null;
|
|
169
170
|
const sectors = Array.from({ length: sectorCount }, (_, index) => ({
|
|
170
171
|
bearingDeg: index * sectorWidth,
|
|
171
172
|
speeds: [],
|
|
172
|
-
gusts: []
|
|
173
|
+
gusts: [],
|
|
174
|
+
bandCounts: bounds == null ? null : Array.from({ length: bounds.length + 1 }, () => 0)
|
|
173
175
|
}));
|
|
174
176
|
let calm = 0;
|
|
175
177
|
let counted = 0;
|
|
@@ -182,6 +184,10 @@ function windRose(points, sectorCount = 16) {
|
|
|
182
184
|
const sector = sectors[Math.round(normalizeDegrees(point.windDirectionDeg) / sectorWidth) % sectorCount];
|
|
183
185
|
sector.speeds.push(point.windAvgMps);
|
|
184
186
|
if (point.windGustMps != null) sector.gusts.push(point.windGustMps);
|
|
187
|
+
if (bounds != null && sector.bandCounts != null) {
|
|
188
|
+
const band = speedBand(point.windAvgMps, bounds);
|
|
189
|
+
sector.bandCounts[band] = (sector.bandCounts[band] ?? 0) + 1;
|
|
190
|
+
}
|
|
185
191
|
}
|
|
186
192
|
const blowing = counted - calm;
|
|
187
193
|
return {
|
|
@@ -192,7 +198,8 @@ function windRose(points, sectorCount = 16) {
|
|
|
192
198
|
count: sector.speeds.length,
|
|
193
199
|
frequency: blowing === 0 ? 0 : sector.speeds.length / blowing,
|
|
194
200
|
meanSpeedMps: sector.speeds.length === 0 ? null : sector.speeds.reduce((sum, speed) => sum + speed, 0) / sector.speeds.length,
|
|
195
|
-
maxGustMps: sector.gusts.length === 0 ? null : Math.max(...sector.gusts)
|
|
201
|
+
maxGustMps: sector.gusts.length === 0 ? null : Math.max(...sector.gusts),
|
|
202
|
+
...sector.bandCounts == null ? {} : { bandCounts: sector.bandCounts }
|
|
196
203
|
}))
|
|
197
204
|
};
|
|
198
205
|
}
|
|
@@ -252,6 +259,35 @@ function filterByTimeOfDay(points, fromMinute, toMinute, utcOffsetMinutes = 0) {
|
|
|
252
259
|
return wraps ? minute >= fromMinute || minute < toMinute : minute >= fromMinute && minute < toMinute;
|
|
253
260
|
});
|
|
254
261
|
}
|
|
262
|
+
/** The share of non-calm history blowing from inside the consumer's arcs;
|
|
263
|
+
* null when nothing non-calm was measured — absence over a fabricated zero. */
|
|
264
|
+
function favorableShare(points, arcs) {
|
|
265
|
+
let blowing = 0;
|
|
266
|
+
let favorable = 0;
|
|
267
|
+
for (const point of points) {
|
|
268
|
+
if (isCalm(point.windAvgMps) || point.windDirectionDeg == null) continue;
|
|
269
|
+
blowing += 1;
|
|
270
|
+
if (inDirectionArcs(point.windDirectionDeg, arcs)) favorable += 1;
|
|
271
|
+
}
|
|
272
|
+
return blowing === 0 ? null : favorable / blowing;
|
|
273
|
+
}
|
|
274
|
+
/** Coverage of a requested window: points held against the count the period
|
|
275
|
+
* implies for [fromMs, toMs). Expected comes from the request, never from the
|
|
276
|
+
* first-to-last point span, so leading and trailing dropouts lower the ratio
|
|
277
|
+
* instead of hiding. */
|
|
278
|
+
function historyCoverage(points, periodMinutes, fromMs, toMs) {
|
|
279
|
+
const expectedCount = Math.max(0, Math.floor((toMs - fromMs) / (periodMinutes * 6e4)));
|
|
280
|
+
let actualCount = 0;
|
|
281
|
+
for (const point of points) {
|
|
282
|
+
const observedMs = Date.parse(point.observedAt);
|
|
283
|
+
if (observedMs >= fromMs && observedMs < toMs) actualCount += 1;
|
|
284
|
+
}
|
|
285
|
+
return {
|
|
286
|
+
actualCount,
|
|
287
|
+
expectedCount,
|
|
288
|
+
ratio: expectedCount === 0 ? 0 : actualCount / expectedCount
|
|
289
|
+
};
|
|
290
|
+
}
|
|
255
291
|
const HISTORY_GAP_TOLERANCE_FACTOR = 2.5;
|
|
256
292
|
function historyGaps(history, toleranceFactor = HISTORY_GAP_TOLERANCE_FACTOR) {
|
|
257
293
|
const gaps = [];
|
|
@@ -337,4 +373,4 @@ function compareTracePoints(comparePoints, scales, offsetDays) {
|
|
|
337
373
|
return comparePoints.map((point) => coordinate(scales.xAtMs(Date.parse(point.observedAt) + shiftMs), scales.yAt(point.windAvgMps))).join(" ");
|
|
338
374
|
}
|
|
339
375
|
//#endregion
|
|
340
|
-
export { CHART_FALLBACK_WIDTH, DAILY_PATTERN_DEFAULT_SLOT_MINUTES, HISTORY_GAP_TOLERANCE_FACTOR, METEOROLOGICAL_SEASON_MONTHS, averagePoints, bandPoints, chartFrame, chartScales, compareTracePoints, compareWindow, dailyPattern, filterByMonth, filterByTimeOfDay, historyGaps, isCalmHistory, meanDirectionDeg$1 as meanDirectionDeg, measuredChartWidth, nearestIndex, speedBand, stretchFrame, thinVanes, tickAnchor, trendRuns, trendSeriesPad, trendValueOf, valueScale, vanePath, vaneTicks, vectorMeanWind, windRose, windowPoints };
|
|
376
|
+
export { CHART_FALLBACK_WIDTH, DAILY_PATTERN_DEFAULT_SLOT_MINUTES, HISTORY_GAP_TOLERANCE_FACTOR, METEOROLOGICAL_SEASON_MONTHS, averagePoints, bandPoints, chartFrame, chartScales, compareTracePoints, compareWindow, dailyPattern, favorableShare, filterByMonth, filterByTimeOfDay, historyCoverage, historyGaps, isCalmHistory, meanDirectionDeg$1 as meanDirectionDeg, measuredChartWidth, nearestIndex, speedBand, stretchFrame, thinVanes, tickAnchor, trendRuns, trendSeriesPad, trendValueOf, valueScale, vanePath, vaneTicks, vectorMeanWind, windRose, windowPoints };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import { AirConditions, History, HistoryPoint, LiveSample, LiveSamples, Reading, STATION_SCHEMA_VERSION, Station, StationCapabilities, StationCurrent, StationFeed, StationLiveFrame, StationMeta, StationTelemetry, UNAVAILABLE_REASONS, UnavailableReason, airConditionsSchema, capabilitiesSchema, emptyConditions, historyPointSchema, historySchema, liveSampleSchema, liveSamplesSchema, parseStationCurrent, parseStationCurrentJson, parseStationFeed, parseStationFeedJson, parseStationLiveFrame, parseStationLiveFrameJson, readingSchema, stationCurrentSchema, stationFeedSchema, stationLiveFrameSchema, stationMetaSchema, stationSchema, telemetrySchema, unavailableStation } from "./contract.js";
|
|
2
|
-
import {
|
|
1
|
+
import { AirConditions, History, HistoryPoint, LiveSample, LiveSamples, Reading, RecentSummary, STATION_SCHEMA_VERSION, Station, StationCapabilities, StationCurrent, StationFeed, StationHistory, StationLiveFrame, StationMeta, StationTelemetry, UNAVAILABLE_REASONS, UnavailableReason, airConditionsSchema, capabilitiesSchema, declaredFavorableDirections, directionArcSchema, emptyConditions, historyPointSchema, historySchema, liveSampleSchema, liveSamplesSchema, parseStationCurrent, parseStationCurrentJson, parseStationFeed, parseStationFeedJson, parseStationHistory, parseStationHistoryJson, parseStationLiveFrame, parseStationLiveFrameJson, readingSchema, recentSummarySchema, stationCurrentSchema, stationFeedSchema, stationHistorySchema, stationLiveFrameSchema, stationMetaSchema, stationSchema, telemetrySchema, unavailableStation } from "./contract.js";
|
|
2
|
+
import { ClimatologyCell, ClimatologySector, ClimatologyYear, STATION_CLIMATOLOGY_SCHEMA_VERSION, StationClimatology, climatologyCellSchema, climatologySectorSchema, climatologyYearSchema, parseStationClimatology, parseStationClimatologyJson, stationClimatologySchema } from "./contract-climatology.js";
|
|
3
|
+
import { CALM_THRESHOLD_MPS, COMPASS_POINTS, CompassPoint, FreshnessStatus, FreshnessThresholds, PeriodSummary, PressureTendency, SpeedThresholds, SpeedUnit, compassDirection, freshness, isCalm, lastNightLowC, normalizeDegrees, periodSummary, pressureDeltaHpa, pressureTendency, seaLevelPressureHpa, speedFromMps, speedToMps, speedUnitLabel, stationFreshnessThresholds, thresholdsToMps } from "./derive.js";
|
|
3
4
|
import { FormatTime, StationStringOverrides, StationStrings, defaultFormatTime, defaultStrings, localeFormatTime, mergeStringOverrides, resolveStrings } from "./strings.js";
|
|
4
5
|
import { DirectionCellData, SummaryEntry, directionCell, optionalSpeed, roundSpeed, summaryEntries, temperatureText, temperatureValue, updatedAtText } from "./format.js";
|
|
6
|
+
import { CONNECTIVITY_SERVICE_STATES, ConnectivityServiceState, ConnectivitySession, StationConnectivity, connectivitySessionSchema, parseStationConnectivity, stationConnectivitySchema } from "./connectivity.js";
|
|
7
|
+
import { DIAL_CARDINALS, DIAL_CARDINAL_TICK_INNER, DIAL_CENTRE, DIAL_COUNTERWEIGHT_RADIUS, DIAL_COUNTERWEIGHT_REACH, DIAL_HUB_RADIUS, DIAL_LETTER_RADIUS, DIAL_MIN_MAX_MPS, DIAL_RING_RADIUS, DIAL_SIZE, DIAL_TICK_INNER, FavorableDirection, HistoryRun, ROSE_CARDINAL_LETTERS, ROSE_CENTRE, ROSE_FAVORABLE_RING_RADIUS, ROSE_HUB_DOT_RADIUS, ROSE_HUB_RADIUS, ROSE_INTERCARDINAL_BEARINGS, ROSE_LETTER_RADIUS, ROSE_MAX_RADIUS, ROSE_PETAL_FILL, ROSE_SIZE, ROSE_TICK_REACH, SPARKLINE_EDGE_INSET, SPARKLINE_MAX_PADDING, bandStrips, dialNeedlePoints, dialPolar, dialScaleMaxMps, dialSpeedArcPath, historyRuns, roseBandPath, rosePetalPath, rosePolar, roseRingArcPath, sparklineScale } from "./instruments.js";
|
|
5
8
|
import { DisplayDefaults, DisplayProps, ResolvedDisplay, requireResolved, resolveDisplay, resolveStation } from "./display.js";
|
|
6
|
-
import { currentEndpoint, feedEndpoint, liveEndpoint } from "./endpoints.js";
|
|
7
|
-
import { CHART_FALLBACK_WIDTH, ChartFrame, ChartScaleOptions, ChartScales, ChartTick, DAILY_PATTERN_DEFAULT_SLOT_MINUTES, DailyPatternSlot, METEOROLOGICAL_SEASON_MONTHS, RoseSector, TickAnchor, Vane, WindRoseSummary, averagePoints, bandPoints, chartFrame, chartScales, compareTracePoints, compareWindow, dailyPattern, filterByMonth, filterByTimeOfDay, historyGaps, meanDirectionDeg, measuredChartWidth, nearestIndex, speedBand, thinVanes, tickAnchor, vanePath, vaneTicks, windRose, windowPoints } from "./geometry.js";
|
|
8
|
-
import {
|
|
9
|
+
import { climatologyEndpoint, currentEndpoint, feedEndpoint, historyEndpoint, liveEndpoint } from "./endpoints.js";
|
|
10
|
+
import { CHART_FALLBACK_WIDTH, ChartFrame, ChartScaleOptions, ChartScales, ChartTick, DAILY_PATTERN_DEFAULT_SLOT_MINUTES, DailyPatternSlot, HistoryCoverage, METEOROLOGICAL_SEASON_MONTHS, RoseSector, TickAnchor, Vane, WindRoseSummary, averagePoints, bandPoints, chartFrame, chartScales, compareTracePoints, compareWindow, dailyPattern, favorableShare, filterByMonth, filterByTimeOfDay, historyCoverage, historyGaps, meanDirectionDeg, measuredChartWidth, nearestIndex, speedBand, thinVanes, tickAnchor, vanePath, vaneTicks, windRose, windowPoints } from "./geometry.js";
|
|
11
|
+
import { ClimatologyAccumulator, ClimatologyCoverage, ClimatologyFilters, ClimatologyFoldParams, accumulatedCells, climatologyCoverage, climatologyFavorableShare, climatologyPattern, climatologyRose, createClimatologyAccumulator, foldClimatologyPoints } from "./climatology.js";
|
|
9
12
|
import { MergeResult, foldCurrent, mergeCurrent } from "./merge-current.js";
|
|
10
13
|
import { SAMPLE_GAP_TOLERANCE_FACTOR, SamplesSummary, sampleMeanDirectionDeg, samplePoints, sampleRuns, sampleScales, samplesSummary, thinSampleVanes } from "./samples.js";
|
|
11
14
|
import { AirRow, airRows, airSummary, lastStrikeWords } from "./air.js";
|
|
12
15
|
import { normalizeWindnerdStationKey, windnerdStationUrl } from "./windnerd.js";
|
|
13
|
-
export { type AirConditions, type AirRow, CALM_THRESHOLD_MPS, CHART_FALLBACK_WIDTH, COMPASS_POINTS, type ChartFrame, type ChartScaleOptions, type ChartScales, type ChartTick, type CompassPoint, DAILY_PATTERN_DEFAULT_SLOT_MINUTES, DIAL_CARDINALS, DIAL_CARDINAL_TICK_INNER, DIAL_CENTRE, DIAL_COUNTERWEIGHT_RADIUS, DIAL_COUNTERWEIGHT_REACH, DIAL_HUB_RADIUS, DIAL_LETTER_RADIUS, DIAL_MIN_MAX_MPS, DIAL_RING_RADIUS, DIAL_SIZE, DIAL_TICK_INNER, type DailyPatternSlot, type DirectionCellData, type DisplayDefaults, type DisplayProps, type FavorableDirection, type FormatTime, type FreshnessStatus, type FreshnessThresholds, type History, type HistoryPoint, type HistoryRun, type LiveSample, type LiveSamples, METEOROLOGICAL_SEASON_MONTHS, type MergeResult, type PeriodSummary, type PressureTendency, ROSE_CARDINAL_LETTERS, ROSE_CENTRE, ROSE_FAVORABLE_RING_RADIUS, ROSE_HUB_DOT_RADIUS, ROSE_HUB_RADIUS, ROSE_INTERCARDINAL_BEARINGS, ROSE_LETTER_RADIUS, ROSE_MAX_RADIUS, ROSE_PETAL_FILL, ROSE_SIZE, ROSE_TICK_REACH, type Reading, type ResolvedDisplay, type RoseSector, SAMPLE_GAP_TOLERANCE_FACTOR, SPARKLINE_EDGE_INSET, SPARKLINE_MAX_PADDING, STATION_SCHEMA_VERSION, type SamplesSummary, type SpeedThresholds, type SpeedUnit, type Station, type StationCapabilities, type StationCurrent, type StationFeed, type StationLiveFrame, type StationMeta, type StationStringOverrides, type StationStrings, type StationTelemetry, type SummaryEntry, type TickAnchor, UNAVAILABLE_REASONS, type UnavailableReason, type Vane, type WindRoseSummary, airConditionsSchema, airRows, airSummary, averagePoints, bandPoints, bandStrips, capabilitiesSchema, chartFrame, chartScales, compareTracePoints, compareWindow, compassDirection, currentEndpoint, dailyPattern, defaultFormatTime, defaultStrings, dialNeedlePoints, dialPolar, dialScaleMaxMps, dialSpeedArcPath, directionCell, emptyConditions, feedEndpoint, filterByMonth, filterByTimeOfDay, foldCurrent, freshness, historyGaps, meanDirectionDeg as historyMeanDirectionDeg, historyPointSchema, historyRuns, historySchema, isCalm, lastStrikeWords, liveEndpoint, liveSampleSchema, liveSamplesSchema, localeFormatTime, measuredChartWidth, mergeCurrent, mergeStringOverrides, nearestIndex, normalizeDegrees, normalizeWindnerdStationKey, optionalSpeed, parseStationCurrent, parseStationCurrentJson, parseStationFeed, parseStationFeedJson, parseStationLiveFrame, parseStationLiveFrameJson, periodSummary, pressureTendency, readingSchema, requireResolved, resolveDisplay, resolveStation, resolveStrings, rosePetalPath, rosePolar, roseRingArcPath, roundSpeed, sampleMeanDirectionDeg, samplePoints, sampleRuns, sampleScales, samplesSummary, seaLevelPressureHpa, sparklineScale, speedBand, speedFromMps, speedToMps, speedUnitLabel, stationCurrentSchema, stationFeedSchema, stationFreshnessThresholds, stationLiveFrameSchema, stationMetaSchema, stationSchema, summaryEntries, telemetrySchema, temperatureText, temperatureValue, thinSampleVanes, thinVanes, thresholdsToMps, tickAnchor, unavailableStation, updatedAtText, vanePath, vaneTicks, windRose, windnerdStationUrl, windowPoints };
|
|
16
|
+
export { type AirConditions, type AirRow, CALM_THRESHOLD_MPS, CHART_FALLBACK_WIDTH, COMPASS_POINTS, CONNECTIVITY_SERVICE_STATES, type ChartFrame, type ChartScaleOptions, type ChartScales, type ChartTick, type ClimatologyAccumulator, type ClimatologyCell, type ClimatologyCoverage, type ClimatologyFilters, type ClimatologyFoldParams, type ClimatologySector, type ClimatologyYear, type CompassPoint, type ConnectivityServiceState, type ConnectivitySession, DAILY_PATTERN_DEFAULT_SLOT_MINUTES, DIAL_CARDINALS, DIAL_CARDINAL_TICK_INNER, DIAL_CENTRE, DIAL_COUNTERWEIGHT_RADIUS, DIAL_COUNTERWEIGHT_REACH, DIAL_HUB_RADIUS, DIAL_LETTER_RADIUS, DIAL_MIN_MAX_MPS, DIAL_RING_RADIUS, DIAL_SIZE, DIAL_TICK_INNER, type DailyPatternSlot, type DirectionCellData, type DisplayDefaults, type DisplayProps, type FavorableDirection, type FormatTime, type FreshnessStatus, type FreshnessThresholds, type History, type HistoryCoverage, type HistoryPoint, type HistoryRun, type LiveSample, type LiveSamples, METEOROLOGICAL_SEASON_MONTHS, type MergeResult, type PeriodSummary, type PressureTendency, ROSE_CARDINAL_LETTERS, ROSE_CENTRE, ROSE_FAVORABLE_RING_RADIUS, ROSE_HUB_DOT_RADIUS, ROSE_HUB_RADIUS, ROSE_INTERCARDINAL_BEARINGS, ROSE_LETTER_RADIUS, ROSE_MAX_RADIUS, ROSE_PETAL_FILL, ROSE_SIZE, ROSE_TICK_REACH, type Reading, type RecentSummary, type ResolvedDisplay, type RoseSector, SAMPLE_GAP_TOLERANCE_FACTOR, SPARKLINE_EDGE_INSET, SPARKLINE_MAX_PADDING, STATION_CLIMATOLOGY_SCHEMA_VERSION, STATION_SCHEMA_VERSION, type SamplesSummary, type SpeedThresholds, type SpeedUnit, type Station, type StationCapabilities, type StationClimatology, type StationConnectivity, type StationCurrent, type StationFeed, type StationHistory, type StationLiveFrame, type StationMeta, type StationStringOverrides, type StationStrings, type StationTelemetry, type SummaryEntry, type TickAnchor, UNAVAILABLE_REASONS, type UnavailableReason, type Vane, type WindRoseSummary, accumulatedCells, airConditionsSchema, airRows, airSummary, averagePoints, bandPoints, bandStrips, capabilitiesSchema, chartFrame, chartScales, climatologyCellSchema, climatologyCoverage, climatologyEndpoint, climatologyFavorableShare, climatologyPattern, climatologyRose, climatologySectorSchema, climatologyYearSchema, compareTracePoints, compareWindow, compassDirection, connectivitySessionSchema, createClimatologyAccumulator, currentEndpoint, dailyPattern, declaredFavorableDirections, defaultFormatTime, defaultStrings, dialNeedlePoints, dialPolar, dialScaleMaxMps, dialSpeedArcPath, directionArcSchema, directionCell, emptyConditions, favorableShare, feedEndpoint, filterByMonth, filterByTimeOfDay, foldClimatologyPoints, foldCurrent, freshness, historyCoverage, historyEndpoint, historyGaps, meanDirectionDeg as historyMeanDirectionDeg, historyPointSchema, historyRuns, historySchema, isCalm, lastNightLowC, lastStrikeWords, liveEndpoint, liveSampleSchema, liveSamplesSchema, localeFormatTime, measuredChartWidth, mergeCurrent, mergeStringOverrides, nearestIndex, normalizeDegrees, normalizeWindnerdStationKey, optionalSpeed, parseStationClimatology, parseStationClimatologyJson, parseStationConnectivity, parseStationCurrent, parseStationCurrentJson, parseStationFeed, parseStationFeedJson, parseStationHistory, parseStationHistoryJson, parseStationLiveFrame, parseStationLiveFrameJson, periodSummary, pressureDeltaHpa, pressureTendency, readingSchema, recentSummarySchema, requireResolved, resolveDisplay, resolveStation, resolveStrings, roseBandPath, rosePetalPath, rosePolar, roseRingArcPath, roundSpeed, sampleMeanDirectionDeg, samplePoints, sampleRuns, sampleScales, samplesSummary, seaLevelPressureHpa, sparklineScale, speedBand, speedFromMps, speedToMps, speedUnitLabel, stationClimatologySchema, stationConnectivitySchema, stationCurrentSchema, stationFeedSchema, stationFreshnessThresholds, stationHistorySchema, stationLiveFrameSchema, stationMetaSchema, stationSchema, summaryEntries, telemetrySchema, temperatureText, temperatureValue, thinSampleVanes, thinVanes, thresholdsToMps, tickAnchor, unavailableStation, updatedAtText, vanePath, vaneTicks, windRose, windnerdStationUrl, windowPoints };
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import { STATION_SCHEMA_VERSION, UNAVAILABLE_REASONS, airConditionsSchema, capabilitiesSchema, emptyConditions, historyPointSchema, historySchema, liveSampleSchema, liveSamplesSchema, parseStationCurrent, parseStationCurrentJson, parseStationFeed, parseStationFeedJson, parseStationLiveFrame, parseStationLiveFrameJson, readingSchema, stationCurrentSchema, stationFeedSchema, stationLiveFrameSchema, stationMetaSchema, stationSchema, telemetrySchema, unavailableStation } from "./contract.js";
|
|
2
|
-
import {
|
|
1
|
+
import { STATION_SCHEMA_VERSION, UNAVAILABLE_REASONS, airConditionsSchema, capabilitiesSchema, declaredFavorableDirections, directionArcSchema, emptyConditions, historyPointSchema, historySchema, liveSampleSchema, liveSamplesSchema, parseStationCurrent, parseStationCurrentJson, parseStationFeed, parseStationFeedJson, parseStationHistory, parseStationHistoryJson, parseStationLiveFrame, parseStationLiveFrameJson, readingSchema, recentSummarySchema, stationCurrentSchema, stationFeedSchema, stationHistorySchema, stationLiveFrameSchema, stationMetaSchema, stationSchema, telemetrySchema, unavailableStation } from "./contract.js";
|
|
2
|
+
import { CONNECTIVITY_SERVICE_STATES, connectivitySessionSchema, parseStationConnectivity, stationConnectivitySchema } from "./connectivity.js";
|
|
3
|
+
import { CALM_THRESHOLD_MPS, COMPASS_POINTS, compassDirection, freshness, isCalm, lastNightLowC, normalizeDegrees, periodSummary, pressureDeltaHpa, pressureTendency, seaLevelPressureHpa, speedFromMps, speedToMps, speedUnitLabel, stationFreshnessThresholds, thresholdsToMps } from "./derive.js";
|
|
3
4
|
import { defaultFormatTime, defaultStrings, localeFormatTime, mergeStringOverrides, resolveStrings } from "./strings.js";
|
|
4
5
|
import { requireResolved, resolveDisplay, resolveStation } from "./display.js";
|
|
5
|
-
import { currentEndpoint, feedEndpoint, liveEndpoint } from "./endpoints.js";
|
|
6
|
+
import { climatologyEndpoint, currentEndpoint, feedEndpoint, historyEndpoint, liveEndpoint } from "./endpoints.js";
|
|
7
|
+
import { STATION_CLIMATOLOGY_SCHEMA_VERSION, climatologyCellSchema, climatologySectorSchema, climatologyYearSchema, parseStationClimatology, parseStationClimatologyJson, stationClimatologySchema } from "./contract-climatology.js";
|
|
8
|
+
import { CHART_FALLBACK_WIDTH, DAILY_PATTERN_DEFAULT_SLOT_MINUTES, METEOROLOGICAL_SEASON_MONTHS, averagePoints, bandPoints, chartFrame, chartScales, compareTracePoints, compareWindow, dailyPattern, favorableShare, filterByMonth, filterByTimeOfDay, historyCoverage, historyGaps, meanDirectionDeg, measuredChartWidth, nearestIndex, speedBand, thinVanes, tickAnchor, vanePath, vaneTicks, windRose, windowPoints } from "./geometry.js";
|
|
9
|
+
import { accumulatedCells, climatologyCoverage, climatologyFavorableShare, climatologyPattern, climatologyRose, createClimatologyAccumulator, foldClimatologyPoints } from "./climatology.js";
|
|
6
10
|
import { directionCell, optionalSpeed, roundSpeed, summaryEntries, temperatureText, temperatureValue, updatedAtText } from "./format.js";
|
|
7
|
-
import {
|
|
8
|
-
import { DIAL_CARDINALS, DIAL_CARDINAL_TICK_INNER, DIAL_CENTRE, DIAL_COUNTERWEIGHT_RADIUS, DIAL_COUNTERWEIGHT_REACH, DIAL_HUB_RADIUS, DIAL_LETTER_RADIUS, DIAL_MIN_MAX_MPS, DIAL_RING_RADIUS, DIAL_SIZE, DIAL_TICK_INNER, ROSE_CARDINAL_LETTERS, ROSE_CENTRE, ROSE_FAVORABLE_RING_RADIUS, ROSE_HUB_DOT_RADIUS, ROSE_HUB_RADIUS, ROSE_INTERCARDINAL_BEARINGS, ROSE_LETTER_RADIUS, ROSE_MAX_RADIUS, ROSE_PETAL_FILL, ROSE_SIZE, ROSE_TICK_REACH, SPARKLINE_EDGE_INSET, SPARKLINE_MAX_PADDING, bandStrips, dialNeedlePoints, dialPolar, dialScaleMaxMps, dialSpeedArcPath, historyRuns, rosePetalPath, rosePolar, roseRingArcPath, sparklineScale } from "./instruments.js";
|
|
11
|
+
import { DIAL_CARDINALS, DIAL_CARDINAL_TICK_INNER, DIAL_CENTRE, DIAL_COUNTERWEIGHT_RADIUS, DIAL_COUNTERWEIGHT_REACH, DIAL_HUB_RADIUS, DIAL_LETTER_RADIUS, DIAL_MIN_MAX_MPS, DIAL_RING_RADIUS, DIAL_SIZE, DIAL_TICK_INNER, ROSE_CARDINAL_LETTERS, ROSE_CENTRE, ROSE_FAVORABLE_RING_RADIUS, ROSE_HUB_DOT_RADIUS, ROSE_HUB_RADIUS, ROSE_INTERCARDINAL_BEARINGS, ROSE_LETTER_RADIUS, ROSE_MAX_RADIUS, ROSE_PETAL_FILL, ROSE_SIZE, ROSE_TICK_REACH, SPARKLINE_EDGE_INSET, SPARKLINE_MAX_PADDING, bandStrips, dialNeedlePoints, dialPolar, dialScaleMaxMps, dialSpeedArcPath, historyRuns, roseBandPath, rosePetalPath, rosePolar, roseRingArcPath, sparklineScale } from "./instruments.js";
|
|
9
12
|
import { foldCurrent, mergeCurrent } from "./merge-current.js";
|
|
10
13
|
import { SAMPLE_GAP_TOLERANCE_FACTOR, sampleMeanDirectionDeg, samplePoints, sampleRuns, sampleScales, samplesSummary, thinSampleVanes } from "./samples.js";
|
|
11
14
|
import { airRows, airSummary, lastStrikeWords } from "./air.js";
|
|
12
15
|
import { normalizeWindnerdStationKey, windnerdStationUrl } from "./windnerd.js";
|
|
13
|
-
export { CALM_THRESHOLD_MPS, CHART_FALLBACK_WIDTH, COMPASS_POINTS, DAILY_PATTERN_DEFAULT_SLOT_MINUTES, DIAL_CARDINALS, DIAL_CARDINAL_TICK_INNER, DIAL_CENTRE, DIAL_COUNTERWEIGHT_RADIUS, DIAL_COUNTERWEIGHT_REACH, DIAL_HUB_RADIUS, DIAL_LETTER_RADIUS, DIAL_MIN_MAX_MPS, DIAL_RING_RADIUS, DIAL_SIZE, DIAL_TICK_INNER, METEOROLOGICAL_SEASON_MONTHS, ROSE_CARDINAL_LETTERS, ROSE_CENTRE, ROSE_FAVORABLE_RING_RADIUS, ROSE_HUB_DOT_RADIUS, ROSE_HUB_RADIUS, ROSE_INTERCARDINAL_BEARINGS, ROSE_LETTER_RADIUS, ROSE_MAX_RADIUS, ROSE_PETAL_FILL, ROSE_SIZE, ROSE_TICK_REACH, SAMPLE_GAP_TOLERANCE_FACTOR, SPARKLINE_EDGE_INSET, SPARKLINE_MAX_PADDING, STATION_SCHEMA_VERSION, UNAVAILABLE_REASONS, airConditionsSchema, airRows, airSummary, averagePoints, bandPoints, bandStrips, capabilitiesSchema, chartFrame, chartScales, compareTracePoints, compareWindow, compassDirection, currentEndpoint, dailyPattern, defaultFormatTime, defaultStrings, dialNeedlePoints, dialPolar, dialScaleMaxMps, dialSpeedArcPath, directionCell, emptyConditions, feedEndpoint, filterByMonth, filterByTimeOfDay, foldCurrent, freshness, historyGaps, meanDirectionDeg as historyMeanDirectionDeg, historyPointSchema, historyRuns, historySchema, isCalm, lastStrikeWords, liveEndpoint, liveSampleSchema, liveSamplesSchema, localeFormatTime, measuredChartWidth, mergeCurrent, mergeStringOverrides, nearestIndex, normalizeDegrees, normalizeWindnerdStationKey, optionalSpeed, parseStationCurrent, parseStationCurrentJson, parseStationFeed, parseStationFeedJson, parseStationLiveFrame, parseStationLiveFrameJson, periodSummary, pressureTendency, readingSchema, requireResolved, resolveDisplay, resolveStation, resolveStrings, rosePetalPath, rosePolar, roseRingArcPath, roundSpeed, sampleMeanDirectionDeg, samplePoints, sampleRuns, sampleScales, samplesSummary, seaLevelPressureHpa, sparklineScale, speedBand, speedFromMps, speedToMps, speedUnitLabel, stationCurrentSchema, stationFeedSchema, stationFreshnessThresholds, stationLiveFrameSchema, stationMetaSchema, stationSchema, summaryEntries, telemetrySchema, temperatureText, temperatureValue, thinSampleVanes, thinVanes, thresholdsToMps, tickAnchor, unavailableStation, updatedAtText, vanePath, vaneTicks, windRose, windnerdStationUrl, windowPoints };
|
|
16
|
+
export { CALM_THRESHOLD_MPS, CHART_FALLBACK_WIDTH, COMPASS_POINTS, CONNECTIVITY_SERVICE_STATES, DAILY_PATTERN_DEFAULT_SLOT_MINUTES, DIAL_CARDINALS, DIAL_CARDINAL_TICK_INNER, DIAL_CENTRE, DIAL_COUNTERWEIGHT_RADIUS, DIAL_COUNTERWEIGHT_REACH, DIAL_HUB_RADIUS, DIAL_LETTER_RADIUS, DIAL_MIN_MAX_MPS, DIAL_RING_RADIUS, DIAL_SIZE, DIAL_TICK_INNER, METEOROLOGICAL_SEASON_MONTHS, ROSE_CARDINAL_LETTERS, ROSE_CENTRE, ROSE_FAVORABLE_RING_RADIUS, ROSE_HUB_DOT_RADIUS, ROSE_HUB_RADIUS, ROSE_INTERCARDINAL_BEARINGS, ROSE_LETTER_RADIUS, ROSE_MAX_RADIUS, ROSE_PETAL_FILL, ROSE_SIZE, ROSE_TICK_REACH, SAMPLE_GAP_TOLERANCE_FACTOR, SPARKLINE_EDGE_INSET, SPARKLINE_MAX_PADDING, STATION_CLIMATOLOGY_SCHEMA_VERSION, STATION_SCHEMA_VERSION, UNAVAILABLE_REASONS, accumulatedCells, airConditionsSchema, airRows, airSummary, averagePoints, bandPoints, bandStrips, capabilitiesSchema, chartFrame, chartScales, climatologyCellSchema, climatologyCoverage, climatologyEndpoint, climatologyFavorableShare, climatologyPattern, climatologyRose, climatologySectorSchema, climatologyYearSchema, compareTracePoints, compareWindow, compassDirection, connectivitySessionSchema, createClimatologyAccumulator, currentEndpoint, dailyPattern, declaredFavorableDirections, defaultFormatTime, defaultStrings, dialNeedlePoints, dialPolar, dialScaleMaxMps, dialSpeedArcPath, directionArcSchema, directionCell, emptyConditions, favorableShare, feedEndpoint, filterByMonth, filterByTimeOfDay, foldClimatologyPoints, foldCurrent, freshness, historyCoverage, historyEndpoint, historyGaps, meanDirectionDeg as historyMeanDirectionDeg, historyPointSchema, historyRuns, historySchema, isCalm, lastNightLowC, lastStrikeWords, liveEndpoint, liveSampleSchema, liveSamplesSchema, localeFormatTime, measuredChartWidth, mergeCurrent, mergeStringOverrides, nearestIndex, normalizeDegrees, normalizeWindnerdStationKey, optionalSpeed, parseStationClimatology, parseStationClimatologyJson, parseStationConnectivity, parseStationCurrent, parseStationCurrentJson, parseStationFeed, parseStationFeedJson, parseStationHistory, parseStationHistoryJson, parseStationLiveFrame, parseStationLiveFrameJson, periodSummary, pressureDeltaHpa, pressureTendency, readingSchema, recentSummarySchema, requireResolved, resolveDisplay, resolveStation, resolveStrings, roseBandPath, rosePetalPath, rosePolar, roseRingArcPath, roundSpeed, sampleMeanDirectionDeg, samplePoints, sampleRuns, sampleScales, samplesSummary, seaLevelPressureHpa, sparklineScale, speedBand, speedFromMps, speedToMps, speedUnitLabel, stationClimatologySchema, stationConnectivitySchema, stationCurrentSchema, stationFeedSchema, stationFreshnessThresholds, stationHistorySchema, stationLiveFrameSchema, stationMetaSchema, stationSchema, summaryEntries, telemetrySchema, temperatureText, temperatureValue, thinSampleVanes, thinVanes, thresholdsToMps, tickAnchor, unavailableStation, updatedAtText, vanePath, vaneTicks, windRose, windnerdStationUrl, windowPoints };
|
package/dist/instruments.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { HistoryPoint } from "./contract.js";
|
|
2
2
|
import { SpeedUnit } from "./derive.js";
|
|
3
|
+
import { DirectionArc } from "@azohra/meteo.core";
|
|
3
4
|
//#region src/instruments.d.ts
|
|
4
5
|
declare const DIAL_SIZE = 160;
|
|
5
6
|
declare const DIAL_CENTRE: number;
|
|
@@ -39,10 +40,11 @@ declare const ROSE_TICK_REACH = 4;
|
|
|
39
40
|
declare const ROSE_PETAL_FILL = 0.82;
|
|
40
41
|
declare function rosePolar(bearingDeg: number, radius: number): readonly [number, number];
|
|
41
42
|
declare function rosePetalPath(bearingDeg: number, radius: number, halfWidthDeg: number): string;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
/** One radial slice of a petal — a stacked wedge's band segment; the petal
|
|
44
|
+
* itself is the slice from the hub out. */
|
|
45
|
+
declare function roseBandPath(bearingDeg: number, innerRadius: number, outerRadius: number, halfWidthDeg: number): string;
|
|
46
|
+
/** The rose ring's arc input; the shape is core's `DirectionArc`. */
|
|
47
|
+
type FavorableDirection = DirectionArc;
|
|
46
48
|
declare function roseRingArcPath(sector: FavorableDirection): string;
|
|
47
49
|
declare const ROSE_CARDINAL_LETTERS: readonly [{
|
|
48
50
|
readonly bearing: 0;
|
|
@@ -72,4 +74,4 @@ type HistoryRun = {
|
|
|
72
74
|
declare function historyRuns(points: ReadonlyArray<HistoryPoint>, periodMinutes: number): HistoryRun[];
|
|
73
75
|
declare function bandStrips(runs: ReadonlyArray<HistoryRun>): HistoryRun[];
|
|
74
76
|
//#endregion
|
|
75
|
-
export { DIAL_CARDINALS, DIAL_CARDINAL_TICK_INNER, DIAL_CENTRE, DIAL_COUNTERWEIGHT_RADIUS, DIAL_COUNTERWEIGHT_REACH, DIAL_HUB_RADIUS, DIAL_LETTER_RADIUS, DIAL_MIN_MAX_MPS, DIAL_RING_RADIUS, DIAL_SIZE, DIAL_TICK_INNER, FavorableDirection, HistoryRun, ROSE_CARDINAL_LETTERS, ROSE_CENTRE, ROSE_FAVORABLE_RING_RADIUS, ROSE_HUB_DOT_RADIUS, ROSE_HUB_RADIUS, ROSE_INTERCARDINAL_BEARINGS, ROSE_LETTER_RADIUS, ROSE_MAX_RADIUS, ROSE_PETAL_FILL, ROSE_SIZE, ROSE_TICK_REACH, SPARKLINE_EDGE_INSET, SPARKLINE_MAX_PADDING, bandStrips, dialNeedlePoints, dialPolar, dialScaleMaxMps, dialSpeedArcPath, historyRuns, rosePetalPath, rosePolar, roseRingArcPath, sparklineScale };
|
|
77
|
+
export { DIAL_CARDINALS, DIAL_CARDINAL_TICK_INNER, DIAL_CENTRE, DIAL_COUNTERWEIGHT_RADIUS, DIAL_COUNTERWEIGHT_REACH, DIAL_HUB_RADIUS, DIAL_LETTER_RADIUS, DIAL_MIN_MAX_MPS, DIAL_RING_RADIUS, DIAL_SIZE, DIAL_TICK_INNER, FavorableDirection, HistoryRun, ROSE_CARDINAL_LETTERS, ROSE_CENTRE, ROSE_FAVORABLE_RING_RADIUS, ROSE_HUB_DOT_RADIUS, ROSE_HUB_RADIUS, ROSE_INTERCARDINAL_BEARINGS, ROSE_LETTER_RADIUS, ROSE_MAX_RADIUS, ROSE_PETAL_FILL, ROSE_SIZE, ROSE_TICK_REACH, SPARKLINE_EDGE_INSET, SPARKLINE_MAX_PADDING, bandStrips, dialNeedlePoints, dialPolar, dialScaleMaxMps, dialSpeedArcPath, historyRuns, roseBandPath, rosePetalPath, rosePolar, roseRingArcPath, sparklineScale };
|
package/dist/instruments.js
CHANGED
|
@@ -26,6 +26,13 @@ function dialNeedlePoints(fromDeg) {
|
|
|
26
26
|
const right = dialPolar(flowDeg - 90, DIAL_NEEDLE_HALF_WIDTH);
|
|
27
27
|
return `${dialAt(tip)} ${dialAt(left)} ${dialAt(right)}`;
|
|
28
28
|
}
|
|
29
|
+
function dialRingArcPath(sector) {
|
|
30
|
+
const from = normalizeDegrees(sector.fromDeg);
|
|
31
|
+
const span = normalizeDegrees(sector.toDeg - sector.fromDeg);
|
|
32
|
+
const start = dialPolar(from, 70);
|
|
33
|
+
const end = dialPolar(from + span, 70);
|
|
34
|
+
return `M ${dialAt(start)} A 70 70 0 ${span > 180 ? 1 : 0} 1 ${dialAt(end)}`;
|
|
35
|
+
}
|
|
29
36
|
function dialSpeedArcPath(fraction) {
|
|
30
37
|
const sweepDeg = Math.min(359.9, Math.max(0, fraction) * 360);
|
|
31
38
|
const start = dialPolar(0, 70);
|
|
@@ -69,16 +76,22 @@ function rosePolar(bearingDeg, radius) {
|
|
|
69
76
|
}
|
|
70
77
|
const roseAt = ([x, y]) => `${x.toFixed(1)} ${y.toFixed(1)}`;
|
|
71
78
|
function rosePetalPath(bearingDeg, radius, halfWidthDeg) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
79
|
+
return roseBandPath(bearingDeg, 16, radius, halfWidthDeg);
|
|
80
|
+
}
|
|
81
|
+
/** One radial slice of a petal — a stacked wedge's band segment; the petal
|
|
82
|
+
* itself is the slice from the hub out. */
|
|
83
|
+
function roseBandPath(bearingDeg, innerRadius, outerRadius, halfWidthDeg) {
|
|
84
|
+
const outerLeft = rosePolar(bearingDeg - halfWidthDeg, outerRadius);
|
|
85
|
+
const outerRight = rosePolar(bearingDeg + halfWidthDeg, outerRadius);
|
|
86
|
+
const innerLeft = rosePolar(bearingDeg - halfWidthDeg, innerRadius);
|
|
87
|
+
const innerRight = rosePolar(bearingDeg + halfWidthDeg, innerRadius);
|
|
88
|
+
const arcRadius = (radius) => Number.isInteger(radius) ? String(radius) : radius.toFixed(1);
|
|
76
89
|
return [
|
|
77
90
|
`M ${roseAt(innerLeft)}`,
|
|
78
91
|
`L ${roseAt(outerLeft)}`,
|
|
79
|
-
`A ${
|
|
92
|
+
`A ${outerRadius.toFixed(1)} ${outerRadius.toFixed(1)} 0 0 1 ${roseAt(outerRight)}`,
|
|
80
93
|
`L ${roseAt(innerRight)}`,
|
|
81
|
-
`A
|
|
94
|
+
`A ${arcRadius(innerRadius)} ${arcRadius(innerRadius)} 0 0 0 ${roseAt(innerLeft)}`,
|
|
82
95
|
"Z"
|
|
83
96
|
].join(" ");
|
|
84
97
|
}
|
|
@@ -170,4 +183,4 @@ function bandStrips(runs) {
|
|
|
170
183
|
return strips;
|
|
171
184
|
}
|
|
172
185
|
//#endregion
|
|
173
|
-
export { DIAL_CARDINALS, DIAL_CARDINAL_TICK_INNER, DIAL_CENTRE, DIAL_COUNTERWEIGHT_RADIUS, DIAL_COUNTERWEIGHT_REACH, DIAL_HUB_RADIUS, DIAL_LETTER_RADIUS, DIAL_MIN_MAX_MPS, DIAL_RING_RADIUS, DIAL_SIZE, DIAL_TICK_INNER, ROSE_CARDINAL_LETTERS, ROSE_CENTRE, ROSE_FAVORABLE_RING_RADIUS, ROSE_HUB_DOT_RADIUS, ROSE_HUB_RADIUS, ROSE_INTERCARDINAL_BEARINGS, ROSE_LETTER_RADIUS, ROSE_MAX_RADIUS, ROSE_PETAL_FILL, ROSE_SIZE, ROSE_TICK_REACH, SPARKLINE_EDGE_INSET, SPARKLINE_MAX_PADDING, bandStrips, dialNeedlePoints, dialPolar, dialScaleMaxMps, dialSpeedArcPath, historyRuns, rosePetalPath, rosePolar, roseRingArcPath, sparklineScale };
|
|
186
|
+
export { DIAL_CARDINALS, DIAL_CARDINAL_TICK_INNER, DIAL_CENTRE, DIAL_COUNTERWEIGHT_RADIUS, DIAL_COUNTERWEIGHT_REACH, DIAL_HUB_RADIUS, DIAL_LETTER_RADIUS, DIAL_MIN_MAX_MPS, DIAL_RING_RADIUS, DIAL_SIZE, DIAL_TICK_INNER, ROSE_CARDINAL_LETTERS, ROSE_CENTRE, ROSE_FAVORABLE_RING_RADIUS, ROSE_HUB_DOT_RADIUS, ROSE_HUB_RADIUS, ROSE_INTERCARDINAL_BEARINGS, ROSE_LETTER_RADIUS, ROSE_MAX_RADIUS, ROSE_PETAL_FILL, ROSE_SIZE, ROSE_TICK_REACH, SPARKLINE_EDGE_INSET, SPARKLINE_MAX_PADDING, bandStrips, dialNeedlePoints, dialPolar, dialRingArcPath, dialScaleMaxMps, dialSpeedArcPath, historyRuns, roseBandPath, rosePetalPath, rosePolar, roseRingArcPath, sparklineScale };
|
package/dist/merge-current.js
CHANGED
|
@@ -28,7 +28,8 @@ function mergeCurrent(feed, current) {
|
|
|
28
28
|
return {
|
|
29
29
|
...incoming,
|
|
30
30
|
reading: preserveOmitted(incoming.reading, prior?.reading ?? null),
|
|
31
|
-
history: prior?.history ?? null
|
|
31
|
+
history: prior?.history ?? null,
|
|
32
|
+
recentSummaries: incoming.recentSummaries ?? prior?.recentSummaries ?? null
|
|
32
33
|
};
|
|
33
34
|
})
|
|
34
35
|
},
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Station } from "../../contract.js";
|
|
2
|
+
import { StationStringOverrides } from "../../strings.js";
|
|
3
|
+
import "../../index.js";
|
|
4
|
+
//#region src/react/components/AirExtremes.d.ts
|
|
5
|
+
/** Derived atmo tiles from served history: the last completed night's low
|
|
6
|
+
* (real astronomy — no coordinates, no tile) and the trailing pressure
|
|
7
|
+
* delta. Nothing derivable, nothing rendered. */
|
|
8
|
+
declare function AirExtremes({ station: stationProp, stationId, nowMs, strings: stringsProp }: {
|
|
9
|
+
station?: Station;
|
|
10
|
+
stationId?: string;
|
|
11
|
+
/** Pinned in tests; defaults to the wall clock. */
|
|
12
|
+
nowMs?: number;
|
|
13
|
+
strings?: StationStringOverrides;
|
|
14
|
+
}): import("react").JSX.Element | null;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { AirExtremes };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { resolveDisplay } from "../../display.js";
|
|
3
|
+
import { airExtremesGate, airExtremesScene } from "../../scene/air-extremes.js";
|
|
4
|
+
import { resolveStation, useStationFeedContext } from "./StationFeedProvider.js";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
//#region src/react/components/AirExtremes.tsx
|
|
7
|
+
/** Derived atmo tiles from served history: the last completed night's low
|
|
8
|
+
* (real astronomy — no coordinates, no tile) and the trailing pressure
|
|
9
|
+
* delta. Nothing derivable, nothing rendered. */
|
|
10
|
+
function AirExtremes({ station: stationProp, stationId, nowMs, strings: stringsProp }) {
|
|
11
|
+
const context = useStationFeedContext();
|
|
12
|
+
const station = stationProp ?? resolveStation(context, stationId) ?? void 0;
|
|
13
|
+
const { words } = resolveDisplay(context, { strings: stringsProp });
|
|
14
|
+
const gate = airExtremesGate(station);
|
|
15
|
+
if (gate.kind === "hidden") return null;
|
|
16
|
+
const scene = airExtremesScene({
|
|
17
|
+
nowMs: nowMs ?? Date.now(),
|
|
18
|
+
station: gate.station,
|
|
19
|
+
words
|
|
20
|
+
});
|
|
21
|
+
if (scene == null) return null;
|
|
22
|
+
return /* @__PURE__ */ jsx("dl", {
|
|
23
|
+
"aria-label": scene.ariaLabel,
|
|
24
|
+
className: scene.className,
|
|
25
|
+
children: scene.tiles.map((tile) => /* @__PURE__ */ jsxs("div", {
|
|
26
|
+
className: tile.className,
|
|
27
|
+
children: [/* @__PURE__ */ jsx("dt", {
|
|
28
|
+
className: "meteo-microlabel",
|
|
29
|
+
children: tile.label
|
|
30
|
+
}), /* @__PURE__ */ jsx("dd", {
|
|
31
|
+
className: "meteo-air-extremes-value",
|
|
32
|
+
children: tile.value
|
|
33
|
+
})]
|
|
34
|
+
}, tile.key))
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
38
|
+
export { AirExtremes };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { StationClimatology } from "../../contract-climatology.js";
|
|
2
|
+
import { SpeedThresholds } from "../../derive.js";
|
|
3
|
+
import { StationStringOverrides } from "../../strings.js";
|
|
4
|
+
import { FavorableDirection } from "../../instruments.js";
|
|
5
|
+
import "../../index.js";
|
|
6
|
+
//#region src/react/components/ClimatologyDailyPattern.d.ts
|
|
7
|
+
/** The cube's typical day through the daily-pattern drawing, month-filtered
|
|
8
|
+
* client-side. The host owns the document and the filters. */
|
|
9
|
+
declare function ClimatologyDailyPattern({ document, months, favorableDirections: favorableDirectionsProp, thresholds: thresholdsProp, unit: unitProp, plotHeight, stationName, strings: stringsProp }: {
|
|
10
|
+
document: StationClimatology | null | undefined;
|
|
11
|
+
months?: ReadonlyArray<number>;
|
|
12
|
+
favorableDirections?: FavorableDirection[] | null;
|
|
13
|
+
thresholds?: SpeedThresholds | null;
|
|
14
|
+
unit?: "kmh" | "knots" | "mph" | "mps";
|
|
15
|
+
plotHeight?: number;
|
|
16
|
+
stationName?: string;
|
|
17
|
+
strings?: StationStringOverrides;
|
|
18
|
+
}): import("react").JSX.Element;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { ClimatologyDailyPattern };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { resolveDisplay } from "../../display.js";
|
|
3
|
+
import { measuredChartWidth } from "../../geometry.js";
|
|
4
|
+
import { CLIMATOLOGY_PATTERN_CLASS, climatologyPatternGate, climatologyPatternScene } from "../../scene/climatology-pattern.js";
|
|
5
|
+
import { useStationFeedContext } from "./StationFeedProvider.js";
|
|
6
|
+
import { DailyPatternSceneView } from "./DailyPattern.js";
|
|
7
|
+
import { useEffect, useId, useRef, useState } from "react";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
//#region src/react/components/ClimatologyDailyPattern.tsx
|
|
10
|
+
/** The cube's typical day through the daily-pattern drawing, month-filtered
|
|
11
|
+
* client-side. The host owns the document and the filters. */
|
|
12
|
+
function ClimatologyDailyPattern({ document, months, favorableDirections: favorableDirectionsProp, thresholds: thresholdsProp, unit: unitProp, plotHeight, stationName, strings: stringsProp }) {
|
|
13
|
+
const { favorableDirections, thresholds, unit, words } = resolveDisplay(useStationFeedContext(), {
|
|
14
|
+
strings: stringsProp,
|
|
15
|
+
thresholds: thresholdsProp,
|
|
16
|
+
favorableDirections: favorableDirectionsProp,
|
|
17
|
+
unit: unitProp
|
|
18
|
+
});
|
|
19
|
+
const wrapRef = useRef(null);
|
|
20
|
+
const [width, setWidth] = useState(null);
|
|
21
|
+
const hatchId = `meteo-climatology-hatch-${useId().replace(/[^a-zA-Z0-9_-]/g, "")}`;
|
|
22
|
+
const gate = climatologyPatternGate(document, words);
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
const element = wrapRef.current;
|
|
25
|
+
if (!element) return;
|
|
26
|
+
if (typeof ResizeObserver === "undefined") {
|
|
27
|
+
setWidth(360);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const observer = new ResizeObserver((entries) => {
|
|
31
|
+
setWidth(measuredChartWidth(entries[0]?.contentRect.width ?? 0));
|
|
32
|
+
});
|
|
33
|
+
observer.observe(element);
|
|
34
|
+
return () => observer.disconnect();
|
|
35
|
+
}, [gate.kind === "draw"]);
|
|
36
|
+
if (gate.kind === "note") return /* @__PURE__ */ jsx("div", {
|
|
37
|
+
className: gate.className,
|
|
38
|
+
role: "note",
|
|
39
|
+
children: gate.text
|
|
40
|
+
});
|
|
41
|
+
return /* @__PURE__ */ jsx("div", {
|
|
42
|
+
className: CLIMATOLOGY_PATTERN_CLASS,
|
|
43
|
+
ref: wrapRef,
|
|
44
|
+
children: width != null && /* @__PURE__ */ jsx(DailyPatternSceneView, { scene: climatologyPatternScene({
|
|
45
|
+
document: gate.document,
|
|
46
|
+
favorableDirections,
|
|
47
|
+
filters: { months },
|
|
48
|
+
hatchId,
|
|
49
|
+
plotHeight,
|
|
50
|
+
stationName,
|
|
51
|
+
thresholds,
|
|
52
|
+
unit,
|
|
53
|
+
width,
|
|
54
|
+
words
|
|
55
|
+
}) })
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
//#endregion
|
|
59
|
+
export { ClimatologyDailyPattern };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { StationClimatology } from "../../contract-climatology.js";
|
|
2
|
+
import { StationStringOverrides } from "../../strings.js";
|
|
3
|
+
import { FavorableDirection } from "../../instruments.js";
|
|
4
|
+
import "../../index.js";
|
|
5
|
+
//#region src/react/components/ClimatologyRose.d.ts
|
|
6
|
+
/** The whole archive as a stacked rose: the cube's sectors, each wedge split
|
|
7
|
+
* by the document's own thresholds, with the honesty captions beneath. The
|
|
8
|
+
* host owns the document (a fetch-once store) and the filters. */
|
|
9
|
+
declare function ClimatologyRose({ document, months, slots, favorableDirections: favorableDirectionsProp, stationName, strings: stringsProp }: {
|
|
10
|
+
document: StationClimatology | null | undefined;
|
|
11
|
+
months?: ReadonlyArray<number>;
|
|
12
|
+
slots?: ReadonlyArray<number>;
|
|
13
|
+
favorableDirections?: FavorableDirection[] | null;
|
|
14
|
+
stationName?: string;
|
|
15
|
+
strings?: StationStringOverrides;
|
|
16
|
+
}): import("react").JSX.Element;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { ClimatologyRose };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { resolveDisplay } from "../../display.js";
|
|
3
|
+
import { climatologyRoseGate, climatologyRoseScene } from "../../scene/climatology-rose.js";
|
|
4
|
+
import { useStationFeedContext } from "./StationFeedProvider.js";
|
|
5
|
+
import { WindRoseSceneView } from "./WindRose.js";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
//#region src/react/components/ClimatologyRose.tsx
|
|
8
|
+
/** The whole archive as a stacked rose: the cube's sectors, each wedge split
|
|
9
|
+
* by the document's own thresholds, with the honesty captions beneath. The
|
|
10
|
+
* host owns the document (a fetch-once store) and the filters. */
|
|
11
|
+
function ClimatologyRose({ document, months, slots, favorableDirections: favorableDirectionsProp, stationName, strings: stringsProp }) {
|
|
12
|
+
const { favorableDirections, words } = resolveDisplay(useStationFeedContext(), {
|
|
13
|
+
strings: stringsProp,
|
|
14
|
+
favorableDirections: favorableDirectionsProp
|
|
15
|
+
});
|
|
16
|
+
const gate = climatologyRoseGate(document, words);
|
|
17
|
+
if (gate.kind === "note") return /* @__PURE__ */ jsx("div", {
|
|
18
|
+
className: gate.className,
|
|
19
|
+
role: "note",
|
|
20
|
+
children: gate.text
|
|
21
|
+
});
|
|
22
|
+
const filters = {
|
|
23
|
+
months,
|
|
24
|
+
slots
|
|
25
|
+
};
|
|
26
|
+
const scene = climatologyRoseScene({
|
|
27
|
+
document: gate.document,
|
|
28
|
+
favorableDirections,
|
|
29
|
+
filters,
|
|
30
|
+
stationName,
|
|
31
|
+
words
|
|
32
|
+
});
|
|
33
|
+
return /* @__PURE__ */ jsx("div", {
|
|
34
|
+
className: scene.className,
|
|
35
|
+
children: /* @__PURE__ */ jsx(WindRoseSceneView, {
|
|
36
|
+
scene: scene.rose,
|
|
37
|
+
children: scene.captions.map((caption) => /* @__PURE__ */ jsx("p", {
|
|
38
|
+
className: caption.className,
|
|
39
|
+
children: caption.text
|
|
40
|
+
}, caption.key))
|
|
41
|
+
})
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
export { ClimatologyRose };
|