From 51af02271fe8a6d3e2db7bef90df1ea5f571a173 Mon Sep 17 00:00:00 2001
From: wangjuncheng <1>
Date: 星期一, 21 四月 2025 13:06:07 +0800
Subject: [PATCH] change

---
 src/utils/tools.js |  218 +++++++++++++++++++++++++++++++-----------------------
 1 files changed, 125 insertions(+), 93 deletions(-)

diff --git a/src/utils/tools.js b/src/utils/tools.js
index 733633f..57e120f 100644
--- a/src/utils/tools.js
+++ b/src/utils/tools.js
@@ -96,7 +96,7 @@
     this.regionTerrain = earthCtrl.factory.createRegionTerrain({});
     this.polygonPosition = [];
 
-    const draw = earthCtrl.shapeTool.createDrawShapeTool(e => {
+    const draw = earthCtrl.shapeTool.createDrawShapeTool((e) => {
       const polygonI = [];
       for (const i of e.result) {
         const ellipsoid = earthCtrl.coreMap.scene.globe.ellipsoid;
@@ -170,7 +170,7 @@
   CreateLabel(pic, show) {
     if (show) {
       earthCtrl.factory.createSimpleGraphic(pic, {}, function (entity) {
-        console.log(entity, "entity");
+        console.log(entity.polyline.positions.getValue(), "entity");
         window.Viewer = earthCtrl.viewer;
         //寮�鍚紪杈戝苟鍚敤灞炴�у脊绐�
         earthCtrl.factory.SimpleGraphic.edit(true, {
@@ -187,7 +187,7 @@
 
   //  姘村钩娴嬮噺
   spjl() {
-    earthCtrl.measure.horizontalDistance(colorAll, e => {
+    earthCtrl.measure.horizontalDistance(colorAll, (e) => {
       console.log(e);
     }).onEnd = () => {
       console.log("姘村钩娴嬭窛宸插畬鎴�");
@@ -195,7 +195,7 @@
   },
   //鐩寸嚎娴嬮噺
   jl() {
-    earthCtrl.measure.lineDistance(colorAll, e => {
+    earthCtrl.measure.lineDistance(colorAll, (e) => {
       console.log(e);
     }).onEnd = () => {
       console.log("鐩寸嚎娴嬮噺宸插畬鎴�");
@@ -203,7 +203,7 @@
   },
   // 鍨傜洿娴嬮噺
   czgd() {
-    earthCtrl.measure.height(colorAll, e => {
+    earthCtrl.measure.height(colorAll, (e) => {
       console.log(e);
     }).onEnd = () => {
       console.log("鍨傜洿娴嬭窛宸插畬鎴�");
@@ -217,7 +217,7 @@
         tin: true, // 鏄惁鏄剧ずtin涓夎缃�
         onlyTerrain: false, // 鏄惁鍙祴閲忕簿缁嗗湴褰�
       },
-      e => {
+      (e) => {
         console.log(e);
       }
     ).onEnd = () => {
@@ -245,7 +245,7 @@
     if (!this.viewShedTool) {
       this.syfx(option);
     }
-    this.viewShedTool.mouseCreate().then(res => {
+    this.viewShedTool.mouseCreate().then((res) => {
       callback(res);
     });
   },
@@ -300,7 +300,7 @@
         polyline: Cesium.Color.fromCssColorString("#ffff0050"),
         polygon: Cesium.Color.fromCssColorString("#ffff0050"),
       },
-      e => {}
+      (e) => {}
     );
   },
   qxcl() {
@@ -310,7 +310,7 @@
         polyline: Cesium.Color.fromCssColorString("#ffff0050"),
         polygon: Cesium.Color.fromCssColorString("#ffff0050"),
       },
-      e => {}
+      (e) => {}
     );
   },
   fwjcl() {
@@ -320,7 +320,7 @@
         polyline: Cesium.Color.fromCssColorString("#ffff0050"),
         polygon: Cesium.Color.fromCssColorString("#ffff0050"),
       },
-      e => {}
+      (e) => {}
     );
   },
   // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>鍦烘櫙鎴浘<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
@@ -375,12 +375,14 @@
     this.earthCtrl.factory.createSimpleGraphic(
       "polygon",
       { showSize: false, removeEdit: true },
-      entity => {
-        let postitions = entity.polygon.hierarchy.getValue().positions.reduce((obj, cur) => {
-          let lonlat = this.cartesainToDegrees(cur);
-          obj.push([lonlat.lng, lonlat.lat]);
-          return obj;
-        }, []);
+      (entity) => {
+        let postitions = entity.polygon.hierarchy
+          .getValue()
+          .positions.reduce((obj, cur) => {
+            let lonlat = this.cartesainToDegrees(cur);
+            obj.push([lonlat.lng, lonlat.lat]);
+            return obj;
+          }, []);
         //澶氬彉褰㈤棴鐜�
         postitions.push(postitions[0]);
         let gridRadius = 0.05;
@@ -422,7 +424,7 @@
         }
         hexres.features.forEach((item, index) => {
           if (turf.booleanContains(polygon, item)) {
-            let newArr = item.geometry.coordinates[0].map(el => {
+            let newArr = item.geometry.coordinates[0].map((el) => {
               return Cesium.Cartesian3.fromDegrees(el[0], el[1]);
             });
             //缃戞牸闈�
@@ -498,87 +500,112 @@
       this.RestrictTheHeight.removeFromMap();
       this.RestrictTheHeight = null;
     }
-    earthCtrl.factory.createSimpleGraphic("polygon", { showSize: false }, entity => {
-      let arr = [];
-      entity.polygon.hierarchy.getValue().positions.forEach(position => {
-        let cartographic = SmartEarth.Cesium.Cartographic.fromCartesian(position);
-        let lat = SmartEarth.Cesium.Math.toDegrees(cartographic.latitude);
-        let lng = SmartEarth.Cesium.Math.toDegrees(cartographic.longitude);
-        arr.push(lng, lat);
-      });
-      this.earthCtrl.viewer.entities.remove(entity);
-      if (viewer.terrainProvider) {
-        Cesium.sampleTerrainMostDetailed(viewer.terrainProvider, [
-          Cesium.Cartographic.fromDegrees(arr[0], arr[1]),
-        ]).then(updatedPositions => {
+    earthCtrl.factory.createSimpleGraphic(
+      "polygon",
+      { showSize: false },
+      (entity) => {
+        let arr = [];
+        entity.polygon.hierarchy.getValue().positions.forEach((position) => {
+          let cartographic =
+            SmartEarth.Cesium.Cartographic.fromCartesian(position);
+          let lat = SmartEarth.Cesium.Math.toDegrees(cartographic.latitude);
+          let lng = SmartEarth.Cesium.Math.toDegrees(cartographic.longitude);
+          arr.push(lng, lat);
+        });
+        this.earthCtrl.viewer.entities.remove(entity);
+        if (viewer.terrainProvider) {
+          Cesium.sampleTerrainMostDetailed(viewer.terrainProvider, [
+            Cesium.Cartographic.fromDegrees(arr[0], arr[1]),
+          ]).then((updatedPositions) => {
+            this.RestrictTheHeight = earthCtrl.analysis.createRestrictTheHeight(
+              {
+                positions: arr,
+                baseHeight: baseHeigh + updatedPositions[0].height,
+                // color: SmartEarth.Cesium.Color.GREEN.withAlpha(0.5),
+                color:
+                  SmartEarth.Cesium.Color.fromCssColorString(
+                    "#ff1515"
+                  ).withAlpha(0.5),
+              }
+            );
+          });
+        } else {
           this.RestrictTheHeight = earthCtrl.analysis.createRestrictTheHeight({
             positions: arr,
-            baseHeight: baseHeigh + updatedPositions[0].height,
-            // color: SmartEarth.Cesium.Color.GREEN.withAlpha(0.5),
-            color: SmartEarth.Cesium.Color.fromCssColorString("#ff1515").withAlpha(0.5),
+            baseHeight: baseHeigh,
+            color:
+              SmartEarth.Cesium.Color.fromCssColorString("#ff1515").withAlpha(
+                0.5
+              ),
           });
-        });
-      } else {
-        this.RestrictTheHeight = earthCtrl.analysis.createRestrictTheHeight({
-          positions: arr,
-          baseHeight: baseHeigh,
-          color: SmartEarth.Cesium.Color.fromCssColorString("#ff1515").withAlpha(0.5),
-        });
+        }
       }
-    });
+    );
   },
   hcqfxPoint(width) {
-    const pointGraphic = earthCtrl.factory.createSimpleGraphic("point", {}, entity => {
-      const position = entity.position.getValue();
-      const { lng, lat } = this.transformCartesianToCoord(position);
-      const pointBuffer = earthCtrl.analysis.createBufferAnalysis({
-        position: [lng, lat],
-        color: SmartEarth.Cesium.Color.YELLOW.withAlpha(0.5),
-        radius: width / 1000,
-      });
-      pointBuffer.initBuffer();
-      this.Buffers.push(pointBuffer);
-    });
+    const pointGraphic = earthCtrl.factory.createSimpleGraphic(
+      "point",
+      {},
+      (entity) => {
+        const position = entity.position.getValue();
+        const { lng, lat } = this.transformCartesianToCoord(position);
+        const pointBuffer = earthCtrl.analysis.createBufferAnalysis({
+          position: [lng, lat],
+          color: SmartEarth.Cesium.Color.YELLOW.withAlpha(0.5),
+          radius: width / 1000,
+        });
+        pointBuffer.initBuffer();
+        this.Buffers.push(pointBuffer);
+      }
+    );
   },
   hcqfxLine(width) {
-    this.earthCtrl.factory.createSimpleGraphic("polyline", { showSize: false }, entity => {
-      const positions = entity.polyline.positions.getValue();
-      let coordinates = [];
-      for (let i = 0; i < positions.length; i++) {
-        const { lng, lat } = this.transformCartesianToCoord(positions[i]);
-        coordinates.push(lng, lat);
+    this.earthCtrl.factory.createSimpleGraphic(
+      "polyline",
+      { showSize: false },
+      (entity) => {
+        const positions = entity.polyline.positions.getValue();
+        let coordinates = [];
+        for (let i = 0; i < positions.length; i++) {
+          const { lng, lat } = this.transformCartesianToCoord(positions[i]);
+          coordinates.push(lng, lat);
+        }
+        const polulineBuffer = earthCtrl.analysis.createBufferAnalysis({
+          position: coordinates,
+          color: SmartEarth.Cesium.Color.YELLOW.withAlpha(0.5),
+          radius: width / 1000,
+        });
+        polulineBuffer.initPolylineBuffer();
+        this.Buffers.push(polulineBuffer);
       }
-      const polulineBuffer = earthCtrl.analysis.createBufferAnalysis({
-        position: coordinates,
-        color: SmartEarth.Cesium.Color.YELLOW.withAlpha(0.5),
-        radius: width / 1000,
-      });
-      polulineBuffer.initPolylineBuffer();
-      this.Buffers.push(polulineBuffer);
-    });
+    );
   },
   hcqfxPolygon(width) {
-    this.earthCtrl.factory.createSimpleGraphic("polygon", { showSize: false }, entity => {
-      let positions = entity.polygon.hierarchy.getValue().positions;
-      let coordinates = [];
-      for (let i = 0; i < positions.length; i++) {
-        const { lng, lat } = this.transformCartesianToCoord(positions[i]);
+    this.earthCtrl.factory.createSimpleGraphic(
+      "polygon",
+      { showSize: false },
+      (entity) => {
+        let positions = entity.polygon.hierarchy.getValue().positions;
+        let coordinates = [];
+        for (let i = 0; i < positions.length; i++) {
+          const { lng, lat } = this.transformCartesianToCoord(positions[i]);
+          coordinates.push(lng, lat);
+        }
+        const { lng, lat } = this.transformCartesianToCoord(positions[0]);
         coordinates.push(lng, lat);
+        const polygonBuffer = earthCtrl.analysis.createBufferAnalysis({
+          position: coordinates,
+          color: SmartEarth.Cesium.Color.YELLOW.withAlpha(0.5),
+          radius: width / 1000,
+        });
+        polygonBuffer.initPolylineBuffer();
+        this.Buffers.push(polygonBuffer);
       }
-      const { lng, lat } = this.transformCartesianToCoord(positions[0]);
-      coordinates.push(lng, lat);
-      const polygonBuffer = earthCtrl.analysis.createBufferAnalysis({
-        position: coordinates,
-        color: SmartEarth.Cesium.Color.YELLOW.withAlpha(0.5),
-        radius: width / 1000,
-      });
-      polygonBuffer.initPolylineBuffer();
-      this.Buffers.push(polygonBuffer);
-    });
+    );
   },
   // 鍔ㄦ�佽鍩熷垎鏋�
   dtsyfxPoint(callback) {
-    earthCtrl.factory.createSimpleGraphic("point", {}, entity => {
+    earthCtrl.factory.createSimpleGraphic("point", {}, (entity) => {
       let position = entity.position.getValue();
       let coord = this.transformCartesianToCoord(position);
       this.earthCtrl.viewer.entities.remove(entity);
@@ -681,9 +708,9 @@
   polygonArray: [],
   selectedEntity: null, //閫変腑鐨勫疄浣�
   addPointToMap(row) {
-    const filteArr = this.pointsArray.filter(item => item.type == row.type);
+    const filteArr = this.pointsArray.filter((item) => item.type == row.type);
     if (filteArr.length > 0) {
-      filteArr.forEach(item => {
+      filteArr.forEach((item) => {
         item.entity.show = true;
       });
       return;
@@ -724,9 +751,9 @@
     });
   },
   hidePointByType(row) {
-    const filteArr = this.pointsArray.filter(item => item.type == row.type);
+    const filteArr = this.pointsArray.filter((item) => item.type == row.type);
     if (filteArr.length > 0) {
-      filteArr.forEach(item => {
+      filteArr.forEach((item) => {
         item.entity.show = false;
       });
     }
@@ -744,14 +771,14 @@
     callback(poiInfo);
   },
   setSelectedEntity(entity) {
-    this.pointsArray.forEach(item => {
+    this.pointsArray.forEach((item) => {
       if (item.id === entity.id) {
         item.entity.billboard.image = cameraIconSel;
       }
     });
   },
   clearSelectedEntityStyle(entity) {
-    this.pointsArray.forEach(item => {
+    this.pointsArray.forEach((item) => {
       if (item.id === entity.id) {
         item.entity.billboard.image = cameraIcon;
       }
@@ -765,7 +792,7 @@
     }
   },
   createPolygonArea(item) {
-    const findItem = this.polygonArray.find(row => row.id === item.id);
+    const findItem = this.polygonArray.find((row) => row.id === item.id);
     if (findItem) {
       earthCtrl.viewer.flyTo(findItem.polygon);
       return;
@@ -780,7 +807,9 @@
         heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
       },
     });
-    var polyPositions = curPolygon.polygon.hierarchy.getValue(Cesium.JulianDate.now()).positions;
+    var polyPositions = curPolygon.polygon.hierarchy.getValue(
+      Cesium.JulianDate.now()
+    ).positions;
     var polyCenter = Cesium.BoundingSphere.fromPoints(polyPositions).center; //涓績鐐�
     polyCenter = Cesium.Ellipsoid.WGS84.scaleToGeodeticSurface(polyCenter);
     curPolygon.position = polyCenter;
@@ -812,7 +841,7 @@
     this.polygonArray.push(obj);
   },
   clearPoygon() {
-    this.polygonArray.forEach(item => {
+    this.polygonArray.forEach((item) => {
       earthCtrl.viewer.entities.remove(item.polygon);
       earthCtrl.viewer.entities.remove(item.polyline);
     });
@@ -855,7 +884,7 @@
     if (graphic) {
       graphic.clear();
     }
-    this.Buffers.map(item => {
+    this.Buffers.map((item) => {
       item.removeFromMap();
     });
     this.Buffers = [];
@@ -899,7 +928,10 @@
       GroupID: 0,
       url: SmartEarthRootUrl + "Workers/image/waterNormals.jpg",
     };
-    this.analysisFlood = earthCtrl.analysis.createSubmergence(method, value => {});
+    this.analysisFlood = earthCtrl.analysis.createSubmergence(
+      method,
+      (value) => {}
+    );
   },
   clearFlood() {
     this.analysisFlood && this.analysisFlood.endWater();

--
Gitblit v1.9.3