perf: slim fires/cameras/events/news map payloads
Heatmap uses {lat,lon,i,c}. Camera list drops URLs (detail via GET
/api/cameras/{id}). Event blips skip body. News omits content unless
include_content=true.
This commit is contained in:
parent
9c14b899ee
commit
8f89994201
3 changed files with 131 additions and 24 deletions
|
|
@ -1921,10 +1921,12 @@ function setBaseOpacity(v) {
|
|||
|
||||
/* ── FIRMS fire heatmap ── */
|
||||
function firesIntensity(f) {
|
||||
const confidence = f.confidence || f.c;
|
||||
const brightness = f.brightness != null ? f.brightness : f.i;
|
||||
if (firesColor === 'confidence') {
|
||||
return f.confidence === 'h' ? 1.0 : f.confidence === 'l' ? 0.35 : 0.6;
|
||||
return confidence === 'h' ? 1.0 : confidence === 'l' ? 0.35 : 0.6;
|
||||
}
|
||||
const b = f.brightness || 300;
|
||||
const b = brightness || 300;
|
||||
return Math.max(0.05, Math.min(1, (b - 290) / 110));
|
||||
}
|
||||
function firesGradient() {
|
||||
|
|
@ -1972,14 +1974,14 @@ async function loadFires() {
|
|||
if (!map) return;
|
||||
const req = ++fireReq;
|
||||
try {
|
||||
let url = `${API}/api/fires?bbox=${currentBBox()}&limit=2000`;
|
||||
let url = `${API}/api/fires?bbox=${currentBBox()}&limit=2000&format=heat`;
|
||||
const since = sinceToISO(firesSince);
|
||||
if (since) url += `&since=${encodeURIComponent(since)}`;
|
||||
const r = await fetch(url);
|
||||
const fires = await r.json();
|
||||
if (req !== fireReq) return; // superseded by a newer pan/zoom
|
||||
if (firesHeat) map.removeLayer(firesHeat);
|
||||
const pts = fires.map(f => [f.latitude, f.longitude, firesIntensity(f)]);
|
||||
const pts = fires.map(f => [f.lat ?? f.latitude, f.lon ?? f.longitude, firesIntensity(f)]);
|
||||
firesHeat = L.heatLayer(pts, {
|
||||
radius: 22, blur: 20, maxZoom: 9, max: 1.0, minOpacity: 0.2,
|
||||
gradient: firesGradient(),
|
||||
|
|
@ -2066,7 +2068,7 @@ async function loadCams() {
|
|||
}
|
||||
const req = ++camReq;
|
||||
try {
|
||||
const r = await fetch(`${API}/api/cameras?bbox=${currentBBox()}&limit=5000`);
|
||||
const r = await fetch(`${API}/api/cameras?bbox=${currentBBox()}&limit=2000`);
|
||||
const cams = await r.json();
|
||||
if (req !== camReq) return; // superseded by a newer pan/zoom
|
||||
if (camsGroup) map.removeLayer(camsGroup);
|
||||
|
|
|
|||
Loading…
Reference in a new issue