From bbdf7b9bfb33552c83bc4ddee2c36893fd43781b Mon Sep 17 00:00:00 2001
From: jihongshun <1151753686@qq.com>
Date: 星期四, 09 十月 2025 16:32:58 +0800
Subject: [PATCH] 动作算法优化 && 两个点增加速度值

---
 src/views/system/flightRouteSimulation/index.vue |   61 +++++++++++++++++++++++-------
 1 files changed, 47 insertions(+), 14 deletions(-)

diff --git a/src/views/system/flightRouteSimulation/index.vue b/src/views/system/flightRouteSimulation/index.vue
index 08d2e64..6e3c4d6 100644
--- a/src/views/system/flightRouteSimulation/index.vue
+++ b/src/views/system/flightRouteSimulation/index.vue
@@ -128,6 +128,7 @@
       maxZoom: 56,//鏈�澶у彉鍊�
       baseBoxSize: 576,//榛樿box瀹藉害 
       i:0,//鍔ㄤ綔鐩戝惉i
+      autoFlightSpeed:10
     }
   },
   watch:{
@@ -165,7 +166,8 @@
         //鍔犵偣閫昏緫 姣斿鍚戠2-n-1涓彃鍏ュ厓绱�  缁忕含搴︿负褰撳墠鐨�  heading pitch roll 涓嬩竴涓殑
         const dealArr = [];
         console.log(">> this.waypoints:", this.waypoints);
-        for (let i = 0; i < this.waypoints.length - 1; i++) {
+        // for (let i = 0; i < this.waypoints.length - 1; i++) {
+        for (let i = 0; i < this.waypoints.length ; i++) {
             dealArr.push(this.waypoints[i]); // Push the current element
             const current = this.waypoints[i];
             const next = this.waypoints[i + 1];
@@ -183,6 +185,7 @@
             //     // 'nowAction':ele.value
             // });
             //鍔ㄤ綔
+            
             if(current.nowAction){
               dealArr.push({
                   'name':'鍔ㄤ綔鐨勫欢缁�',
@@ -194,22 +197,50 @@
                   "pitch": current.pitch,
                   "roll": current.roll,
                   "zoom":current.zoom || 1,
+                  'speed':current.speed,
+                  
+              });
+            }
+            //鏈�鍚庝竴涓鏋滃甫鍔ㄤ綔澶勭悊
+            if(next){
+              if(current.lng !=next.lng ||  current.lat !=next.lat||  current.alt !=next.alt) {
+                // 鍋囪浣犳湁涓や釜鐐圭殑缁忕含搴�
+                var point1 = Cesium.Cartesian3.fromDegrees(current.lng ,  current.lat ,  current.alt);
+                var point2 = Cesium.Cartesian3.fromDegrees(next.lng, next.lat, next.alt);
+                // 璁$畻涓ょ偣涔嬮棿鐨勫湴琛ㄨ窛绂�
+                var distance = Cesium.Cartesian3.distance(point1, point2);;
+              }
+              dealArr.push({
+                  'name':'push鐨勬暟鎹�',
+                  "lng": next.lng,
+                  "lat": next.lat,
+                  "alt": next.alt,
+                  'flyHeading':current.flyHeading,
+                  "heading": current.heading,
+                  "pitch": current.pitch,
+                  "roll": current.roll,
+                  "zoom":current.zoom || 1,
+                  'speed':current.speed,
+                  'wait':Math.floor(distance/this.autoFlightSpeed)
+              });
+            }else {
+              dealArr.push({
+                  'name':'push鐨勬暟鎹�',
+                  "lng": current.lng,
+                  "lat": current.lat,
+                  "alt": current.alt,
+                  'flyHeading':current.flyHeading,
+                  "heading": current.heading,
+                  "pitch": current.pitch,
+                  "roll": current.roll,
+                  "zoom":current.zoom || 1,
+                  'speed':current.speed,
               });
             }
             //鍒拌揪鐐瑰悗鏈濆悜闂
-            dealArr.push({
-                'name':'push鐨勬暟鎹�',
-                "lng": next.lng,
-                "lat": next.lat,
-                "alt": next.alt,
-                'flyHeading':next.flyHeading,
-                "heading": current.heading,
-                "pitch": current.pitch,
-                "roll": current.roll,
-                "zoom":current.zoom || 1,
-            });
+            
         }
-        dealArr.push(this.waypoints[this.waypoints.length - 1]);
+        // dealArr.push(this.waypoints[this.waypoints.length - 1]);
         this.waypoints = dealArr
         console.log(dealArr)
         this.fileInfo = `
@@ -491,6 +522,9 @@
 
       const placemarks =
         result.kml.Document[0].Folder[0].Placemark || [];
+      const flySpeed =
+        result.kml.Document[0].Folder[0]['wpml:autoFlightSpeed'][0] || 10
+      this.autoFlightSpeed = Number(flySpeed)
       const points = [];
       const dealPoints = [];
       let lastHeading = 0
@@ -878,7 +912,6 @@
       while(i>=0){
          trajectory = this.trajectoryData[i];
         if(new Date(currentTimeISO).getTime() < Math.abs(new Date(trajectory.time).getTime())){
-        console.log(i)
         i--;
         }else{
           break;

--
Gitblit v1.9.3