Explorar o código

填挖方bug修改

zpf hai 1 ano
pai
achega
45f5c78846

+ 1 - 1
src/components/TerrainAnalysis/TerrainCutFillAnalysis/CutFillAnalysis.js

@@ -20,7 +20,7 @@ export default class CutFillAnalysis {
     //创建自定义平面几何体
     this.geom = new Cesium.PolygonGeometry.createGeometry(polygonGeometry);
   }
-  VolumeAnalysis(points, height, extrudedHeight) {
+  VolumeAnalysis(points, extrudedHeight) {
     this.createPolygonGeo(points);
 
     let cutArea = 0,

+ 18 - 15
src/components/TerrainAnalysis/TerrainCutFillAnalysis/TerrainCutFillAnalysis.vue

@@ -30,7 +30,8 @@ export default {
       input: '', sharedState: store.state,
       height: 300,
       result: null,
-      handler_Cut_fill: new Cesium.DrawHandler(viewer, Cesium.DrawMode.Polygon, 0)
+      handler_Cut_fill: null,
+      array3D: []
     };
   },
   //监听属性 类似于data概念
@@ -45,22 +46,13 @@ export default {
   //方法集合
   methods: {
     draw() {
-     
-     
-      const that = this;
-      that.clear();
-      // that.handler_Cut_fill.clear();
-      // that.handler_Cut_fill.deactivate();
 
 
+      const that = this;
+      if (that.handler_Cut_fill == null) {
+        that.handler_Cut_fill = new Cesium.DrawHandler(viewer, Cesium.DrawMode.Polygon, 0);
+      }
 
-      // if (that.handler_Cut_fill.polyline) {
-      //   that.handler_Cut_fill.polyline.show = false;
-      // }
-      // if (that.handler_Cut_fill.polyline) {
-      //   that.handler_Cut_fill.polygon.show = false;
-      // }
-      // viewer.scene.globe.removeAllExcavationRegion();
       var tooltip = createTooltip(viewer._element);
       //绘制多边形
       that.handler_Cut_fill.activeEvt.addEventListener(function (isActive) {
@@ -97,6 +89,7 @@ export default {
         };
         var array = [].concat(result.object.positions);
         tooltip.setVisible(false);
+        that.array = array
         var positions = [];
         for (var i = 0, len = array.length; i < len; i++) {
           var cartographic = Cesium.Cartographic.fromCartesian(array[i]);
@@ -121,14 +114,24 @@ export default {
         that.handler_Cut_fill.polyline.show = false;
         that.handler_Cut_fill.deactivate();
         // that.handler_Cut_fill.activate();
+        console.log(Number(that.height));
+
+
+
+        let cutVolume = cutFillAnalysis.VolumeAnalysis(that.array, -that.height);
+        that.result = cutVolume;
+
+
       });
       that.handler_Cut_fill.activate();
+
     },
     clear() {
       const that = this;
       that.handler_Cut_fill.clear();
       viewer.scene.globe.removeAllExcavationRegion();
-
+      that.handler_Cut_fill.deactivate();
+      that.handler_Cut_fill = null
       that.result = null;
 
     }