| | |
| | | import xml2js from 'xml2js' |
| | | import CesiumMap from "../../../utils/components/cesium-map.vue"; |
| | | import { getScopeTower} from "@/api/system/template" |
| | | import { watch } from 'vue'; |
| | | export default { |
| | | name: "flightRouteSimulation", |
| | | components: { |
| | |
| | | minZoom: 1,//最小变倍 |
| | | maxZoom: 56,//最大变倍 |
| | | baseBoxSize: 576,//默认box宽度 |
| | | // actionArr : new Cesium.SampledProperty(array),//云台朝向pitch |
| | | i:0,//动作监听i |
| | | } |
| | | }, |
| | | watch:{ |
| | | i(val,old){ |
| | | let trajectory =this.trajectoryData[val] |
| | | if(trajectory) { |
| | | if(trajectory.nowAction) { |
| | | this.$notify({ |
| | | title: trajectory.nowAction, |
| | | position: 'bottom-right', |
| | | duration:1500, |
| | | offset:50, |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | mounted() { |
| | | }, |
| | |
| | | dealArr.push(this.waypoints[i]); // Push the current element |
| | | const current = this.waypoints[i]; |
| | | const next = this.waypoints[i + 1]; |
| | | // 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' : 3, |
| | | // // 'wait' : current.waitTime, |
| | | // // 'nowAction':ele.value |
| | | // }); |
| | | //动作 |
| | | if(current.nowAction){ |
| | | dealArr.push({ |
| | | 'name':'动作的延续', |
| | | "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, |
| | | }); |
| | | } |
| | | //到达点后朝向问题 |
| | | 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' : 3, |
| | | // 'wait' : current.waitTime, |
| | | // 'nowAction':ele.value |
| | | }); |
| | | dealArr.push({ |
| | | 'name':'push的数据', |
| | | "lng": next.lng, |
| | | "lat": next.lat, |
| | | "alt": next.alt, |
| | |
| | | "pitch": current.pitch, |
| | | "roll": current.roll, |
| | | "zoom":current.zoom || 1, |
| | | 'wait':1 |
| | | }); |
| | | |
| | | } |
| | | // 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 = ` |
| | |
| | | |
| | | var date = new Date(isoString); |
| | | } |
| | | // const startDate = new Date("2025-04-01T13:00:00Z"); |
| | | const startDate = new Date(date.toISOString()); |
| | | console.log(dealArr) |
| | | let nowTime |
| | | const result = dealArr.map((item, 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() |
| | | // const time = Cesium.JulianDate.addSeconds(startDate, 3600, new Cesium.JulianDate()); |
| | | return { |
| | | time, |
| | | position: { |
| | |
| | | zoom:item.zoom, |
| | | flyHeading:item.flyHeading, |
| | | nowResult:item.nowResult || [], |
| | | nowAction:item.nowAction |
| | | nowAction:item.nowAction, |
| | | name:item.name |
| | | }; |
| | | }); |
| | | this.trajectoryData = result |
| | |
| | | return angle |
| | | }, |
| | | // 解析KMZ文件 |
| | | // async parseKMZ(kmzData) { |
| | | |
| | | // // ⚠️ 这里直接使用全局 JSZip 和 xml2js(通过CDN引入) |
| | | // const zip = await JSZip.loadAsync(kmzData); |
| | | // const kmlFile = Object.keys(zip.files).find(name => |
| | | // name.endsWith(".kml") |
| | | // ); |
| | | // // console.log(">> kmlFile:", kmlFile); |
| | | // if (!kmlFile) throw new Error("未找到KML文件"); |
| | | |
| | | // const kmlContent = await zip.file(kmlFile).async("text"); |
| | | |
| | | // // xml2js 从 CDN 引入后是 window.xml2js |
| | | // const parser = new xml2js.Parser(); |
| | | // const result = await parser.parseStringPromise(kmlContent); |
| | | // // console.log(">> result:", result); |
| | | |
| | | // const placemarks = |
| | | // result.kml.Document[0].Folder[0].Placemark || []; |
| | | // const points = []; |
| | | // var lastZoom =1 |
| | | // let lastHeading = 0 |
| | | // for(let i=0;i<placemarks.length;i++){ |
| | | // const coords = placemarks[i].Point?.[0]?.coordinates?.[0]; |
| | | // const height = placemarks[i]["wpml:height"]?.[0]; |
| | | // if(i<placemarks.length-1){ |
| | | // // console.log(placemarks[i]) |
| | | // // console.log( placemarks[i].Point?.[0]?.coordinates?.[0].split(',')[0]) |
| | | // // console.log( placemarks[i].Point?.[0]?.coordinates?.[0].split(',')[1]) |
| | | // // console.log( placemarks[i+1].Point?.[0]?.coordinates?.[0].split(',')[0]) |
| | | // // console.log( placemarks[i+1].Point?.[0]?.coordinates?.[0].split(',')[1]) |
| | | // let lon1 = placemarks[i].Point?.[0]?.coordinates?.[0].split(',')[0] |
| | | // let lat1 = placemarks[i].Point?.[0]?.coordinates?.[0].split(',')[1] |
| | | // let lon2 = placemarks[i+1].Point?.[0]?.coordinates?.[0].split(',')[0] |
| | | // let lat2 = placemarks[i+1].Point?.[0]?.coordinates?.[0].split(',')[1] |
| | | // // console.log(this.azimuthtwopoi(lon1,lat1,lon2,lat2)) |
| | | // // lastHeading = this.azimuthtwopoi(lon1,lat1,lon2,lat2) |
| | | // var nowHeading = this.azimuthtwopoi(lon1,lat1,lon2,lat2) |
| | | // if(!nowHeading){ |
| | | // nowHeading = lastHeading |
| | | // }else { |
| | | // let p1 = {"lng": lon1, "lat": lat1, "alt": height}; |
| | | |
| | | // let p2 = {"lng": lon2, "lat": lat2, "alt": height}; |
| | | |
| | | // let c1 = Cesium.Cartesian3.fromDegrees(p1.lng,p1.lat,p1.height); |
| | | // let c2 = Cesium.Cartesian3.fromDegrees(p2.lng,p2.lat,p2.height); |
| | | // lastHeading = this.Bearing(c1, c2); |
| | | // // lastHeading = this.azimuthtwopoi(lon1,lat1,lon2,lat2) |
| | | // } |
| | | |
| | | // // console.log(lastHeading) |
| | | // // console.log('+++++++++++++++++++++++++') |
| | | // } |
| | | // // 提取 aircraftHeading |
| | | // // 提取 action 里的参数 |
| | | // // 初始化 Pitch, Roll 和 Heading |
| | | // let totalPitch = 0; |
| | | // 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 函数 |
| | | // 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(gimbalYaw < 0 ){ |
| | | // gimbalYaw += 360 |
| | | // } |
| | | // // 累加 Pitch, Roll 和 Heading |
| | | // totalPitch += gimbalPitch; |
| | | // totalRoll += gimbalRoll; |
| | | // // totalHeading += gimbalYaw; |
| | | |
| | | // } |
| | | // // 处理 rotateYaw 函数 |
| | | // if (action['wpml:actionActuatorFunc'].includes("rotateYaw")) { |
| | | // // 获取 aircraftHeading |
| | | // var aircraftHeading = parseFloat(action['wpml:actionActuatorFuncParam'][0]["wpml:aircraftHeading"][0]); |
| | | |
| | | // if(aircraftHeading <0) { |
| | | // aircraftHeading+=360 |
| | | // } |
| | | // flyHeadingData = aircraftHeading |
| | | // // 将 aircraftHeading 累加到 totalHeading |
| | | // totalHeading += aircraftHeading; |
| | | // } |
| | | |
| | | // // 处理 rotateYaw 函数 |
| | | // if (action['wpml:actionActuatorFunc'].includes("zoom")) { |
| | | // 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,waitTime:waitTime,nowResult:filteredArray}); |
| | | // }); |
| | | // } |
| | | // } |
| | | // console.log(points) |
| | | // if (points.length === 0) throw new Error("未找到有效航点"); |
| | | // return points; |
| | | // }, |
| | | async parseKMZ(kmzData) { |
| | | |
| | | // ⚠️ 这里直接使用全局 JSZip 和 xml2js(通过CDN引入) |
| | |
| | | // xml2js 从 CDN 引入后是 window.xml2js |
| | | const parser = new xml2js.Parser(); |
| | | const result = await parser.parseStringPromise(kmlContent); |
| | | // console.log(">> result:", result); |
| | | console.log(">> result:", result); |
| | | |
| | | const placemarks = |
| | | result.kml.Document[0].Folder[0].Placemark || []; |
| | | const points = []; |
| | | var lastZoom =1 |
| | | const dealPoints = []; |
| | | let lastHeading = 0 |
| | | var changeZoom = 1 |
| | | for(let i=0;i<placemarks.length;i++){ |
| | | const coords = placemarks[i].Point?.[0]?.coordinates?.[0]; |
| | | const height = placemarks[i]["wpml:height"]?.[0]; |
| | | if(i<placemarks.length-1){ |
| | | // console.log(placemarks[i]) |
| | | // console.log( placemarks[i].Point?.[0]?.coordinates?.[0].split(',')[0]) |
| | | // console.log( placemarks[i].Point?.[0]?.coordinates?.[0].split(',')[1]) |
| | | // console.log( placemarks[i+1].Point?.[0]?.coordinates?.[0].split(',')[0]) |
| | | // console.log( placemarks[i+1].Point?.[0]?.coordinates?.[0].split(',')[1]) |
| | | let lon1 = placemarks[i].Point?.[0]?.coordinates?.[0].split(',')[0] |
| | | let lat1 = placemarks[i].Point?.[0]?.coordinates?.[0].split(',')[1] |
| | | let lon2 = placemarks[i+1].Point?.[0]?.coordinates?.[0].split(',')[0] |
| | |
| | | // console.log(this.azimuthtwopoi(lon1,lat1,lon2,lat2)) |
| | | // lastHeading = this.azimuthtwopoi(lon1,lat1,lon2,lat2) |
| | | var nowHeading = this.azimuthtwopoi(lon1,lat1,lon2,lat2) |
| | | console.log(nowHeading) |
| | | if(!nowHeading){ |
| | | nowHeading = lastHeading |
| | | }else { |
| | | let p1 = {"lng": lon1, "lat": lat1, "alt": height}; |
| | | |
| | | let p2 = {"lng": lon2, "lat": lat2, "alt": height}; |
| | | |
| | | let p1 = {"lng": lon1, "lat": lat1, "alt": height}; |
| | | let p2 = {"lng": lon2, "lat": lat2, "alt": height}; |
| | | let c1 = Cesium.Cartesian3.fromDegrees(p1.lng,p1.lat,p1.height); |
| | | let c2 = Cesium.Cartesian3.fromDegrees(p2.lng,p2.lat,p2.height); |
| | | lastHeading = this.Bearing(c1, c2); |
| | | // lastHeading = this.azimuthtwopoi(lon1,lat1,lon2,lat2) |
| | | } |
| | | |
| | | // console.log(lastHeading) |
| | | console.log(lastHeading) |
| | | // console.log('+++++++++++++++++++++++++') |
| | | } |
| | | // 提取 aircraftHeading |
| | | // 提取 action 里的参数 |
| | | // 初始化 Pitch, Roll 和 Heading |
| | | let totalPitch = 0; |
| | | let totalRoll = 0; |
| | | let totalHeading = 0; |
| | | let flyHeadingData = 0; |
| | | let waitTime = 0; |
| | | let nowResult = [] |
| | | let changeHeading = 0; |
| | | let changePitch = 0; |
| | | let changeRoll = 0; |
| | | let changeFlyHeadingData = 0; |
| | | |
| | | if (placemarks[i]["wpml:actionGroup"]?.[0]?.["wpml:action"]) { |
| | | placemarks[i]["wpml:actionGroup"][0]["wpml:action"].forEach(action => { |
| | | // 处理 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(gimbalYaw < 0 ){ |
| | | gimbalYaw += 360 |
| | | } |
| | | // 累加 Pitch, Roll 和 Heading |
| | | totalPitch += gimbalPitch; |
| | | totalRoll += gimbalRoll; |
| | | // totalHeading += gimbalYaw; |
| | | |
| | | } |
| | | // 处理 rotateYaw 函数 |
| | | if (action['wpml:actionActuatorFunc'].includes("rotateYaw")) { |
| | | // 获取 aircraftHeading |
| | | var aircraftHeading = parseFloat(action['wpml:actionActuatorFuncParam'][0]["wpml:aircraftHeading"][0]); |
| | | |
| | | if(aircraftHeading <0) { |
| | | aircraftHeading+=360 |
| | | } |
| | | flyHeadingData = aircraftHeading |
| | | // 将 aircraftHeading 累加到 totalHeading |
| | | totalHeading += aircraftHeading; |
| | | } |
| | | for(let j=0;j<placemarks[i]["wpml:actionGroup"][0]["wpml:action"].length;j++){ |
| | | // console.log(placemarks[i]["wpml:actionGroup"][0]["wpml:action"][j]) |
| | | let groupObj = placemarks[i]["wpml:actionGroup"][0]["wpml:action"][j] |
| | | // console.log(groupObj) |
| | | //无人机 |
| | | if(groupObj['wpml:actionActuatorFunc'].includes("rotateYaw")) { |
| | | changeHeading = parseFloat(groupObj['wpml:actionActuatorFuncParam'][0]["wpml:aircraftHeading"][0]) |
| | | changeFlyHeadingData = parseFloat(groupObj['wpml:actionActuatorFuncParam'][0]["wpml:aircraftHeading"][0]) |
| | | } |
| | | //云台 |
| | | if(groupObj['wpml:actionActuatorFunc'].includes("gimbalRotate")) { |
| | | console.log(groupObj) |
| | | changePitch = parseFloat(groupObj['wpml:actionActuatorFuncParam'][0]["wpml:gimbalPitchRotateAngle"][0]) |
| | | changeRoll = parseFloat(groupObj['wpml:actionActuatorFuncParam'][0]["wpml:gimbalRollRotateAngle"][0]) |
| | | } |
| | | if(groupObj['wpml:actionActuatorFunc'].includes("zoom")) { |
| | | console.log(groupObj) |
| | | changeZoom = parseFloat(groupObj['wpml:actionActuatorFuncParam'][0]["wpml:focalLength"][0]) |
| | | } |
| | | // //拍照 |
| | | if(groupObj['wpml:actionActuatorFunc'].includes("takePhoto")) { |
| | | |
| | | // 处理 rotateYaw 函数 |
| | | if (action['wpml:actionActuatorFunc'].includes("zoom")) { |
| | | 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,waitTime:waitTime,nowResult:filteredArray}); |
| | | }); |
| | | console.log(groupObj) |
| | | } |
| | | dealPoints.push({ |
| | | lng:placemarks[i].Point?.[0]?.coordinates?.[0].split(',')[0], |
| | | lat:placemarks[i].Point?.[0]?.coordinates?.[0].split(',')[1], |
| | | alt: placemarks[i]["wpml:height"]?.[0], |
| | | heading:changeHeading < 0 ? changeHeading + 360 :changeHeading , |
| | | pitch:changePitch, |
| | | roll:changeRoll, |
| | | flyHeading:changeFlyHeadingData, |
| | | zoom:changeZoom, |
| | | nowAction:this.dealDataValue(groupObj), |
| | | }) |
| | | console.log(dealPoints) |
| | | } |
| | | }else { |
| | | dealPoints.push({ |
| | | lng:placemarks[i].Point?.[0]?.coordinates?.[0].split(',')[0], |
| | | lat:placemarks[i].Point?.[0]?.coordinates?.[0].split(',')[1], |
| | | alt: placemarks[i]["wpml:height"]?.[0], |
| | | // heading:changeHeading, |
| | | heading:changeHeading ?changeHeading:lastHeading, |
| | | pitch:changePitch, |
| | | roll:changeRoll, |
| | | flyHeading:changeFlyHeadingData, |
| | | zoom:changeZoom, |
| | | }) |
| | | } |
| | | } |
| | | console.log(points) |
| | | if (points.length === 0) throw new Error("未找到有效航点"); |
| | | return points; |
| | | console.log(dealPoints) |
| | | if (dealPoints.length === 0) throw new Error("未找到有效航点"); |
| | | return dealPoints; |
| | | }, |
| | | dealDataValue(action){ |
| | | switch (action['wpml:actionActuatorFunc'][0]) { |
| | |
| | | return '结束录像' |
| | | break; |
| | | default: |
| | | console.log('Access Denied!'); |
| | | } |
| | | }, |
| | | // 计算总距离 |
| | |
| | | // 创建位置和速度属性 |
| | | const speedProperty = new Cesium.SampledProperty(Number) |
| | | // 添加采样点 |
| | | console.log(this.trajectoryData) |
| | | this.trajectoryData.forEach(data => { |
| | | const time = Cesium.JulianDate.fromIso8601(data.time) |
| | | const position = Cesium.Cartesian3.fromDegrees( |
| | |
| | | // // 添加飞机朝向采样 |
| | | this.orientation.addSample(time, quaternion); |
| | | this.holderHeadingProperty.addSample(time, data.heading) |
| | | |
| | | this.holderPitchProperty.addSample(time, data.pitch) |
| | | this.holderRollProperty.addSample(time, data.roll) |
| | | |
| | | //变倍 |
| | | this.holderZoomProperty.addSample(time,data.zoom) |
| | | }) |
| | |
| | | } |
| | | }); |
| | | }, |
| | | 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 格式 |
| | | // console.log('currentTime' + currentTime) |
| | | 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) |
| | | let i=this.trajectoryData?.length-1 |
| | | // console.log('时间轴事件:' + new Date(currentTimeISO).getTime()) |
| | | // console.log('数组中时间:' +Math.abs(new Date(this.trajectoryData[this.i].time).getTime())) |
| | | // console.log('分割线——————————————————————————————————————————') |
| | | let trajectory=null; |
| | | 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; |
| | | } |
| | | } |
| | | this.i = i; |
| | | const currentPosition = this.positionProperty.getValue(currentTime); |
| | | // 如果获取到位置 |
| | | if (currentPosition) { |
| | |
| | | bottom: 55px; |
| | | border: 1px solid white; |
| | | } |
| | | .el-notification { |
| | | width: 140px !important; /* 调整为所需宽度 */ |
| | | } |
| | | </style> |
| | | <style scoped> |
| | | .zoom-ui-container { |
| | |
| | | bottom: 35px; |
| | | left: 340px; |
| | | } |
| | | /* 修改通知框宽度 */ |
| | | |
| | | </style> |