From b963a6899bb6c8eee695bc7c5ba1a865c7028cb3 Mon Sep 17 00:00:00 2001
From: jihongshun <1151753686@qq.com>
Date: 星期三, 10 九月 2025 13:08:17 +0800
Subject: [PATCH] fix++

---
 src/views/system/flightRouteSimulation/index.vue |  111 ++++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 88 insertions(+), 23 deletions(-)

diff --git a/src/views/system/flightRouteSimulation/index.vue b/src/views/system/flightRouteSimulation/index.vue
index 5118cb6..c321ec2 100644
--- a/src/views/system/flightRouteSimulation/index.vue
+++ b/src/views/system/flightRouteSimulation/index.vue
@@ -35,6 +35,11 @@
       //     roll:0,
       //     speed: 10           // 閫熷害(鍏噷/灏忔椂)
       //   },
+
+
+
+
+      
       //   {
       //     time: '2025-04-01T13:01:00Z', // ISO 8601鏍煎紡鏃堕棿
       //     position: {
@@ -116,6 +121,30 @@
       try {
         const arrayBuffer = await this.readFileAsArrayBuffer(file);
         this.waypoints = await this.parseKMZ(arrayBuffer);
+        const dealArr = [];
+        console.log(">> this.waypoints:", this.waypoints);
+        for (let i = 0; i < this.waypoints.length - 1; i++) {
+            dealArr.push(this.waypoints[i]); // Push the current element
+            const current = this.waypoints[i];
+            const next = this.waypoints[i + 1];
+            
+            // Create a new element with the current lng, lat and next heading, pitch, roll
+            dealArr.push({
+                "lng": current.lng,
+                "lat": current.lat,
+                "alt": current.alt,
+                'flyHeading':next.flyHeading,
+                "heading": next.heading,
+                "pitch": next.pitch,
+                "roll": next.roll
+            });
+        }
+
+        // Push the last element without any change
+        dealArr.push(this.waypoints[this.waypoints.length - 1]);
+
+        console.log(dealArr)
+        // this.waypoints = dealArr
         console.log(">> this.waypoints:", this.waypoints);
 
         this.fileInfo = `
@@ -127,7 +156,8 @@
         const startDate = new Date("2025-04-01T13:00:00Z");
         const speeds = [10, 10, 20, 30, 80, 100, 60, 50, 40, 30, 20, 10]; // 鑷畾涔夐�熷害
 
-        const result = this.waypoints.map((item, index) => {
+        // const result = this.waypoints.map((item, index) => {
+        const result = dealArr.map((item, index) => {
           // 姣忔鍔犱竴澶�
           const time = new Date(startDate.getTime() + index * 60 * 1000).toISOString();
           return {
@@ -140,7 +170,8 @@
             heading:item.heading|| 0,
             pitch:item.pitch|| 0,
             roll:item.roll || 0,
-            speed: speeds[index] || 0
+            speed: speeds[index] || 0,
+            flyHeading:item.flyHeading
           };
         });
         this.trajectoryData = result
@@ -189,35 +220,64 @@
         // 鎻愬彇 action 閲岀殑鍙傛暟
         let heading = null;
         let gimbalPitch = null, gimbalRoll = null, gimbalYaw = null;
-
+        // 鍒濆鍖� Pitch, Roll 鍜� Heading
+        let totalPitch = 0;
+        let totalRoll = 0;
+        let totalHeading = 0;
+        let flyHeadingData = 0;
         if (placemark["wpml:actionGroup"]?.[0]?.["wpml:action"]) {
           placemark["wpml:actionGroup"][0]["wpml:action"].forEach(action => {
-            let params = action["wpml:actionActuatorFuncParam"]?.[0];
+            // 澶勭悊 gimbalRotate 鍜� rotateYaw 鍑芥暟
+            if (action['wpml:actionActuatorFunc'].includes("gimbalRotate")) {
+                // 鑾峰彇姣忎釜瑙掑害鍊�
+                const gimbalPitch = parseFloat(action['wpml:actionActuatorFuncParam'][0]["wpml:gimbalPitchRotateAngle"][0]);
+                const gimbalRoll = parseFloat(action['wpml:actionActuatorFuncParam'][0]["wpml:gimbalRollRotateAngle"][0]);
+                const gimbalYaw = parseFloat(action['wpml:actionActuatorFuncParam'][0]["wpml:gimbalYawRotateAngle"][0]);
 
-            if (!params) return;
-
-            // 椋炴満鑸悜瑙�
-            if (action["wpml:actionActuatorFunc"]?.[0] === "rotateYaw" &&
-                params["wpml:aircraftHeading"]) {
-              heading = Number(params["wpml:aircraftHeading"][0]);
+                // 绱姞 Pitch, Roll 鍜� Heading
+                totalPitch += gimbalPitch;
+                totalRoll += gimbalRoll;
+                totalHeading += gimbalYaw;
             }
-
-            // 浜戝彴瑙掑害
-            if (action["wpml:actionActuatorFunc"]?.[0] === "gimbalRotate") {
-              if (params["wpml:gimbalPitchRotateAngle"])
-                gimbalPitch = Number(params["wpml:gimbalPitchRotateAngle"][0]);
-              if (params["wpml:gimbalRollRotateAngle"])
-                gimbalRoll = Number(params["wpml:gimbalRollRotateAngle"][0]);
-              if (params["wpml:gimbalYawRotateAngle"])
-                gimbalYaw = Number(params["wpml:gimbalYawRotateAngle"][0]);
+            // 澶勭悊 rotateYaw 鍑芥暟
+            if (action['wpml:actionActuatorFunc'].includes("rotateYaw")) {
+                // 鑾峰彇 aircraftHeading
+                const aircraftHeading = parseFloat(action['wpml:actionActuatorFuncParam'][0]["wpml:aircraftHeading"][0]);
+                flyHeadingData = aircraftHeading
+                // 灏� aircraftHeading 绱姞鍒� totalHeading
+                totalHeading += aircraftHeading;
             }
+            // action['wpml:actionActuatorFuncParam'][0].['wpml:gimbalPitchRotateAngle']
+            // let params = action["wpml:actionActuatorFuncParam"]?.[0];
+
+            // if (!params) return;
+
+            // // 椋炴満鑸悜瑙�
+            // if (action["wpml:actionActuatorFunc"]?.[0] === "rotateYaw" &&
+            //     params["wpml:aircraftHeading"]) {
+            //   heading = Number(params["wpml:aircraftHeading"][0]);
+            // }
+
+            // // 浜戝彴瑙掑害
+            // if (action["wpml:actionActuatorFunc"]?.[0] === "gimbalRotate") {
+            //   if (params["wpml:gimbalPitchRotateAngle"])
+            //     gimbalPitch = Number(params["wpml:gimbalPitchRotateAngle"][0]);
+            //   if (params["wpml:gimbalRollRotateAngle"])
+            //     gimbalRoll = Number(params["wpml:gimbalRollRotateAngle"][0]);
+            //   if (params["wpml:gimbalYawRotateAngle"])
+            //     gimbalYaw = Number(params["wpml:gimbalYawRotateAngle"][0]);
+            // }
           });
         }
+        // 杈撳嚭缁撴灉
+      console.log("Total Pitch:", totalPitch);
+      console.log("Total Roll:", totalRoll);
+      console.log("Total Heading:", totalHeading);
         if (coords) {
           coords.trim().split(" ").forEach(coord => {
             const [lng, lat] = coord.split(",").map(Number);
             //,heading:gimbalYaw || 0,pitch:gimbalPitch|| 0,roll:gimbalRoll|| 0
-            points.push({ lng, lat, alt: height,heading:gimbalYaw || 0,pitch:gimbalPitch|| 0,roll:gimbalRoll|| 0 });
+            points.push({ lng, lat, alt: height,heading:totalHeading  || 0,pitch:totalPitch || 0,roll:totalRoll|| 0 ,flyHeading:flyHeadingData});
           });
         }
       });
@@ -372,10 +432,15 @@
         this.positionProperty.addSample(time, position)
         speedProperty.addSample(time, data.speed)
             // 璁$畻鏈濆悜鍥涘厓鏁�
+        // const hpr = new Cesium.HeadingPitchRoll(
+        //     Cesium.Math.toRadians(data.heading),
+        //     Cesium.Math.toRadians(data.pitch),
+        //     Cesium.Math.toRadians(data.roll)
+        // );
         const hpr = new Cesium.HeadingPitchRoll(
-            Cesium.Math.toRadians(data.heading),
-            Cesium.Math.toRadians(data.pitch),
-            Cesium.Math.toRadians(data.roll)
+            Cesium.Math.toRadians(data.flyHeading),
+            Cesium.Math.toRadians(0),
+            Cesium.Math.toRadians(0)
         );
         const quaternion = Cesium.Transforms.headingPitchRollQuaternion(position, hpr);
         

--
Gitblit v1.9.3