From 9f51306b10520a2be30bedfe1b34c288cf770f43 Mon Sep 17 00:00:00 2001
From: surprise <15810472099@163.com>
Date: 星期四, 19 十月 2023 17:51:30 +0800
Subject: [PATCH] 坡度坡向功能新增,临时图层添加定位。空间查询功能优化;

---
 src/components/mouseMove.vue |   58 ++++++++++++++++++++++++++++------------------------------
 1 files changed, 28 insertions(+), 30 deletions(-)

diff --git a/src/components/mouseMove.vue b/src/components/mouseMove.vue
index 63e1296..771bf4d 100644
--- a/src/components/mouseMove.vue
+++ b/src/components/mouseMove.vue
@@ -1,13 +1,6 @@
 <template>
-  <div
-    class="mouseBox"
-    @setMouseMove="setMouseMove"
-  >
-    <div
-      class="earthImage"
-      :class="{ active: gridIsshow }"
-      @click="gridSwitch"
-    ></div>
+  <div class="mouseBox" @setMouseMove="setMouseMove">
+    <div class="earthImage" :class="{ active: gridIsshow }" @click="gridSwitch"></div>
     <div class="earthLable">缁忓害 :</div>
     <div class="earthLable">{{ longitude }}</div>
     <div class="earthLable">绾害 :</div>
@@ -56,13 +49,15 @@
   let handlerPoint = new SmartEarth.Cesium.ScreenSpaceEventHandler(
     window.Viewer.scene.canvas
   );
+  const pickGlobeSlope = new SmartEarth.Cesium.PickGlobeSlope(earthCtrl.Viewer)
   var ellipsoid = window.Viewer.scene.globe.ellipsoid;
-  handlerPoint.setInputAction(function (movement) {
+  handlerPoint.setInputAction((movement) => {
     //鎹曡幏妞悆浣擄紝灏嗙瑳鍗″皵浜岀淮骞抽潰鍧愭爣杞负妞悆浣撶殑绗涘崱灏斾笁缁村潗鏍囷紝杩斿洖鐞冧綋琛ㄩ潰鐨勭偣
     var cartesian = window.Viewer.camera.pickEllipsoid(
       movement.endPosition,
       ellipsoid
     );
+   
     if (cartesian) {
       //灏嗙瑳鍗″皵涓夌淮鍧愭爣杞负鍦板浘鍧愭爣锛堝姬搴︼級
       var cartographic =
@@ -119,27 +114,27 @@
   });
 
 
-   Viewer.scene.postRender.addEventListener(() => {
-      // // 鑾峰彇鐢诲竷鐨勫ぇ灏�
-      let scene = earthCtrl.Viewer.scene;
-      var width = scene.canvas.clientWidth;
-      var height = scene.canvas.clientHeight;
-      //鑾峰彇鐢诲竷涓績涓や釜鍍忕礌鐨勫潗鏍囷紙榛樿鍦板浘娓叉煋鍦ㄧ敾甯冧腑蹇冧綅缃級
-      var left = scene.camera.getPickRay(new SmartEarth.Cesium.Cartesian2((width / 2) | 0, (height - 1) / 2));
-      var right = scene.camera.getPickRay(new SmartEarth.Cesium.Cartesian2(1 + (width / 2) | 0, (height - 1) / 2));
+  Viewer.scene.postRender.addEventListener(() => {
+    // // 鑾峰彇鐢诲竷鐨勫ぇ灏�
+    let scene = earthCtrl.Viewer.scene;
+    var width = scene.canvas.clientWidth;
+    var height = scene.canvas.clientHeight;
+    //鑾峰彇鐢诲竷涓績涓や釜鍍忕礌鐨勫潗鏍囷紙榛樿鍦板浘娓叉煋鍦ㄧ敾甯冧腑蹇冧綅缃級
+    var left = scene.camera.getPickRay(new SmartEarth.Cesium.Cartesian2((width / 2) | 0, (height - 1) / 2));
+    var right = scene.camera.getPickRay(new SmartEarth.Cesium.Cartesian2(1 + (width / 2) | 0, (height - 1) / 2));
 
-      var leftPosition = scene.globe.pick(left, scene);
-      var rightPosition = scene.globe.pick(right, scene);
-      if (!SmartEarth.Cesium.defined(leftPosition) || !SmartEarth.Cesium.defined(rightPosition)) {
-        return;
-      }
-      const ellipsoid = SmartEarth.Cesium.Ellipsoid.MOON2000
-      var leftCartographic = ellipsoid.cartesianToCartographic(leftPosition);
-      var rightCartographic = ellipsoid.cartesianToCartographic(rightPosition);
-      var geodesic = new SmartEarth.Cesium.EllipsoidGeodesic(leftCartographic, rightCartographic, ellipsoid);
-      var distance = geodesic.surfaceDistance;// 鍒嗚鲸鐜�
-      rate.value =distance.toFixed(2); //鍒嗚鲸鐜�
-    })
+    var leftPosition = scene.globe.pick(left, scene);
+    var rightPosition = scene.globe.pick(right, scene);
+    if (!SmartEarth.Cesium.defined(leftPosition) || !SmartEarth.Cesium.defined(rightPosition)) {
+      return;
+    }
+    const ellipsoid = SmartEarth.Cesium.Ellipsoid.MOON2000
+    var leftCartographic = ellipsoid.cartesianToCartographic(leftPosition);
+    var rightCartographic = ellipsoid.cartesianToCartographic(rightPosition);
+    var geodesic = new SmartEarth.Cesium.EllipsoidGeodesic(leftCartographic, rightCartographic, ellipsoid);
+    var distance = geodesic.surfaceDistance;// 鍒嗚鲸鐜�
+    rate.value = distance.toFixed(2); //鍒嗚鲸鐜�
+  })
 };
 const gridSwitch = () => {
   server.showlonlatLine();
@@ -303,6 +298,7 @@
   padding-right: 20px;
   display: flex;
   align-items: center;
+
   .earthImage {
     width: 20px;
     height: 20px;
@@ -311,6 +307,7 @@
     margin-left: 10px;
     cursor: pointer;
   }
+
   .earthLable {
     font-size: 16px;
     font-family: Source Han Sans CN;
@@ -319,6 +316,7 @@
     line-height: 5px;
     margin-left: 10px;
   }
+
   .active {
     background-color: #171e2e;
     border: 1px solid;

--
Gitblit v1.9.3