zpf 11 månader sedan
förälder
incheckning
fb17c578f1

+ 17 - 8
src/components/TerrainAnalysis/TerrainCutFillAnalysis/TerrainCutFillAnalysis.vue

@@ -49,10 +49,13 @@ export default {
 
 
       const that = this;
+      that.clear();
+
       if (that.handler_Cut_fill == null) {
         that.handler_Cut_fill = new Cesium.DrawHandler(viewer, Cesium.DrawMode.Polygon, 0);
       }
 
+
       var tooltip = createTooltip(viewer._element);
       //绘制多边形
       that.handler_Cut_fill.activeEvt.addEventListener(function (isActive) {
@@ -89,9 +92,13 @@ 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++) {
+          debugger
           var cartographic = Cesium.Cartographic.fromCartesian(array[i]);
           var longitude = Cesium.Math.toDegrees(cartographic.longitude);
           var latitude = Cesium.Math.toDegrees(cartographic.latitude);
@@ -102,6 +109,7 @@ export default {
             positions.push(h);
           }
         }
+
         viewer.scene.globe.removeAllExcavationRegion();
         viewer.scene.globe.addExcavationRegion({
           name: 'ggg',
@@ -114,9 +122,6 @@ 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;
@@ -128,11 +133,15 @@ export default {
     },
     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;
+
+
+      if (that.handler_Cut_fill != null) {
+        that.handler_Cut_fill.clear();
+        viewer.scene.globe.removeAllExcavationRegion();
+        that.handler_Cut_fill.deactivate();
+        that.handler_Cut_fill = null
+        that.result = null;
+      }
 
     }
   },