From 2a6abfbd2a9a39f35395f3cfc1794b5fa82ed63a Mon Sep 17 00:00:00 2001
From: jihongshun <1151753686@qq.com>
Date: 星期一, 29 九月 2025 10:50:25 +0800
Subject: [PATCH] 停留时间和动作

---
 src/views/system/flightRouteSimulation/index.vue |  165 ++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 156 insertions(+), 9 deletions(-)

diff --git a/src/views/system/flightRouteSimulation/index.vue b/src/views/system/flightRouteSimulation/index.vue
index 3a62e7e..a731264 100644
--- a/src/views/system/flightRouteSimulation/index.vue
+++ b/src/views/system/flightRouteSimulation/index.vue
@@ -126,6 +126,7 @@
       minZoom: 1,//鏈�灏忓彉鍊�
       maxZoom: 56,//鏈�澶у彉鍊�
       baseBoxSize: 576,//榛樿box瀹藉害 
+      // actionArr : new Cesium.SampledProperty(array),//浜戝彴鏈濆悜pitch
     }
   },
   mounted() {
@@ -161,7 +162,9 @@
                 "pitch": current.pitch,
                 "roll": current.roll,
                 "zoom":current.zoom || 1,
-                'wait' : 3
+                'wait' : 3,
+                // 'wait' : current.waitTime,
+                // 'nowAction':ele.value
             });
             dealArr.push({
                 "lng": next.lng,
@@ -176,9 +179,45 @@
             });
             
         }
-
+        // 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];
+        //     //鎻掑�兼偓鍋�
+        //     this.waypoints[i].nowResult?.forEach((ele)=>{
+        //        dealArr.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,
+        //           // 'wait' : current.waitTime,
+        //           'wait' : 1,
+        //           'nowAction':ele.value
+        //       });
+        //     })
+        //     if(next){
+        //       console.log(next)
+        //       //鎻掑�间笅涓�涓偣缁忕含搴�  褰撳墠pt
+        //       dealArr.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,
+        //           // 'wait':1
+        //           'wait':0
+        //       });
+        //     }
+        // }
         // Push the last element without any change
-        dealArr.push(this.waypoints[this.waypoints.length - 1]);
+        // dealArr.push(this.waypoints[this.waypoints.length - 1]);
         this.waypoints = dealArr
         console.log(dealArr)
         this.fileInfo = `
@@ -204,13 +243,13 @@
         console.log(dealArr)
           let nowTime 
         const result = dealArr.map((item, index) => {
-          console.log(index)
         // const result = this.waypoints.map((item, index) => {
           // 姣忔鍔犱竴澶�
           // const time = new Date(startDate.getTime() + index * 60 *1000 + (item.wait ? item.wait :1 ) * 60 * 1000).toISOString();
           if(index == 0) {
              nowTime = startDate.getTime() + 1  *1000
           }else{
+            // nowTime = nowTime + (item.wait ? item.wait :1 )  *1000
             nowTime = nowTime + (item.wait ? item.wait :1 )  *1000
           }
           const time  = new Date(nowTime).toISOString()
@@ -227,7 +266,9 @@
             roll:item.roll || 0,
             speed: 80,
             zoom:item.zoom,
-            flyHeading:item.flyHeading
+            flyHeading:item.flyHeading,
+            nowResult:item.nowResult || [],
+            nowAction:item.nowAction
           };
         });
         this.trajectoryData = result
@@ -376,6 +417,8 @@
         let totalRoll = 0;
         let totalHeading = 0;
         let flyHeadingData = 0;
+        let waitTime = 0;
+        let nowResult = []
         if (placemarks[i]["wpml:actionGroup"]?.[0]?.["wpml:action"]) {
           placemarks[i]["wpml:actionGroup"][0]["wpml:action"].forEach(action => {
             // 澶勭悊 gimbalRotate 鍜� rotateYaw 鍑芥暟
@@ -411,12 +454,29 @@
               const aircraftZoom = parseFloat(action['wpml:actionActuatorFuncParam'][0]["wpml:focalLength"][0]);
               lastZoom = aircraftZoom
             }
+
+            if (action['wpml:actionActuatorFunc'].includes("hover")) {
+                // 鑾峰彇 aircraftHeading
+                var aircraftHeading = parseFloat(action['wpml:actionActuatorFuncParam'][0]["wpml:hoverTime"][0]);
+                // 灏� aircraftHeading 绱姞鍒� totalHeading
+                waitTime += aircraftHeading;
+            }
+            nowResult.push(
+              {
+                type:action['wpml:actionActuatorFunc'][0],
+                value:this.dealDataValue(action)
+              }
+            )
           });
         }
+        const filteredArray = nowResult.filter(item => item.type !== "rotateYaw" && item.type !== "gimbalRotate");
+
+        console.log(filteredArray)
         if (coords) {
           coords.trim().split(" ").forEach(coord => {
             const [lng, lat] = coord.split(",").map(Number);
-            points.push({ lng, lat, alt: height,heading:totalHeading ?totalHeading:lastHeading ,pitch:totalPitch || 0,roll:totalRoll|| 0 ,flyHeading:flyHeadingData,zoom :lastZoom});
+            // points.push({ lng, lat, alt: height,heading:totalHeading ?totalHeading:lastHeading ,pitch:totalPitch || 0,roll:totalRoll|| 0 ,flyHeading:flyHeadingData,zoom :lastZoom});
+            points.push({ lng, lat, alt: height,heading:totalHeading ?totalHeading:lastHeading ,pitch:totalPitch || 0,roll:totalRoll|| 0 ,flyHeading:flyHeadingData,zoom :lastZoom,waitTime:waitTime,nowResult:filteredArray});
           });
         }
       }
@@ -424,7 +484,27 @@
       if (points.length === 0) throw new Error("鏈壘鍒版湁鏁堣埅鐐�");
       return points;
     },
-
+    dealDataValue(action){
+      switch (action['wpml:actionActuatorFunc'][0]) {
+        case 'zoom':
+          return '鍙樺��'
+          break;
+        case 'takePhoto':
+          return '鎷嶇収'
+          break;
+        case 'startRecord':
+          return '寮�濮嬪綍鍍�'
+          break;
+        case 'hover':
+          return `鎮仠${parseFloat(action['wpml:actionActuatorFuncParam'][0]["wpml:hoverTime"][0])}绉抈
+          break;
+        case 'stopRecord':
+          return '缁撴潫褰曞儚'
+          break;
+        default:
+          console.log('Access Denied!');
+      }
+    },
     // 璁$畻鎬昏窛绂�
     calculateTotalDistance(points) {
       let total = 0;
@@ -682,14 +762,81 @@
         }
       });
     },
+    julianToDate(julianDate, secondsOfDay) {
+      // 1鍎掔暐鏃� = 86400绉掞紝璁$畻鏃堕棿鎴筹紙浠庡叕鍏冨墠4713骞�1鏈�1鏃ヨ捣鐨勭鏁帮級
+      const baseJulianDate = 2440587.5; // UTC 1970-01-01 00:00:00 瀵瑰簲鐨勫剴鐣ユ棩
+      const daysSinceEpoch = julianDate - baseJulianDate;
+
+      // 璁$畻鑷�1970骞�1鏈�1鏃ヤ互鏉ョ殑绉掓暟
+      const epochSeconds = daysSinceEpoch * 86400 + secondsOfDay;
+
+      // 鍒涘缓瀵瑰簲鐨� JavaScript Date 瀵硅薄锛堟绉掔骇鏃堕棿鎴筹級
+      const date = new Date(epochSeconds * 1000); // 灏嗙杞崲涓烘绉�
+      return date;
+    },
+
     getCurrentPosition() {
       let viewer =  window['cesiumContainer'].viewer;
       // 鑾峰彇褰撳墠鏃堕棿
       const currentTime = viewer.clock.currentTime;
+      // console.log(currentTime)
+      // 3. 灏� Julian Date 杞崲涓哄搴旂殑鏃ユ湡瀵硅薄
+      // const julianDateObj = this.julianToDate(currentTime.dayNumber, currentTime.secondsOfDay);
+     
+      // console.log("Julian Date 杞崲鍚庣殑鏃堕棿锛�", julianDateObj.toISOString()); // 杞崲涓� ISO 8601 鏍煎紡
+      const currentTimeISO = Cesium.JulianDate.toIso8601(currentTime,3)
+      this.trajectoryData.forEach((ele)=>{
+        console.log(currentTimeISO)
+        console.log(ele.time)
+        console.log(currentTimeISO.split('.')[0] )
+        console.log(ele.time.split('.')[0])
+        const eventTimeISO = ele.time; 
+        // console.log(new Date(currentTimeISO) -new Date(eventTimeISO))
+        console.log(Math.abs(new Date(eventTimeISO).getTime() - new Date(currentTimeISO).getTime()))
+        // if ((new Date(currentTimeISO) -new Date(eventTimeISO)) < 20) {
+        // if (currentTimeISO.split('.')[0]  == ele.time.split('.')[0])  {
+        //   console.log(ele)
+        //   // this.matchedEvents.push(event);
+        //   // console.log(ele)
+        //   if(ele.nowAction) {
+        //     this.$message({
+        //       message: ele.nowAction,
+        //       type: 'success'
+        //     });
+        //   }
+        // }
+        if(Math.abs(new Date(eventTimeISO).getTime() - new Date(currentTimeISO).getTime()) < 15) {
+          if(ele.nowAction) {
+              this.$message({
+                message: ele.nowAction,
+                type: 'success'
+              });
+            }
+          }
+      })
+
+      // this.trajectoryData.forEach((ele)=>{
+      //   console.log(Cesium.JulianDate.fromIso8601(ele.time))
+
+      //     // console.log( Cesium.JulianDate.fromIso8601(ele.time))
+      //   // if (Math.abs(julianDateObj - new Date(ele.time)) < 20) {  // 鍏佽 1 绉掑唴鐨勮宸�
+      //   //   console.log("Julian Date 鍜� ISO 8601 鏃堕棿鏍煎紡闈炲父鎺ヨ繎");
+      //   //   if(ele.nowAction) {
+      //   //     this.$message({
+      //   //       message: ele.nowAction,
+      //   //       type: 'success'
+      //   //     });
+      //   //   }
+      //   // } else {
+      //   //   console.log("Julian Date 鍜� ISO 8601 鏃堕棿鏍煎紡涓嶅悓");
+      //   // }
+      // })
+      // console.log(currentTime)
+      // console.log(this.trajectoryData)
       const currentPosition = this.positionProperty.getValue(currentTime);
-      
       // 濡傛灉鑾峰彇鍒颁綅缃�
       if (currentPosition) {
+        // console.log(currentPosition)
         // 灏嗕綅缃粠 Cartesian 杞崲涓� Cartographic
         const cartographicPosition = Cesium.Cartographic.fromCartesian(currentPosition);
 
@@ -707,7 +854,7 @@
         const holderYtHeading = this.holderHeadingProperty.getValue(currentTime)
         const holderYtPitch = this.holderPitchProperty.getValue(currentTime)
         const holderYtRoll = this.holderRollProperty.getValue(currentTime)
-        console.log(holderYtHeading)
+        // console.log(holderYtHeading)
         if(holderYtHeading) {
           this.heading = holderYtHeading
           this.pitch = holderYtPitch

--
Gitblit v1.9.3