feat: 新增区域统计
This commit is contained in:
parent
5d8202311f
commit
13b4117d75
@ -128,6 +128,7 @@
|
|||||||
maybeCalcSector();
|
maybeCalcSector();
|
||||||
maybePlotSquare();
|
maybePlotSquare();
|
||||||
maybeCalcNearbyRain();
|
maybeCalcNearbyRain();
|
||||||
|
maybeCalcTileRegionStats();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadTileAt(z, y, x, dtStr) {
|
async function loadTileAt(z, y, x, dtStr) {
|
||||||
@ -160,6 +161,7 @@
|
|||||||
maybeCalcSector();
|
maybeCalcSector();
|
||||||
maybePlotSquare();
|
maybePlotSquare();
|
||||||
maybeCalcNearbyRain();
|
maybeCalcNearbyRain();
|
||||||
|
maybeCalcTileRegionStats();
|
||||||
}
|
}
|
||||||
|
|
||||||
function fmtDTLocal(dt){
|
function fmtDTLocal(dt){
|
||||||
@ -436,6 +438,75 @@
|
|||||||
}catch(e){ /* ignore */ }
|
}catch(e){ /* ignore */ }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 计算并展示:扇形区域与8km圆形区域的 >=40 和 >=30 dBZ 点数与累计值
|
||||||
|
function maybeCalcTileRegionStats(){
|
||||||
|
try{
|
||||||
|
const s40CntEl = document.getElementById('sector_ge40_cnt');
|
||||||
|
if(!s40CntEl) return; // 元素不存在则不计算
|
||||||
|
// 先清空展示
|
||||||
|
const ids=[
|
||||||
|
'sector_ge40_cnt','sector_ge40_sum','sector_ge30_cnt','sector_ge30_sum',
|
||||||
|
'circle_ge40_cnt','circle_ge40_sum','circle_ge30_cnt','circle_ge30_sum'
|
||||||
|
];
|
||||||
|
ids.forEach(id=>{ const el=document.getElementById(id); if(el) el.textContent='-'; });
|
||||||
|
|
||||||
|
if(!gTileValues || !gXs || !gYs || gStLat===null || gStLon===null) return;
|
||||||
|
const h=gTileValues.length, w=gTileValues[0].length;
|
||||||
|
|
||||||
|
// 扇形区域定义:风向 ±30°,半径 = 3 小时移动距离
|
||||||
|
const hasWind = (gWindFromDeg!==null && gWindSpeedMS!==null && gWindSpeedMS>0);
|
||||||
|
const halfAngle=30;
|
||||||
|
const rangeM = hasWind ? (gWindSpeedMS*3*3600) : 0;
|
||||||
|
|
||||||
|
// 圆形区域:半径 8km
|
||||||
|
const circleR = 8000;
|
||||||
|
|
||||||
|
let sec40Cnt=0, sec40Sum=0, sec30Cnt=0, sec30Sum=0;
|
||||||
|
let cir40Cnt=0, cir40Sum=0, cir30Cnt=0, cir30Sum=0;
|
||||||
|
|
||||||
|
for(let r=0;r<h;r++){
|
||||||
|
const lat=gYs[r];
|
||||||
|
for(let c=0;c<w;c++){
|
||||||
|
const v=gTileValues[r][c];
|
||||||
|
if(v==null) continue;
|
||||||
|
const dbz=Number(v);
|
||||||
|
const lon=gXs[c];
|
||||||
|
const dist=haversine(gStLat,gStLon,lat,lon);
|
||||||
|
|
||||||
|
// 圆形区域统计
|
||||||
|
if(dist<=circleR){
|
||||||
|
if(dbz>=40){ cir40Cnt++; cir40Sum+=dbz; }
|
||||||
|
if(dbz>=30){ cir30Cnt++; cir30Sum+=dbz; }
|
||||||
|
}
|
||||||
|
|
||||||
|
// 扇形区域统计(需要风向风速)
|
||||||
|
if(hasWind){
|
||||||
|
if(dist<=rangeM){
|
||||||
|
const brg=bearingDeg(gStLat,gStLon,lat,lon);
|
||||||
|
if(angDiff(brg,gWindFromDeg)<=halfAngle){
|
||||||
|
if(dbz>=40){ sec40Cnt++; sec40Sum+=dbz; }
|
||||||
|
if(dbz>=30){ sec30Cnt++; sec30Sum+=dbz; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新展示
|
||||||
|
const set = (id, val)=>{ const el=document.getElementById(id); if(el) el.textContent=String(val); };
|
||||||
|
if(hasWind){
|
||||||
|
set('sector_ge40_cnt', sec40Cnt); set('sector_ge40_sum', sec40Sum.toFixed(1));
|
||||||
|
set('sector_ge30_cnt', sec30Cnt); set('sector_ge30_sum', sec30Sum.toFixed(1));
|
||||||
|
} else {
|
||||||
|
// 无风场信息时显示提示
|
||||||
|
set('sector_ge40_cnt', '无风场'); set('sector_ge40_sum', '-');
|
||||||
|
set('sector_ge30_cnt', '无风场'); set('sector_ge30_sum', '-');
|
||||||
|
}
|
||||||
|
set('circle_ge40_cnt', cir40Cnt); set('circle_ge40_sum', cir40Sum.toFixed(1));
|
||||||
|
set('circle_ge30_cnt', cir30Cnt); set('circle_ge30_sum', cir30Sum.toFixed(1));
|
||||||
|
}catch(e){ /* ignore */ }
|
||||||
|
}
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
await loadStations();
|
await loadStations();
|
||||||
// 初始化时间范围为最近24小时
|
// 初始化时间范围为最近24小时
|
||||||
@ -605,6 +676,7 @@
|
|||||||
<option value="">最新</option>
|
<option value="">最新</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="w-full flex justify-center my-2">
|
<div class="w-full flex justify-center my-2">
|
||||||
<input id="timeSlider" type="range" min="0" max="0" value="0" step="1" class="slider slider-horizontal w-64" />
|
<input id="timeSlider" type="range" min="0" max="0" value="0" step="1" class="slider slider-horizontal w-64" />
|
||||||
</div>
|
</div>
|
||||||
@ -615,6 +687,14 @@
|
|||||||
|
|
||||||
<div class="card mt-4" style="width:100%;">
|
<div class="card mt-4" style="width:100%;">
|
||||||
<div class="text-lg font-semibold mb-2">正方形裁减区域</div>
|
<div class="text-lg font-semibold mb-2">正方形裁减区域</div>
|
||||||
|
<div class="mt-3 text-sm space-y-1">
|
||||||
|
<div class="font-bold">扇形区域统计</div>
|
||||||
|
<span class="text-gray-700">≥40 dBZ:点数 <span id="sector_ge40_cnt">-</span>,累计 <span id="sector_ge40_sum">-</span></span>
|
||||||
|
<span class="text-gray-700"> | ≥30 dBZ:点数 <span id="sector_ge30_cnt">-</span>,累计 <span id="sector_ge30_sum">-</span></span>
|
||||||
|
<div class="font-bold mt-2">圆形区域统计</div>
|
||||||
|
<span class="text-gray-700">≥40 dBZ:点数 <span id="circle_ge40_cnt">-</span>,累计 <span id="circle_ge40_sum">-</span></span>
|
||||||
|
<span class="text-gray-700"> | ≥30 dBZ:点数 <span id="circle_ge30_cnt">-</span>,累计 <span id="circle_ge30_sum">-</span></span>
|
||||||
|
</div>
|
||||||
<div id="squarePlot" class="plot-box"></div>
|
<div id="squarePlot" class="plot-box"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user