fix: 修正8km下雨预警报警撤销
This commit is contained in:
parent
0449971bcb
commit
5d8202311f
@ -90,7 +90,13 @@
|
|||||||
async function loadLatestTile(z, y, x) {
|
async function loadLatestTile(z, y, x) {
|
||||||
const status = document.getElementById('tile_status');
|
const status = document.getElementById('tile_status');
|
||||||
const res = await fetch(`/api/radar/latest?z=${z}&y=${y}&x=${x}`);
|
const res = await fetch(`/api/radar/latest?z=${z}&y=${y}&x=${x}`);
|
||||||
if (!res.ok) { status.textContent = '未找到瓦片'; return; }
|
if (!res.ok) {
|
||||||
|
status.textContent = '未找到瓦片';
|
||||||
|
// 当没有瓦片可用时,清空附近降雨提示,避免遗留旧提示
|
||||||
|
const nb = document.getElementById('nearbyStatus');
|
||||||
|
if (nb) { nb.textContent=''; nb.classList.remove('text-red-700'); nb.classList.add('text-gray-700'); }
|
||||||
|
return;
|
||||||
|
}
|
||||||
const t = await res.json();
|
const t = await res.json();
|
||||||
const fmt = (n, d=5)=> Number(n).toFixed(d);
|
const fmt = (n, d=5)=> Number(n).toFixed(d);
|
||||||
document.getElementById('tile_dt').textContent = t.dt;
|
document.getElementById('tile_dt').textContent = t.dt;
|
||||||
@ -127,7 +133,13 @@
|
|||||||
async function loadTileAt(z, y, x, dtStr) {
|
async function loadTileAt(z, y, x, dtStr) {
|
||||||
const status = document.getElementById('tile_status');
|
const status = document.getElementById('tile_status');
|
||||||
const res = await fetch(`/api/radar/at?z=${z}&y=${y}&x=${x}&dt=${encodeURIComponent(dtStr)}`);
|
const res = await fetch(`/api/radar/at?z=${z}&y=${y}&x=${x}&dt=${encodeURIComponent(dtStr)}`);
|
||||||
if (!res.ok) { status.textContent = '未找到瓦片'; return; }
|
if (!res.ok) {
|
||||||
|
status.textContent = '未找到瓦片';
|
||||||
|
// 清空附近降雨提示,避免遗留
|
||||||
|
const nb = document.getElementById('nearbyStatus');
|
||||||
|
if (nb) { nb.textContent=''; nb.classList.remove('text-red-700'); nb.classList.add('text-gray-700'); }
|
||||||
|
return;
|
||||||
|
}
|
||||||
const t = await res.json();
|
const t = await res.json();
|
||||||
const fmt = (n, d=5)=> Number(n).toFixed(d);
|
const fmt = (n, d=5)=> Number(n).toFixed(d);
|
||||||
document.getElementById('tile_dt').textContent = t.dt;
|
document.getElementById('tile_dt').textContent = t.dt;
|
||||||
@ -393,7 +405,13 @@
|
|||||||
function maybeCalcNearbyRain(){
|
function maybeCalcNearbyRain(){
|
||||||
try{
|
try{
|
||||||
const el = document.getElementById('nearbyStatus'); if(!el) return;
|
const el = document.getElementById('nearbyStatus'); if(!el) return;
|
||||||
if(!gTileValues || !gXs || !gYs || gStLat===null || gStLon===null){ el.textContent=''; return; }
|
if(!gTileValues || !gXs || !gYs || gStLat===null || gStLon===null){
|
||||||
|
// 数据不足时清空提示并恢复默认样式
|
||||||
|
el.textContent='';
|
||||||
|
el.classList.remove('text-red-700');
|
||||||
|
el.classList.add('text-gray-700');
|
||||||
|
return;
|
||||||
|
}
|
||||||
const radiusM = 8000; // 8km
|
const radiusM = 8000; // 8km
|
||||||
const h=gTileValues.length, w=gTileValues[0].length;
|
const h=gTileValues.length, w=gTileValues[0].length;
|
||||||
let hit=false, maxDBZ=null;
|
let hit=false, maxDBZ=null;
|
||||||
@ -405,7 +423,16 @@
|
|||||||
if(dist <= radiusM){ hit=true; maxDBZ = maxDBZ==null?dbz:Math.max(maxDBZ, dbz); break; }
|
if(dist <= radiusM){ hit=true; maxDBZ = maxDBZ==null?dbz:Math.max(maxDBZ, dbz); break; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(hit){ el.textContent = `附近8公里内检测到大于等于 40dBz 的雷达反射率,短时间内可能会下雨`; el.classList.remove('text-gray-700'); el.classList.add('text-red-700'); }
|
if(hit){
|
||||||
|
el.textContent = `附近8公里内检测到大于等于 40dBz 的雷达反射率,短时间内可能会下雨`;
|
||||||
|
el.classList.remove('text-gray-700');
|
||||||
|
el.classList.add('text-red-700');
|
||||||
|
} else {
|
||||||
|
// 未命中时清空并恢复默认样式,避免提示“停留不消失”
|
||||||
|
el.textContent = '';
|
||||||
|
el.classList.remove('text-red-700');
|
||||||
|
el.classList.add('text-gray-700');
|
||||||
|
}
|
||||||
}catch(e){ /* ignore */ }
|
}catch(e){ /* ignore */ }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user