From 0dc7fbac552884839ee89807e0140d6bf6d1f005 Mon Sep 17 00:00:00 2001
From: jihongshun <1151753686@qq.com>
Date: 星期六, 02 八月 2025 13:38:38 +0800
Subject: [PATCH] fix创建多个设备 第n个转的时候

---
 src/views/system/project/components/addPorjectDialog.vue |   84 +++++++++++++++++++++--------------------
 1 files changed, 43 insertions(+), 41 deletions(-)

diff --git a/src/views/system/project/components/addPorjectDialog.vue b/src/views/system/project/components/addPorjectDialog.vue
index b0fafb8..217b3eb 100644
--- a/src/views/system/project/components/addPorjectDialog.vue
+++ b/src/views/system/project/components/addPorjectDialog.vue
@@ -71,7 +71,7 @@
 import chooseDeviceDialog from './chooseDeviceDialog.vue';
 import chooseModelDialog from './chooseModelDialog.vue';
 import { obtainRealData ,buildKmz} from "@/api/system/template"
-
+let rotationAngle = Cesium.Math.toRadians(0)
 export  default{
   components: {
     CesiumMap,
@@ -99,9 +99,9 @@
       this.$emit('close')
     },
     flyToLocal(row){
-      console.log(row)
-       const position = Cesium.Cartesian3.fromDegrees(row.longitude,row.latitude, row.altitude);
-
+       const position = Cesium.Cartesian3.fromDegrees(row.longitude,row.latitude, row.deviceHeight);
+      // rotationAngle  = Cesium.Math.toRadians(row.face)  ||  Cesium.Math.toRadians(0)
+      rotationAngle  = Cesium.Math.toRadians(row.face)  ||  Cesium.Math.toRadians(0)
       // 璁剧疆妯″瀷鏂瑰悜锛堝彲閫夛級
       const heading = Cesium.Math.toRadians(row.face); // 鏈濅笢鍗楁柟鍚�
       const pitch = 0;
@@ -196,7 +196,6 @@
     },
     receiveModel(obj){
       //deal閫昏緫
-      console.log(obj)
       let flightTemplateId =obj.modelObj.id
       let deviceId = obj.deviceId
       this.dealTableTemplate(obj)
@@ -204,10 +203,9 @@
       obtainRealData(flightTemplateId,deviceId).then(res=>{
         console.log(res)
         let treeDealData = this.transformFlightData(res.data?.coordinateSystemVoS || [])
-        console.log(treeDealData)
         this.dealTreeMerge(obj,treeDealData)
-        // const aaa = this.rotateAllPoints(this.treeData || [],res.data.longitude,res.data.latitude,res.data.height)
-         this.drawConnectionsWithLabels(this.treeData)
+        this.rotateAllPoints(this.treeData || [],res.data.longitude,res.data.latitude,res.data.height)
+        this.drawConnectionsWithLabels(this.treeData)
       })
       // this.dealTreeMerge(obj)
     },
@@ -261,10 +259,8 @@
     },
     drawConnectionsWithLabels(devices) {
       const airPoints = [];
-
       devices.forEach(device => {
         if (!Array.isArray(device.children)) return;
-
         device.children.forEach(airPoint => {
           // 绌轰腑鐐逛綅缃�
           const airPos = Cesium.Cartesian3.fromDegrees(
@@ -351,43 +347,43 @@
     },
     rotateAllPoints(dataList,towerLongitude,towerLatitude,towerhHight) {
       return dataList.map(item => {
-        console.log(item)
-        console.log(towerLongitude)
-        console.log(towerLatitude)
-        console.log(towerhHight)
-        const groundPoint = Cesium.Cartesian3.fromDegrees(item.longitude, item.latitude, item.height);
-        const towerPoint = Cesium.Cartesian3.fromDegrees(towerLongitude, towerLatitude, towerhHight);
-        let rotationAngle = Cesium.Math.toRadians(135)
-        // 鏃嬭浆鍦伴潰鐐规湰韬紙浼氬彉锛屼絾缁曡嚜韬棆杞笉浼氱Щ鍔級
-        const newGroundPoint = this.rotateAroundPoint( groundPoint,towerPoint, rotationAngle);
-        const newGroundCarto = Cesium.Cartographic.fromCartesian(newGroundPoint);
-        const newGround = {
-          ...item,
-          longitude: Cesium.Math.toDegrees(newGroundCarto.longitude),
-          latitude: Cesium.Math.toDegrees(newGroundCarto.latitude),
-          height: newGroundCarto.height
-        };
-        console.log(newGround)
-        // 澶勭悊瀛愮┖涓偣
-        newGround.children = item.children.map(child => {
-          const airPoint = Cesium.Cartesian3.fromDegrees(child.longitude, child.latitude, child.height);
-          const rotatedAirPoint = this.rotateAroundPoint( airPoint,towerPoint, rotationAngle);
-          const rotatedAirCarto = Cesium.Cartographic.fromCartesian(rotatedAirPoint);
-
-          return {
-            ...child,
-            longitude: Cesium.Math.toDegrees(rotatedAirCarto.longitude),
-            latitude: Cesium.Math.toDegrees(rotatedAirCarto.latitude),
-            height: rotatedAirCarto.height
+        if(!item.isDeal) {
+          const towerPoint = Cesium.Cartesian3.fromDegrees(towerLongitude, towerLatitude, towerhHight);
+          const newGround = {
+            ...item,
           };
-        });
-
-        return newGround;
+          if(item.id == this.deviceId ){
+            item.isDeal = true
+          } 
+          // 澶勭悊瀛愮┖涓偣
+          newGround.children = item.children?.map(child => {
+            const airPoint = Cesium.Cartesian3.fromDegrees(child.longitude, child.latitude, child.height);
+            const rotatedAirPoint = this.rotateAroundPoint( airPoint,towerPoint, rotationAngle);
+            const rotatedAirCarto = Cesium.Cartographic.fromCartesian(rotatedAirPoint);
+            child.longitude = Cesium.Math.toDegrees(rotatedAirCarto.longitude)
+            child.latitude = Cesium.Math.toDegrees(rotatedAirCarto.latitude)
+            child.height = rotatedAirCarto.height
+            child.children = child.children?.map(sonChild => {
+              const groundPoint = Cesium.Cartesian3.fromDegrees(sonChild.longitude, sonChild.latitude, sonChild.height);
+              const newGroundPoint = this.rotateAroundPoint( groundPoint,towerPoint, rotationAngle);
+              const newGroundCarto = Cesium.Cartographic.fromCartesian(newGroundPoint);
+              return {
+                ...sonChild,
+                longitude: Cesium.Math.toDegrees(newGroundCarto.longitude),
+                latitude: Cesium.Math.toDegrees(newGroundCarto.latitude),
+                height: newGroundCarto.height
+              };
+            });
+          });
+          return newGround;
+        }
+         
       });
     },
     //聽璁$畻鐐笰缁曠偣B閫嗘椂閽堟棆杞寚瀹氳搴﹀悗鐨勬柊浣嶇疆
     //  绌轰腑鐐规垨鑰呭湴闈㈢偣绗涘崱灏斿潗鏍� 濉旂殑绗涘崱灏斿潗鏍�    濉旂殑鏈濆悜鍊�
     rotateAroundPoint(startPoint,pivotPoint,rotationAngle) {
+      console.log(rotationAngle)
       //聽鍒涘缓涓�涓粠B鐐瑰埌鏈湴鍧愭爣绯荤殑杞崲鐭╅樀锛堜笢鏂瑰悜涓篨杞达紝鍖楁柟鍚戜负Y杞达紝鍨傜洿鏂瑰悜涓篫杞达級
      const transformationMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(pivotPoint);
       //聽鑾峰彇涓栫晫鍧愭爣绯诲埌鏈湴鍧愭爣绯荤殑杞崲鐭╅樀
@@ -412,7 +408,13 @@
             routePointIndex: routePointList.length,
             longitude: airPoint.longitude,
             latitude: airPoint.latitude,
+            height: airPoint.height,
             isStartAndEndPoint: false,
+            coordinatePointReq: {
+                height: airPoint.children[0].height,
+                latitude:airPoint.children[0].latitude,
+                longitude: airPoint.children[0].longitude
+              }
           });
         });
       });

--
Gitblit v1.9.3