mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 00:32:21 +00:00
Read satellite fire hits in Context only while the FIRMS layer is on
FIRMS needs a key the browser cannot see. Without one the proxy answers 503, so Context no longer asks for fire hits unless the FIRMS layer is on. Co-authored-by: Manjunath Paparaju <[email protected]>
This commit is contained in:
1 parent
b6b7874b97
commit
90510bf9e6
2 files changed
+16
-5
No files matched your search
@@ -101,15 +101,22 @@ function stormTitle(storm) {
|
||||
/**
|
||||
* Hazards within a radius of a spot, nearest first within each kind:
|
||||
* `[{kind, icon, title, detail, distanceKm, at}]`. Every kind uses the same
|
||||
* radius, the one Context's radius control sets.
|
||||
* radius, the one Context's radius control sets. Satellite fire hits need a
|
||||
* FIRMS key the browser cannot see, so they are read only with `fires`: while
|
||||
* the FIRMS layer is on, which has found the key works.
|
||||
*/
|
||||
export async function hazardsNear(lat, lon, radiusKm = 250) {
|
||||
export async function hazardsNear(
|
||||
lat,
|
||||
lon,
|
||||
radiusKm = 250,
|
||||
{ fires: withFires = false } = {},
|
||||
) {
|
||||
const here = { lat, lon };
|
||||
const [quakeRows, stormSnap, perimeterRows, fireSnap] = await Promise.all([
|
||||
quakes(),
|
||||
storms(),
|
||||
perimeters(),
|
||||
fires(),
|
||||
withFires ? fires() : null,
|
||||
]);
|
||||
const found = [];
|
||||
const add = (row) => {
|
||||
|
||||
@@ -48,6 +48,10 @@ const radiusText = computed(() => t('{n} km', { n: formatNumber(radiusKm.value)
|
||||
const radiusIndex = computed(() => Math.max(0, CONTEXT_RADIUS_STEPS.indexOf(radiusKm.value)));
|
||||
const pickRadius = (index) => setContextRadiusKm(CONTEXT_RADIUS_STEPS[index]);
|
||||
|
||||
// Satellite fire hits come only while the FIRMS layer is on (spotConditions.js).
|
||||
const firesOn = () =>
|
||||
Boolean((omnibar.controls?.layers() || []).find((layer) => layer.id === HAZARD_LAYER.hotspots)?.enabled);
|
||||
|
||||
async function read(lat, lon) {
|
||||
if (readAt && distanceKm(readAt, { lat, lon }) <= props.settleKm) return;
|
||||
readAt = { lat, lon };
|
||||
@@ -56,7 +60,7 @@ async function read(lat, lon) {
|
||||
loading.value = true;
|
||||
const [nextBrief, nextHazards] = await Promise.all([
|
||||
regionalBrief(lat, lon),
|
||||
hazardsNear(lat, lon, radiusKm.value).catch(() => []),
|
||||
hazardsNear(lat, lon, radiusKm.value, { fires: firesOn() }).catch(() => []),
|
||||
]);
|
||||
if (reading !== mine) return;
|
||||
brief.value = nextBrief;
|
||||
@@ -76,7 +80,7 @@ watch(
|
||||
async function rereadHazards(km) {
|
||||
const at = readAt || { lat: props.lat, lon: props.lon };
|
||||
const mine = ++readingHazards;
|
||||
const next = await hazardsNear(at.lat, at.lon, km).catch(() => []);
|
||||
const next = await hazardsNear(at.lat, at.lon, km, { fires: firesOn() }).catch(() => []);
|
||||
if (readingHazards !== mine) return;
|
||||
hazards.value = next;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user