From 28de79b44655118b1deffb5c9a8b06ec2904905b Mon Sep 17 00:00:00 2001
From: suerprisePlus <15810472099@163.com>
Date: 星期四, 13 六月 2024 17:38:24 +0800
Subject: [PATCH] 功能添加

---
 src/assets/js/tool/configTool.js |  155 +++++++++++++++++++++++++++++----------------------
 1 files changed, 89 insertions(+), 66 deletions(-)

diff --git a/src/assets/js/tool/configTool.js b/src/assets/js/tool/configTool.js
index 8132583..4904bda 100644
--- a/src/assets/js/tool/configTool.js
+++ b/src/assets/js/tool/configTool.js
@@ -1,66 +1,89 @@
-const configTool = {
-  time: 5,
-  setMapFly(res) {
-    var that = this;
-    const alt = res.alt == 0 ? 100 : res.alt;
-    //璁剧疆鍒濆瑙嗗浘浣嶇疆
-    Viewer.camera.flyTo({
-      // fromDegrees()鏂规硶锛屽皢缁忕含搴﹀拰楂樼▼杞崲涓轰笘鐣屽潗鏍�
-      destination: Cesium.Cartesian3.fromDegrees(res.lon, res.lat, alt),
-      orientation: {
-        // 鏂瑰悜
-        heading: res.heading,
-        // 瑙嗚
-        pitch: res.pitch,
-        // 鍊炬枩瑙掑害
-        roll: res.roll,
-        // 璁剧疆椋炶鎸佺画鏃堕棿锛岄粯璁や細鏍规嵁璺濈鏉ヨ绠�
-        duration: that.time,
-      },
-    });
-  },
-  getNewDateTime() {
-    return new Date().getTime();
-  },
-  getEndDateTime() {
-    return this.getNewDateTime() + 3600 * 2;
-  },
-  //鐐瑰嚮鑾峰彇缁忕含搴�
-  getViewerPosition(res) {
-    const cartesain = Viewer.camera.pickEllipsoid(res.position);
-    var cartographic = Cesium.Cartographic.fromCartesian(cartesain);
-    return {
-      lon: parseFloat(Cesium.Math.toDegrees(cartographic.longitude)).toFixed(6),
-      lat: parseFloat(Cesium.Math.toDegrees(cartographic.latitude)).toFixed(6),
-      alt: cartographic.height,
-      heading: Viewer.scene.camera.heading,
-      pitch: Viewer.scene.camera.pitch,
-      roll: Viewer.scene.camera.roll,
-    };
-  },
-  //鑾峰彇褰撳墠瑙嗚淇℃伅
-  getViewerCamera() {
-    var position = Viewer.scene.camera.positionCartographic;
-    return {
-      lon: Cesium.Math.toDegrees(position.longitude).toFixed(6),
-      lat: Cesium.Math.toDegrees(position.latitude).toFixed(6),
-      alt: position.height,
-      heading: Viewer.scene.camera.heading,
-      pitch: Viewer.scene.camera.pitch,
-      roll: Viewer.scene.camera.roll,
-    };
-  },
-  getTreeDataCheck(res, std) {
-    for (var i in res) {
-      if (res[i].children) {
-        this.getTreeDataCheck(res[i].children, std);
-      } else {
-        if (res[i].checked) {
-          std.push(res[i].id);
-        }
-      }
-    }
-    return std;
-  },
-};
-export default configTool;
+const configTool = {
+  time: 5,
+  setMapFly(res) {
+    var that = this;
+    const alt = res.alt == 0 ? 100 : res.alt;
+    //璁剧疆鍒濆瑙嗗浘浣嶇疆
+    Viewer.camera.flyTo({
+      // fromDegrees()鏂规硶锛屽皢缁忕含搴﹀拰楂樼▼杞崲涓轰笘鐣屽潗鏍�
+      destination: Cesium.Cartesian3.fromDegrees(res.lon, res.lat, alt),
+      orientation: {
+        // 鏂瑰悜
+        heading: res.heading,
+        // 瑙嗚
+        pitch: res.pitch,
+        // 鍊炬枩瑙掑害
+        roll: res.roll,
+        // 璁剧疆椋炶鎸佺画鏃堕棿锛岄粯璁や細鏍规嵁璺濈鏉ヨ绠�
+        duration: that.time
+      }
+    });
+  },
+  getNewDateTime() {
+    return new Date().getTime();
+  },
+  getEndDateTime() {
+    return this.getNewDateTime() + 3600 * 2;
+  },
+  //鐐瑰嚮鑾峰彇缁忕含搴�
+  getViewerPosition(res) {
+    const cartesain = Viewer.camera.pickEllipsoid(res.position);
+    var cartographic = Cesium.Cartographic.fromCartesian(cartesain);
+    return {
+      lon: parseFloat(Cesium.Math.toDegrees(cartographic.longitude)).toFixed(6),
+      lat: parseFloat(Cesium.Math.toDegrees(cartographic.latitude)).toFixed(6),
+      alt: cartographic.height,
+      heading: Viewer.scene.camera.heading,
+      pitch: Viewer.scene.camera.pitch,
+      roll: Viewer.scene.camera.roll
+    };
+  },
+  //鑾峰彇褰撳墠瑙嗚淇℃伅
+  getViewerCamera() {
+    var position = Viewer.scene.camera.positionCartographic;
+    return {
+      lon: Cesium.Math.toDegrees(position.longitude).toFixed(6),
+      lat: Cesium.Math.toDegrees(position.latitude).toFixed(6),
+      alt: position.height.toFixed(6),
+      heading: Cesium.Math.toDegrees(Viewer.scene.camera.heading),
+      pitch: Cesium.Math.toDegrees(Viewer.scene.camera.pitch),
+      roll: Cesium.Math.toDegrees(Viewer.scene.camera.roll)
+    };
+  },
+  getTreeDataCheck(res, std) {
+    for (var i in res) {
+      if (res[i].children) {
+        this.getTreeDataCheck(res[i].children, std);
+      } else {
+        if (res[i].checked) {
+          std.push(res[i].id);
+        }
+      }
+    }
+    return std;
+  },
+  generateID() {
+    return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(
+      /[xy]/g,
+      function (c) {
+        var r = (Math.random() * 16) | 0,
+          v = c === "x" ? r : (r & 0x3) | 0x8;
+        return v.toString(16);
+      }
+    );
+  },
+  saveToJson(data, res) {
+    let content = JSON.stringify(data);
+    let blob = new Blob([content], { type: "" });
+    var reader = new FileReader();
+    reader.onloadend = () => {
+      let url = reader.result;
+      let triggerDownload = document.createElement("a");
+      triggerDownload.download = (res) + ".json";
+      triggerDownload.href = url;
+      triggerDownload.click();
+    };
+    reader.readAsDataURL(blob);
+  }
+};
+export default configTool;

--
Gitblit v1.9.3