Show real regional water-temperature ranges, not one station duplicated as both bounds
Classify all 65 LVĢMC stations reporting water temperature (56 inland WTEMD + 9 coastal SEDUT) into the six Ūdens zones by geography, and report the real min/max across each zone's currently-reporting stations instead of one hand-picked station's single value shown twice. Drops readings older than 12h so a stuck sensor can't skew a zone's range.
This commit is contained in:
@@ -11,7 +11,7 @@ type OutputSize = '1920x1080' | '3840x1440';
|
||||
type WaterArea = 'Jūra' | 'Līcis' | 'Kurzeme' | 'Zemgale' | 'Vidzeme' | 'Latgale';
|
||||
type RangeValue = { min: string; max: string };
|
||||
type LabelBox = { x: number; y: number; width: number; height: number };
|
||||
type WaterReading = { area: WaterArea; observedAt: string; value: number | null };
|
||||
type WaterReading = { area: WaterArea; observedAt: string; min: number | null; max: number | null };
|
||||
|
||||
const areaNames: WaterArea[] = ['Jūra', 'Līcis', 'Kurzeme', 'Zemgale', 'Vidzeme', 'Latgale'];
|
||||
const layouts: Record<OutputSize, { fontSize: number; horizontalPadding: number; boxes: Record<WaterArea, LabelBox> }> = {
|
||||
@@ -63,9 +63,8 @@ export function WaterTemperature() {
|
||||
if (!readings) return;
|
||||
const next = emptyRanges();
|
||||
readings.forEach(reading => {
|
||||
if (reading.value == null) return;
|
||||
const rounded = Math.round(reading.value).toString();
|
||||
next[reading.area] = { min: rounded, max: rounded };
|
||||
if (reading.min == null || reading.max == null) return;
|
||||
next[reading.area] = { min: Math.round(reading.min).toString(), max: Math.round(reading.max).toString() };
|
||||
});
|
||||
setRanges(next);
|
||||
setOverrides(new Set<WaterArea>());
|
||||
@@ -84,8 +83,9 @@ export function WaterTemperature() {
|
||||
|
||||
const resetRange = (name: WaterArea) => {
|
||||
const reading = observationsByArea().get(name);
|
||||
const rounded = reading?.value == null ? '' : Math.round(reading.value).toString();
|
||||
setRanges(current => ({ ...current, [name]: { min: rounded, max: rounded } }));
|
||||
const min = reading?.min == null ? '' : Math.round(reading.min).toString();
|
||||
const max = reading?.max == null ? '' : Math.round(reading.max).toString();
|
||||
setRanges(current => ({ ...current, [name]: { min, max } }));
|
||||
setOverrides(current => {
|
||||
const next = new Set(current);
|
||||
next.delete(name);
|
||||
@@ -152,7 +152,7 @@ export function WaterTemperature() {
|
||||
<h2>3. Ievadi temperatūras</h2>
|
||||
<div class="rangeGrid"><For each={areaNames}>{name => {
|
||||
const observation = () => observationsByArea().get(name);
|
||||
return <fieldset class="rangeField" classList={{ manual: overrides().has(name), missing: observation()?.value == null }}>
|
||||
return <fieldset class="rangeField" classList={{ manual: overrides().has(name), missing: observation()?.min == null }}>
|
||||
<legend>{name}</legend>
|
||||
<div class="rangeFieldMeta">
|
||||
<span>{overrides().has(name) ? 'Manuāli' : observation()?.observedAt ? new Date(observation()!.observedAt).toLocaleTimeString('lv-LV', { hour: '2-digit', minute: '2-digit' }) : 'Nav datu'}</span>
|
||||
|
||||
Reference in New Issue
Block a user