| | |
| | | CloseOutlined, |
| | | CheckOutlined |
| | | } from '@ant-design/icons-vue' |
| | | import { Item } from 'ant-design-vue/lib/menu' |
| | | // 初始化jszip |
| | | const JsZip = new JSZIP() |
| | | |
| | |
| | | }) |
| | | } |
| | | }, |
| | | // { |
| | | // key: '', |
| | | // icon: getResource('waylinetool/shoot1.png'), |
| | | // title: '开始等时间隔拍照', |
| | | // event: (obj: sBtn) => { |
| | | // obj.selected = !obj.selected |
| | | // editKmlFile() |
| | | // } |
| | | // }, |
| | | // { |
| | | // key: 'shootType', |
| | | // icon: getResource('waylinetool/shoot2.png'), |
| | | // title: '开始等距间隔拍照', |
| | | // event: (obj: sBtn) => { |
| | | // obj.selected = !obj.selected |
| | | // editKmlFile() |
| | | // } |
| | | // }, |
| | | // { |
| | | // key: '', |
| | | // icon: getResource('waylinetool/shoot3.png'), |
| | | // title: '结束间隔拍照', |
| | | // event: (obj: sBtn) => { |
| | | // obj.selected = !obj.selected |
| | | // editKmlFile() |
| | | // } |
| | | // }, |
| | | { |
| | | key: 'time', |
| | | icon: getResource('waylinetool/shoot1.png'), |
| | | title: '开始等时间隔拍照', |
| | | event: (obj: sBtn) => { |
| | | obj.selected = !obj.selected |
| | | editKmlFile('time') |
| | | } |
| | | }, |
| | | { |
| | | key: 'distance', |
| | | icon: getResource('waylinetool/shoot2.png'), |
| | | title: '开始等距间隔拍照', |
| | | event: (obj: sBtn) => { |
| | | obj.selected = !obj.selected |
| | | editKmlFile('distance') |
| | | } |
| | | }, |
| | | { |
| | | key: 'deleteShootType', |
| | | icon: getResource('waylinetool/shoot3.png'), |
| | | title: '结束间隔拍照', |
| | | event: (obj: sBtn) => { |
| | | obj.selected = !obj.selected |
| | | editKmlFile('deleteShootType') |
| | | } |
| | | }, |
| | | { |
| | | key: 'hover', |
| | | icon: getResource('waylinetool/xt.png'), |
| | |
| | | payloadPositionIndex: 0, |
| | | gimbalHeadingYawBase: 'north', |
| | | gimbalRotateMode: 'relativeAngle', |
| | | // 上下摆动 pitch xyz中心点为基准 |
| | | gimbalPitchRotateEnable: 0, |
| | | gimbalPitchRotateAngle: 0.4, |
| | | gimbalPitchRotateAngle: 0, |
| | | // 摆动 roll 已x位基准 |
| | | gimbalRollRotateEnable: 0, |
| | | gimbalRollRotateAngle: 0.4, |
| | | gimbalYawRotateEnable: 0, |
| | | gimbalYawRotateAngle: 0.4, |
| | | gimbalRollRotateAngle: 0, |
| | | // 左右摆动 yaw xyz中心点为基准 |
| | | gimbalYawRotateEnable: 1, |
| | | gimbalYawRotateAngle: 30.1, |
| | | gimbalRotateTimeEnable: 0, |
| | | gimbalRotateTime: 5 |
| | | gimbalRotateTime: 3 |
| | | }) |
| | | } |
| | | }, |
| | | // { |
| | | // key: '', |
| | | // icon: getResource('waylinetool/holdertilt.png'), |
| | | // title: '云台俯仰角', |
| | | // event: (obj: sBtn) => { |
| | | // obj.selected = !obj.selected |
| | | // editKmlFile('gimbalRotate', { |
| | | // payloadPositionIndex: 0, |
| | | // gimbalHeadingYawBase: 'north', |
| | | // gimbalRotateMode: 'relativeAngle', |
| | | // gimbalPitchRotateEnable: 0, |
| | | // gimbalPitchRotateAngle: 0.4, |
| | | // gimbalRollRotateEnable: 0, |
| | | // gimbalRollRotateAngle: 0.4, |
| | | // gimbalYawRotateEnable: 0, |
| | | // gimbalYawRotateAngle: 0.4, |
| | | // gimbalRotateTimeEnable: 0, |
| | | // gimbalRotateTime: 5 |
| | | // }) |
| | | // } |
| | | // }, |
| | | { |
| | | key: 'gimbalRotate', |
| | | icon: getResource('waylinetool/holdertilt.png'), |
| | | title: '云台俯仰角', |
| | | event: (obj: sBtn) => { |
| | | obj.selected = !obj.selected |
| | | editKmlFile('gimbalRotate', { |
| | | payloadPositionIndex: 0, |
| | | gimbalHeadingYawBase: 'north', |
| | | gimbalRotateMode: 'relativeAngle', |
| | | gimbalPitchRotateEnable: 1, |
| | | gimbalPitchRotateAngle: 31.1, |
| | | gimbalRollRotateEnable: 0, |
| | | gimbalRollRotateAngle: 0, |
| | | gimbalYawRotateEnable: 0, |
| | | gimbalYawRotateAngle: 0, |
| | | gimbalRotateTimeEnable: 0, |
| | | gimbalRotateTime: 3 |
| | | }) |
| | | } |
| | | }, |
| | | { |
| | | key: 'takePhoto', |
| | | icon: getResource('waylinetool/camera.png'), |
| | |
| | | return store.state.waylineTool |
| | | }) |
| | | |
| | | /** |
| | | * @description: 读取kmz文件转blob |
| | | * @param {*} kmzPath 文件地址 |
| | | * @return {*} void |
| | | */ |
| | | const readKmzFile = (kmzPath: string) => { |
| | | // return axios.get(kmzPath, { responseType: 'arraybuffer' }) |
| | | return axios({ |
| | |
| | | const funcRegx = /<wpml:actionActuatorFunc>([\s\S]*?)<\/wpml:actionActuatorFunc>/g |
| | | const funcs = (points[currentPosition.value] || '').match(funcRegx) |
| | | const funcNameRegx = /<wpml:actionActuatorFunc>(.*?)<\/wpml:actionActuatorFunc>/ |
| | | |
| | | const shootTypeRegx = /<wpml:shootType>([\s\S]*?)<\/wpml:shootType>/g |
| | | const shootType = (points[currentPosition.value] || '').match(shootTypeRegx) |
| | | const shootTypeValueRegx = /<wpml:shootType>(.*?)<\/wpml:shootType>/ |
| | | btnList.value.forEach(sBtn => { |
| | | funcs?.forEach((func: string) => { |
| | | const funcName = func.match(funcNameRegx) || [] |
| | |
| | | sBtn.selected = true |
| | | } |
| | | }) |
| | | shootType?.forEach((shootType: string) => { |
| | | const typeValue = shootType.match(shootTypeValueRegx) || [] |
| | | if (typeValue[1] === sBtn.key) { |
| | | sBtn.selected = true |
| | | } |
| | | }) |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | // 创建kml模版 |
| | | /** |
| | | * @description: 创建kml模版 |
| | | * @param {*} actionId 事件id(唯一) |
| | | * @param {*} actionType 事件类型 |
| | | * @param {*} param 事件参数 |
| | | * @return {*} void |
| | | */ |
| | | const createActionKML = (actionId: string, actionType: string, param: any) => { |
| | | let paramKML = '' |
| | | Object.keys(param).forEach((key: string) => { |
| | |
| | | return template |
| | | } |
| | | |
| | | // 修改template.kml文件 |
| | | const editKmlFile = (eventType: string, eventParam: any) => { |
| | | /** |
| | | * @description: 修改template.kml文件 |
| | | * @param {*} eventType 事件类型 |
| | | * @param {*} eventParam 事件参数 |
| | | * @return {*} void |
| | | */ |
| | | const editKmlFile = (eventType: string, eventParam?: any) => { |
| | | // kmzZip文件处理 |
| | | const kmlFile = kmzFileZip.value.file(/\.kml$/i)[0] |
| | | kmlFile.async('text').then((kmlText: string) => { |
| | |
| | | // 当前要修改的字段 |
| | | // const curSelected: string | any = points?.find(item => item.includes(currentPosition.value.join(','))) |
| | | const curSelected: string | any = points[currentPosition.value] |
| | | // 判断是不是间隔拍照任务 |
| | | if (eventType === 'time' || eventType === 'distance' || eventType === 'deleteShootType') { |
| | | // 判断当前选中的点是否存在shootType |
| | | const shootTypeRegx = /<wpml:shootType>([\s\S]*?)<\/wpml:shootType>/g |
| | | const kmlResult: string[] = curSelected.match(shootTypeRegx) || [] |
| | | const shootTypeKML = kmlResult[0] |
| | | let replacedKML = '' |
| | | // 判断是不是结束间隔拍照任务 |
| | | if (eventType === 'deleteShootType') { |
| | | if (!shootTypeKML) { |
| | | message.warning('暂未设置间隔任务,无法结束!!') |
| | | } else { |
| | | replacedKML = curSelected.replace(shootTypeRegx, '') |
| | | } |
| | | } else { |
| | | // 判断是否已经设置间隔拍照任务 |
| | | if (shootTypeKML) { |
| | | replacedKML = curSelected.replace(shootTypeRegx, `<wpml:shootType>${eventType}</wpml:shootType>`) |
| | | } else { |
| | | // 判断是否存在actionGroup |
| | | const index = curSelected.indexOf('<wpml:actionGroup>') |
| | | if (index === -1) { |
| | | const placeMarkIdx = curSelected.indexOf('</Placemark>') |
| | | replacedKML = curSelected.slice(0, placeMarkIdx) + `<wpml:shootType>${eventType}</wpml:shootType>` + curSelected.slice(placeMarkIdx) |
| | | } else { |
| | | replacedKML = curSelected.slice(0, index) + `<wpml:shootType>${eventType}</wpml:shootType>` + curSelected.slice(index) |
| | | } |
| | | } |
| | | } |
| | | // 将另外两个间隔任务按钮高亮取消 |
| | | btnList.value.forEach((sBtn: sBtn) => { |
| | | if (sBtn.key === 'time' || sBtn.key === 'distance' || sBtn.key === 'deleteShootType') { |
| | | if (sBtn.key !== eventType) { |
| | | sBtn.selected = false |
| | | } |
| | | } |
| | | }) |
| | | // 替换原本KML |
| | | const replacedTemplateKML = kmlText.replace(curSelected, replacedKML) |
| | | JsZip.file('wpmz/template.kml', replacedTemplateKML) |
| | | kmzFileZip.value.file('wpmz/template.kml', replacedTemplateKML) |
| | | return |
| | | } |
| | | // 查找actionGroup |
| | | const actionGroupReg = /<wpml:actionGroup>([\s\S]*?)<\/wpml:actionGroup>/g |
| | | const actionGroup = curSelected.match(actionGroupReg) ? curSelected.match(actionGroupReg)[0] : '' |
| | |
| | | replacedActionsKML = curSelected.slice(0, index) + actionGroupKML + curSelected.slice(index) |
| | | } else { |
| | | // 替换原有的action |
| | | // replacedActionsKML = curSelected.replace(actionReg, actions.join('')) |
| | | replacedActionsKML = curSelected.replace(actionGroupReg, actionGroupKML) |
| | | } |
| | | // Placemark代替 |
| | | const replacedTemplateKML = kmlText.replace(curSelected, replacedActionsKML) |
| | | // 转成unit8格式 |
| | | // const textEncoder = new TextEncoder() |
| | | // const uint8Array = textEncoder.encode(replacedTemplateKML) |
| | | |
| | | JsZip.file('wpmz/template.kml', replacedTemplateKML) |
| | | kmzFileZip.value.file('wpmz/template.kml', replacedTemplateKML) |
| | | // JsZip.generateAsync({ type: 'blob' }).then(content => { |
| | | // saveAs(content, curKmzName.value) |
| | | // }) |
| | | }) |
| | | } |
| | | |