From 4b7b8185bdce4272cd5f256fcc777056f54add6d Mon Sep 17 00:00:00 2001
From: wangjuncheng <1>
Date: 星期一, 16 六月 2025 17:03:09 +0800
Subject: [PATCH] 123

---
 src/utils/water.js |   46 +++++++++++++++++++++++++++++++---------------
 1 files changed, 31 insertions(+), 15 deletions(-)

diff --git a/src/utils/water.js b/src/utils/water.js
index c9c543d..7f5c102 100644
--- a/src/utils/water.js
+++ b/src/utils/water.js
@@ -38,30 +38,46 @@
     "#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 = [];
-  // 鎸囨暟澧為暱鍏紡锛歽 = 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,
@@ -70,7 +86,7 @@
   });
 
   console.log(
-    `浠跨湡妯℃嫙鍙傛暟锛氳姹傝矾寰� ${baseUrl}, 甯ч棿闂撮殧 ${interval}ms, 鏄惁寮�鍚笓棰樻覆鏌� ${colorRender},鍥句緥鍙傛暟${waterHeightLevels}`
+    `浠跨湡妯℃嫙鍙傛暟锛氳姹傝矾寰� ${baseUrl}, 甯ч棿闂撮殧 ${interval}ms, 鏄惁寮�鍚笓棰樻覆鏌� ${colorRender}`
   );
 }
 /**

--
Gitblit v1.9.3