From 559f0776123a2205863b5787d5b8e1e012d397d3 Mon Sep 17 00:00:00 2001
From: suerprisePlus <15810472099@163.com>
Date: 星期三, 23 十月 2024 15:29:34 +0800
Subject: [PATCH] 灾害效果修改

---
 src/views/visual/mapView/index.vue         |   12 ++-
 src/views/visualization/list/mapWeather.js |   91 ++++++++++++++++++++++++++----
 public/config/config.js                    |    1 
 src/assets/js/mapSdk/index.js              |    1 
 src/views/visualization/mapView.vue        |    5 +
 src/views/visual/mapView/mapInfo.vue       |    4 -
 src/views/visualization/msgList.vue        |    2 
 public/imgs/waterNormals.jpg               |    0 
 src/assets/js/mapSdk/menuManager.js        |   39 ++++++------
 src/views/visualization/index.vue          |    2 
 10 files changed, 113 insertions(+), 44 deletions(-)

diff --git a/public/config/config.js b/public/config/config.js
index 4099b48..449c469 100644
--- a/public/config/config.js
+++ b/public/config/config.js
@@ -20,6 +20,7 @@
 const pwythHost = "http://localhost/pwyth";
 //閰嶇疆
 const config = {
+  images:  host + "/imgs/",
   // server鏈嶅姟
   apiServices: "http://" + apiHost + "/server/",
   // 鐭ヨ瘑鍥捐氨鏈嶅姟
diff --git a/public/imgs/waterNormals.jpg b/public/imgs/waterNormals.jpg
new file mode 100644
index 0000000..eb1baa2
--- /dev/null
+++ b/public/imgs/waterNormals.jpg
Binary files differ
diff --git a/src/assets/js/mapSdk/index.js b/src/assets/js/mapSdk/index.js
index 48cf46c..a52864a 100644
--- a/src/assets/js/mapSdk/index.js
+++ b/src/assets/js/mapSdk/index.js
@@ -99,7 +99,6 @@
       // 鑾峰彇鐐瑰嚮浣嶇疆鐨勪笘鐣屽潗鏍�
       var pickedFeature = window.Viewer.scene.pick(event.position);
       if (Cesium.defined(pickedFeature)) {
-        console.log(pickedFeature);
         if (pickedFeature.id) {
           const obj = pickedFeature.id;
           var arr = [];
diff --git a/src/assets/js/mapSdk/menuManager.js b/src/assets/js/mapSdk/menuManager.js
index c993e80..b22d7e6 100644
--- a/src/assets/js/mapSdk/menuManager.js
+++ b/src/assets/js/mapSdk/menuManager.js
@@ -263,31 +263,18 @@
                 break;
             case 'a3':
                 earthCtrl.factory.createSimpleGraphic('polyline', { showSize: false }, (entity) => {
-                   
-                    // console.log(entity);
-
-                    // const obj = entity.polyline.positions.getValue();
-                    // var std = [];
-                    // for (var i in obj) {
-                    //     var ellipsoid =Viewer.scene.globe.ellipsoid;
-
-                    //     // 灏嗕笘鐣屽潗鏍囪浆鎹负鍦扮悊鍧愭爣锛圕artographic锛�
-                    //     var cartographic = ellipsoid.cartesianToCartographic(obj[i]);
-
-                    //     // 鑾峰彇缁忕含搴�
-                    //     var longitude = Cesium.Math.toDegrees(cartographic.longitude);
-                    //     var latitude = Cesium.Math.toDegrees(cartographic.latitude);
-                    //     var height = 0;
-                    //     std.push([longitude, latitude, height]);
-                    // }
-                    // console.log(std);
+                    const obj = this.getWKtCoord(entity.polyline.positions.getValue());
+                    console.log('polyline Wkt:' + obj);
                 });
                 break;
             case 'a4':
                 earthCtrl.factory.createSimpleGraphic('rectangle', { showSize: false }, (entity) => {});
                 break;
             case 'a5':
-                earthCtrl.factory.createSimpleGraphic('polygon', { showSize: false }, (entity) => {});
+                earthCtrl.factory.createSimpleGraphic('polygon', { showSize: false }, (entity) => {
+                    const obj = this.getWKtCoord(entity.polygon.hierarchy.getValue().positions);
+                    console.log('polygon Wkt:' + obj);
+                });
                 break;
             case 'a6':
                 earthCtrl.factory.SimpleGraphic.clear();
@@ -297,6 +284,20 @@
         }
         return null;
     },
+    getWKtCoord(obj) {
+        var ellipsoid = Viewer.scene.globe.ellipsoid;
+        var std = [];
+        for (var i in obj) {
+            // 灏嗕笘鐣屽潗鏍囪浆鎹负鍦扮悊鍧愭爣锛圕artographic锛�
+            var cartographic = ellipsoid.cartesianToCartographic(obj[i]);
+            // 鑾峰彇缁忕含搴�
+            var longitude = Cesium.Math.toDegrees(cartographic.longitude);
+            var latitude = Cesium.Math.toDegrees(cartographic.latitude);
+            var height = 0;
+            std.push([longitude, latitude, height]);
+        }
+        return std;
+    },
     // 娴嬮噺
     setMenuS8(res) {
         const colorAll = this.colorAll;
diff --git a/src/views/visual/mapView/index.vue b/src/views/visual/mapView/index.vue
index 4cecfec..dc30041 100644
--- a/src/views/visual/mapView/index.vue
+++ b/src/views/visual/mapView/index.vue
@@ -87,6 +87,7 @@
         this.showEarth = true;
         this.mapViewStart();
         this.$busEvent.$on('CHANGE_MAPINFO', (res) => {
+     
             this.setMapInfo(res);
         });
     },
@@ -100,12 +101,15 @@
 
     methods: {
         setMapInfo(res) {
-            // console.log(res);
-            if (res.length > 0) {
+            this.childObj = null
+            if (res && res.length > 0) {
                 this.childObj = res;
-                setTimeout(() => {
+                this.$nextTick(() => {
                     this.$refs && this.$refs.mapInfo && this.$refs.mapInfo.open();
-                }, 200);
+                })
+
+            } else {
+                return
             }
         },
         mapViewStart() {
diff --git a/src/views/visual/mapView/mapInfo.vue b/src/views/visual/mapView/mapInfo.vue
index 3c378a1..60739f8 100644
--- a/src/views/visual/mapView/mapInfo.vue
+++ b/src/views/visual/mapView/mapInfo.vue
@@ -51,9 +51,7 @@
 
 
 
-            setTimeout(() => {
-                console.log(store.getters.mapInfo);
-            }, 500);
+           
         },
 
 
diff --git a/src/views/visualization/index.vue b/src/views/visualization/index.vue
index aa10c39..d69f69d 100644
--- a/src/views/visualization/index.vue
+++ b/src/views/visualization/index.vue
@@ -25,7 +25,7 @@
                     <atlas v-if="isShow == '鐭ヨ瘑鍥捐氨'"></atlas>
                     <analysis v-if="isShow == '鏁版嵁鍒嗘瀽'"></analysis>
                     <statistics v-if="isShow == '鏁版嵁缁熻'"></statistics>
-                    <line-loss v-if="isShow == '鏁板瓧绾挎崯'"></line-loss>
+                    <line-loss v-if="isShow == '閰嶇綉杩愭'"></line-loss>
                     <semanticFunction v-if="isShow == '璇箟鍔熻兘'"></semanticFunction>
                 </div>
 
diff --git a/src/views/visualization/list/mapWeather.js b/src/views/visualization/list/mapWeather.js
index 222f65f..21f8beb 100644
--- a/src/views/visualization/list/mapWeather.js
+++ b/src/views/visualization/list/mapWeather.js
@@ -1,8 +1,9 @@
 import mapServer from '../../../assets/js/mapSdk/mapServe';
-
+import * as turf from '@turf/turf';
 const mapWeather = {
     regionWeather: null,
     particle: null,
+    showRain: 'ShowRain',
     closeRegionWeather() {
         if (this.regionWeather) {
             this.regionWeather.enableWeatherType = SmartEarth.Cesium.RegionWeather.TYPE_NONE;
@@ -12,23 +13,34 @@
             this.particle.deleteObject();
             this.particle = null;
         }
+        for (var i in Viewer.scene.primitives._primitives) {
+            const name = Viewer.scene.primitives._primitives[i].name;
+            if (name && name == this.showRain) {
+                Viewer.scene.primitives.remove(Viewer.scene.primitives._primitives[i]);
+            }
+        }
     },
     setRegionWeatherType(response) {
         this.closeRegionWeather();
         if (!this.regionWeather) {
             this.getRegionWather(response);
         }
+
         const coord = this.getCoord(response);
-        earthCtrl.camera.flyTo(coord[0], coord[1], 1000, 0, -90, 0, 0);
+
         switch (response.type) {
             case 'rain':
-                this.showRain();
+                //  earthCtrl.camera.flyTo(coord[0], coord[1], 8000, 0, -90, 0, 0);
+                this.showRain(response);
+
                 break;
             case 'fire':
                 this.showFire(response);
+                earthCtrl.camera.flyTo(coord[0], coord[1], 1000, 0, -90, 0, 0);
                 break;
             case 'snow':
                 this.showSnow();
+                earthCtrl.camera.flyTo(coord[0], coord[1], 1000, 0, -90, 0, 0);
                 break;
         }
     },
@@ -44,19 +56,74 @@
             obj,
             {
                 translation: SmartEarth.Cesium.Cartesian3.fromElements(0, 0, 0), //骞崇Щ
-                particleSize:10
+                particleSize: 10,
             },
             function (data) {}
         );
     },
 
-    showRain() {
-        if (this.regionWeather) {
-            this.regionWeather.enableWeatherType = SmartEarth.Cesium.RegionWeather.TYPE_RAIN;
-            this.regionWeather.regionAlpha = 0.6;
-            this.regionWeather.regionGradientDistance = 300;
+    showRain(res) {
+        var area = [];
+        var std =[];
+        for (var i = 0; i < res.area.length; i += 3) {
+            area.push(res.area[i]);
+            area.push(res.area[i + 1]);
+            std.push([res.area[i],res.area[i + 1]])
         }
+        std.push(std[0])
+ 
+        
+        const polygon = turf.polygon([std]);
+
+        const centerPoint = turf.center(polygon);
+        const coord= centerPoint.geometry.coordinates;
+        earthCtrl.camera.flyTo(coord[0], coord[1], 8000, 0, -90, 0, 0);
+
+        const geometry = new Cesium.PolygonGeometry({
+            polygonHierarchy: new Cesium.PolygonHierarchy(Cesium.Cartesian3.fromDegreesArray(area)),
+            height: 0, // 搴曢潰楂樺害
+            extrudedHeight: 0.2, // 姘撮潰楂樺害
+            ellipsoid: Cesium.Ellipsoid.WGS84,
+        });
+
+        // 2. 鍒涘缓GeometryInstance
+        const geometryInstances = new Cesium.GeometryInstance({ geometry });
+
+        // 3. 鍒涘缓material
+        const material = new Cesium.Material({
+            fabric: {
+                type: 'Water',
+                uniforms: {
+                    baseWaterColor: new Cesium.Color(0.25, 0.6, 0.9, 0.5), // 姘撮潰棰滆壊
+                    normalMap: config.images + 'waterNormals.jpg', // 璐村浘
+                    frequency: 5000, // 姘存尝绾规暟閲�
+                    animationSpeed: 0.02, // 姘存祦閫�
+                    amplitude: 30, // 姘存尝绾规尟鍔ㄥ箙搴�
+                    specularIntensity: 5, // 闀滈潰鍙嶅皠寮哄害
+                },
+            },
+        });
+        // 4. 鍒涘缓Appearance
+        const appearance = new Cesium.EllipsoidSurfaceAppearance({
+            aboveGround: true,
+            material,
+        });
+        // 5. 鍒涘缓primitive
+        var primitive = new Cesium.Primitive({
+            geometryInstances,
+            appearance,
+        });
+        primitive.name = this.showRain;
+        Viewer.scene.primitives.add(primitive);
+
+        // Viewer.camera.lookAt(primitive.boundingSphere.center, new Cesium.HeadingPitchRange(0.0, Cesium.Math.toRadians(-90), 5000));
+        // if (this.regionWeather) {
+        //     this.regionWeather.enableWeatherType = SmartEarth.Cesium.RegionWeather.TYPE_RAIN;
+        //     this.regionWeather.regionAlpha = 0.6;
+        //     this.regionWeather.regionGradientDistance = 300;
+        // }
     },
+
     showSnow() {
         if (this.regionWeather) {
             this.regionWeather.enableWeatherType = SmartEarth.Cesium.RegionWeather.TYPE_SNOW;
@@ -65,9 +132,7 @@
         }
     },
     getCoord(res) {
-       const coord = res.point.split(',');
-       
-
+        const coord = res.point.split(',');
         return coord;
     },
     getRegionWather(res) {
@@ -83,7 +148,7 @@
             primitive: model[0].layer.item,
             position: new SmartEarth.Cesium.Cartesian3.fromDegrees(coord[0], coord[1], 1),
             radius: 1000,
-        })
+        });
     },
 };
 
diff --git a/src/views/visualization/mapView.vue b/src/views/visualization/mapView.vue
index 2bf0801..270738d 100644
--- a/src/views/visualization/mapView.vue
+++ b/src/views/visualization/mapView.vue
@@ -96,8 +96,9 @@
         addRoadLayer() {
             earthCtrl.factory.createPathLayer({
                 url: road,
-                color: "#00FA9A", //绾跨殑棰滆壊
-                width: 4.0, //绾跨殑瀹藉害
+                // color: "#00FA9A", //绾跨殑棰滆壊
+                 color: "#ff0000", //绾跨殑棰滆壊
+                width: 5.0, //绾跨殑瀹藉害
                 pointColor: "#FFFFFF", //绉诲姩鐐圭殑棰滆壊
                 speed: 1,
                 far: 50000
diff --git a/src/views/visualization/msgList.vue b/src/views/visualization/msgList.vue
index 2df2c44..34b1cb0 100644
--- a/src/views/visualization/msgList.vue
+++ b/src/views/visualization/msgList.vue
@@ -67,7 +67,7 @@
     handleClick(item) {
       this.removeLabel();
       // const point = mapConfig.getWKTParse(item.point)
-      const point = item.point.split(" ")
+      const point = item.point.split(",")
       this.label = earthCtrl.factory.createLabel({
         lon: point[0],
         lat: point[1],

--
Gitblit v1.9.3