Procházet zdrojové kódy

更新填挖方分析

zpf před 11 měsíci
rodič
revize
a05a873e15

+ 50 - 2
src/components/TerrainAnalysis/TerrainCutFillAnalysis/TerrainCutFillAnalysis.vue

@@ -22,7 +22,11 @@
         <br>
         土石方量(立方米):
         <el-input class="cut_fill_input" v-model="result" placeholder=""></el-input>
+        <br>
+        <br>
 
+        土石面积(平方米):
+        <el-input class="cut_fill_input" v-model="result_area" placeholder=""></el-input>
       </div>
     </div>
     <div class="cut_fill_Buttons">
@@ -37,6 +41,7 @@
 import CutFillAnalysis from "./CutFillAnalysis.js"
 let cutFillAnalysis = null;
 import { getDsm } from '@/api/analse'
+import * as turf from "@turf/turf";
 
 export default {
   name: "TerrainCutFillAnalysis",
@@ -107,6 +112,7 @@ export default {
       return wktPolygon;
     },
     async smooth_ana(positions, positions_noHeight, threeArray, height) {
+
       let data = await getDsm({
         "geom": this.coordsToWktPolygon(positions_noHeight),
         'type': 'min'
@@ -126,6 +132,42 @@ export default {
       let cutVolume = cutFillAnalysis.VolumeAnalysis(threeArray, height);
       that.result = cutVolume.toFixed(2);
     },
+    async smooth_ana1(positions, positions_noHeight, threeArray, height) {
+      console.log('positions: ', positions);
+
+
+      let data = await getDsm({
+        "geom": this.coordsToWktPolygon(positions_noHeight),
+        'type': 'max'
+      });
+
+      let newArr = positions.map((item, index) => {
+        return (index + 1) % 3 === 0 ? data.data : item;
+      });
+      viewer.scene.globe.removeAllModifyRegion();
+      viewer.scene.globe.addModifyRegion({
+        name: 'ggg',
+        position: newArr
+      });
+
+      this.smooth_height = data.data.toFixed(2)
+      // let cutVolume = cutFillAnalysis.VolumeAnalysis1(threeArray, Number(height));
+      // console.log('cutVolume: ', cutVolume);
+
+      let newArray = [];
+      for (let i = 0; i < positions_noHeight.length; i += 2) {
+        // 将每两个连续的元素组合成一个新的数组,并添加到新数组中
+        newArray.push([positions_noHeight[i], positions_noHeight[i + 1]]);
+      }
+      newArray.push(newArray[0])
+
+      var polygon = turf.polygon([
+        newArray
+      ]);
+
+      this.result_area = turf.area(polygon).toFixed(2);
+    },
+
     draw() {
 
 
@@ -185,7 +227,6 @@ export default {
           var longitude = Cesium.Math.toDegrees(cartographic.longitude);
           var latitude = Cesium.Math.toDegrees(cartographic.latitude);
           var h = cartographic.height;
-          console.log('h: ', h);
           if (positions.indexOf(longitude) == -1 && positions.indexOf(latitude) == -1) {
             positions.push(longitude);
             positions.push(latitude);
@@ -196,6 +237,7 @@ export default {
           }
         }
         let threeArray = null;
+
         if (positions.length % 2 == 0) {
           threeArray = positions;
 
@@ -207,7 +249,9 @@ export default {
         }
 
         if (that.radio == 'smooth') {
-          that.smooth_ana(positions, positions_noHeight, threeArray, -that.height);
+          // that.smooth_ana(positions, positions_noHeight, threeArray, -that.height);
+          that.smooth_ana1(positions, positions_noHeight, threeArray, -that.height);
+
 
         } else if (that.radio == 'cut') {
           if (that.height < 0) {
@@ -240,10 +284,14 @@ export default {
         that.handler_Cut_fill.clear();
         viewer.scene.globe.removeAllExcavationRegion();
         viewer.scene.globe.removeAllExtractRegion();
+        viewer.scene.globe.removeAllModifyRegion();
 
         that.handler_Cut_fill.deactivate();
         that.handler_Cut_fill = null
         that.result = null;
+        that.smooth_height = null;
+        that.result_area = null;
+
       }
 
     },