| | |
| | | "#ffe930", "#fdd10a", "#feb652", "#fd7f06", |
| | | "#fe2b07", "#4d0a08" |
| | | ]; |
| | | // 构造 waterHeightLevels:从 min 到 max 使用指数增长,确保小值区域更密集 |
| | | const levelCount = colorStops.length; // 保持和颜色数量一致 |
| | | |
| | | const levelCount = colorStops.length; |
| | | const minAllowed = 0.01; // 最小允许值 |
| | | const threshold = 1; // 小值与大值分界点 |
| | | |
| | | let effectiveMin = Math.max(minFlowRate, minAllowed); // 最小不能小于 0.01 |
| | | |
| | | const waterHeightLevels = []; |
| | | // 指数增长公式:y = base^x |
| | | const base = Math.exp(Math.log(maxFlowRate / minFlowRate) / (levelCount - 1)); |
| | | |
| | | // 分两段构造高度数组 |
| | | for (let i = 0; i < levelCount; i++) { |
| | | const ratio = i / (levelCount - 1); // 0 ~ 1 |
| | | // 使用指数插值,保证低值区域更密集 |
| | | const height = minFlowRate * Math.pow(base, i); |
| | | const color = colorStops[i]; |
| | | let ratio = i / (levelCount - 1); // 0 ~ 1 |
| | | |
| | | let height; |
| | | if (ratio <= 0.5) { |
| | | // 前半段:低值区域,使用强指数增长,从 effectiveMin 到 threshold |
| | | const localRatio = ratio * 2; // 映射到 0~1 |
| | | const expRatio = Math.pow(localRatio, 2); // 更强调低值区域密度 |
| | | height = effectiveMin + (threshold - effectiveMin) * expRatio; |
| | | } else { |
| | | // 后半段:高值区域,从 threshold 到 maxFlowRate,使用指数增长 |
| | | const localRatio = (ratio - 0.5) * 2; // 映射到 0~1 |
| | | const expBase = Math.exp(Math.log(maxFlowRate / threshold) / 1); |
| | | height = threshold * Math.pow(expBase, localRatio); |
| | | } |
| | | |
| | | waterHeightLevels.push({ |
| | | height: height.toFixed(2), // 可选:保留两位小数 |
| | | color |
| | | height: parseFloat(height.toFixed(2)), // 保留两位小数 |
| | | color: colorStops[i] |
| | | }); |
| | | } |
| | | waterLegendData.value = waterHeightLevels |
| | | console.log(waterLegendData.value,'图里数据'); |
| | | |
| | | |
| | | waterLegendData.value = waterHeightLevels; |
| | | console.log(waterLegendData.value, '图例数据'); |
| | | |
| | | // 创建图层 |
| | | water = earthCtrl.simulate.createWaterSimulateLayer({ |
| | | baseUrl, |
| | | interval, |
| | | color: new SmartEarth.Cesium.Color.fromCssColorString("#D4F2E7"), |
| | | color: SmartEarth.Cesium.Color.fromCssColorString("#D4F2E7"), |
| | | loop: false, |
| | | callback: timeCallback, |
| | | alphaByDepth: -0.3, |
| | |
| | | }); |
| | | |
| | | console.log( |
| | | `仿真模拟参数:请求路径 ${baseUrl}, 帧间间隔 ${interval}ms, 是否开启专题渲染 ${colorRender},图例参数${waterHeightLevels}` |
| | | `仿真模拟参数:请求路径 ${baseUrl}, 帧间间隔 ${interval}ms, 是否开启专题渲染 ${colorRender}` |
| | | ); |
| | | } |
| | | /** |