| | |
| | | // roll:0, |
| | | // speed: 10 // 速度(公里/小时) |
| | | // }, |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | // { |
| | | // time: '2025-04-01T13:01:00Z', // ISO 8601格式时间 |
| | | // position: { |
| | |
| | | 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 = ` |
| | |
| | | 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 { |
| | |
| | | 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 |
| | |
| | | // 提取 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}); |
| | | }); |
| | | } |
| | | }); |
| | |
| | | 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); |
| | | |