From 52a426373c619415f876952b0de04af82564dd96 Mon Sep 17 00:00:00 2001
From: GuLiMmo <2820890765@qq.com>
Date: Wed, 06 Mar 2024 18:04:02 +0800
Subject: [PATCH] update:航线全局设置编辑、新增航点、事件编辑等
---
src/utils/cesium/use-kmz-tsa.ts | 57 +++++++++++++++++++++++++++++++++++++++++++++------------
1 files changed, 45 insertions(+), 12 deletions(-)
diff --git a/src/utils/cesium/use-kmz-tsa.ts b/src/utils/cesium/use-kmz-tsa.ts
index a7543de..a37e16e 100644
--- a/src/utils/cesium/use-kmz-tsa.ts
+++ b/src/utils/cesium/use-kmz-tsa.ts
@@ -1,16 +1,17 @@
import { ref } from 'vue'
-import { analyzeKmzFile, getKmlParams } from '/@/utils/cesium/kmz'
+import { analyzeKmzFile, getKmlParams, generateKmlFormat } from '/@/utils/cesium/kmz'
-const useKMLTsa = () => {
- const kmzStr = ref('')
+const kmlStr = ref('')
- const init = async (fileUrl: string, fileContent ?: string) => {
+const useKmzTsa = () => {
+ const init = async (fileUrl: string, fileContent?: string) => {
const kmzRes: string = await analyzeKmzFile(fileUrl)
if (fileContent) {
- kmzStr.value = fileContent
+ kmlStr.value = fileContent
return false
}
- kmzStr.value = kmzRes
+ kmlStr.value = kmzRes
+ return kmzRes
}
const create = () => {
@@ -29,22 +30,54 @@
</Document>
</kml>
`
- kmzStr.value = str
+ kmlStr.value = str
}
- const write = () => {}
+ const write = (settingParmas: any = {}, name?: string, isWpml?: boolean = false) => {}
- const del = () => {}
+ const del = () => {
+ }
- const edit = () => {}
+ const edit = (settingParmas: any = {}, keyName?: string, isKeyWpml: boolean = false) => {
+ Object.keys(settingParmas).forEach((key: string) => {
+ const regxVal: any = getKmlParams(kmlStr.value, true, {
+ name: key,
+ findRegx: '([\\s\\S]*?)',
+ })
+ const str = regxVal[1]
+ if (str) {
+ if (key === 'globalHeight') {
+ const regxVal: any = getKmlParams(kmlStr.value, true, {
+ name: 'height',
+ findRegx: '([\\s\\S]*?)',
+ mode: 'g'
+ })
+ regxVal.forEach((heightStr: string) => {
+ const rstr = generateKmlFormat({ height: settingParmas[key] })
+ kmlStr.value = kmlStr.value.replace(heightStr, rstr)
+ })
+ }
+ const replaceStr = generateKmlFormat({ [key]: settingParmas[key] })
+ kmlStr.value = kmlStr.value.replace(regxVal[0], replaceStr)
+ } else {
+ console.warn('没有找到对应的属性')
+ }
+ })
+ }
- const save = () => {}
+ const save = () => {
+ console.log(kmlStr.value)
+ }
return {
+ init,
create,
write,
del,
edit,
- save
+ save,
}
}
+
+export { kmlStr }
+export default useKmzTsa
--
Gitblit v1.9.3