mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
fix(air-quality): show the Weather card, add voice support and bound the feed
The card never appeared: the Weather panel only passed five fixed ids and only rendered lists and categorical legends for cyclones. Air quality now reaches the panel, the legend style comes from the layer's descriptor, and any layer with list items gets its list. Adds the voice manifest entry main now requires, reads ECCC through the shared capped JSON reader with a 15 s deadline and the row limit enforced, reports stale when every reading was too old, adds source tests, links the ECCC licence and moves the changelog entry into Unreleased.
This commit is contained in:
1 parent
046126eb36
commit
129174c3ab
17 files changed
+440
-148
No files matched your search
@@ -224,24 +224,25 @@ export function createAirQualityLayer({ source, overlayHost } = {}) {
|
||||
status: _lastError
|
||||
? _lastError
|
||||
: _count === 0
|
||||
? 'No readings available'
|
||||
? _lastUpdate === null
|
||||
? 'No readings available'
|
||||
: 'No current readings'
|
||||
: `${_count} stations reporting`,
|
||||
units: provider.scale,
|
||||
},
|
||||
legend: {
|
||||
colors: AIR_QUALITY_BANDS.map((band) => band.color),
|
||||
labels: AIR_QUALITY_BANDS.map((band) => band.label),
|
||||
units: provider.scale,
|
||||
categorical: true,
|
||||
},
|
||||
legend: AIR_QUALITY_BANDS.map((band) => ({
|
||||
color: band.color,
|
||||
label: band.label,
|
||||
})),
|
||||
legendCategorical: true,
|
||||
list: {
|
||||
ariaLabel: 'Highest air-quality readings in view',
|
||||
items: inView.map((reading) => ({
|
||||
items: inView.map((reading, index) => ({
|
||||
id: reading.id,
|
||||
label: reading.name,
|
||||
value: `${reading.scale} ${reading.label}`,
|
||||
ordinal: index + 1,
|
||||
lead: `${reading.scale} ${reading.label}`,
|
||||
text: `${reading.name} · ${reading.risk}`,
|
||||
accent: reading.color,
|
||||
detail: reading.risk,
|
||||
})),
|
||||
},
|
||||
};
|
||||
@@ -251,30 +252,6 @@ export function createAirQualityLayer({ source, overlayHost } = {}) {
|
||||
rowControlsListener = typeof listener === 'function' ? listener : null;
|
||||
},
|
||||
|
||||
/**
|
||||
* The current reading nearest a point — what "the air quality here" means.
|
||||
* @param {number} lat
|
||||
* @param {number} lon
|
||||
* @returns {object|null} Reading with distanceKm, or null when none loaded.
|
||||
*/
|
||||
nearestReading(lat, lon) {
|
||||
if (!Number.isFinite(lat) || !Number.isFinite(lon) || !_readings.length)
|
||||
return null;
|
||||
const cosLat = Math.cos((lat * Math.PI) / 180);
|
||||
let best = null;
|
||||
let bestDistance = Infinity;
|
||||
for (const reading of _readings) {
|
||||
const dLat = (reading.lat - lat) * 111.32;
|
||||
const dLon = (reading.lon - lon) * 111.32 * cosLat;
|
||||
const distance = Math.hypot(dLat, dLon);
|
||||
if (distance < bestDistance) {
|
||||
bestDistance = distance;
|
||||
best = reading;
|
||||
}
|
||||
}
|
||||
return best ? { ...best, distanceKm: bestDistance } : null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Snapshot readings as JSON-safe records for the analyst query engine.
|
||||
* @param {number} [maxCount=500]
|
||||
@@ -300,7 +277,8 @@ export function createAirQualityLayer({ source, overlayHost } = {}) {
|
||||
lastUpdate: _lastUpdate,
|
||||
error: _lastError,
|
||||
observedAt: newestObservation(_readings),
|
||||
stale: readingsAreStale(_readings),
|
||||
// Only a completed refresh can be stale; before one there is no feed.
|
||||
stale: _lastUpdate !== null && readingsAreStale(_readings),
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user