| | |
| | | // 预计算颜色阶段时间点 |
| | | function precomputeColorStages() { |
| | | if (!rainTotalInfo.value || rainTotalInfo.value.length === 0) return; |
| | | |
| | | // 颜色配置(亮度递减) |
| | | const COLOR_STOPS = [ |
| | | { hex: "#F5F0E6", luminance: 240.4 }, // stage 0 |
| | |
| | | -0.7, // stage 5 |
| | | -0.8 // stage 6 |
| | | ]; |
| | | |
| | | // 累计降雨量阈值(mm) |
| | | const R_THRESHOLDS = [0, 200, 240, 280, 310, 350]; // 共6个阶段对应6个阈值 |
| | | |
| | | // 时间和降雨量信息 |
| | | const timeTotals = []; |
| | | const initialTimestamp = new Date(rainTotalInfo.value[0].time).getTime(); |
| | |
| | | |
| | | // 找出每个阶段首次达到的时间点 |
| | | const stages = []; |
| | | |
| | | for (let stage = 1; stage < R_THRESHOLDS.length + 1; stage++) { |
| | | const threshold = R_THRESHOLDS[stage - 1]; |
| | | for (let i = 0; i < timeTotals.length; i++) { |
| | |
| | | |
| | | // 打印信息 |
| | | // console.log("========================================"); |
| | | console.log(`【时间戳】: ${new Date(currentTimeMs).toLocaleString()}`); |
| | | console.log(`【累计降雨量 R】: ${currentTotal !== null ? currentTotal.toFixed(2) : '未知'} mm`); |
| | | console.log(`【当前阶段】: 第 ${currentStage} 阶段`); |
| | | // console.log(`【时间戳】: ${new Date(currentTimeMs).toLocaleString()}`); |
| | | // console.log(`【累计降雨量 R】: ${currentTotal !== null ? currentTotal.toFixed(2) : '未知'} mm`); |
| | | // console.log(`【当前阶段】: 第 ${currentStage} 阶段`); |
| | | // console.log(`【颜色 HEX】: ${colorState.colorStages[currentStage]?.color || '未定义'}`); |
| | | // console.log(`【透明度 Alpha】: ${colorState.colorStages[currentStage]?.alpha || '未定义'}`); |
| | | // console.log("========================================"); |
| | |
| | | rainDensity: rainLevel.density, |
| | | rainColor: rainLevel.color, |
| | | }; |
| | | console.log("当前雨量数据:", rainValue, "当前雨形:", rainLevel); |
| | | // console.log("当前雨量数据:", rainValue, "当前雨形:", rainLevel); |
| | | // 调用工具方法更新雨效 |
| | | mapUtils.toggleRain(rainParams, true); |
| | | } |