浏览代码

添加倾斜模型压平功能

lkk 1 年之前
父节点
当前提交
9932ee326a

+ 84 - 9
src/components/3DAnalysis/Smashing/Smashing.vue

@@ -7,7 +7,7 @@
       }}</label> -->
 
       <div class="boxchild">
-        <el-button type="primary" size="mini" @click="analysis"
+        <el-button type="primary" size="mini" @click="createSmashing"
           >倾斜压平</el-button
         >
         <el-button type="primary" size="mini" @click="clear">{{
@@ -19,19 +19,19 @@
 </template>
   
   <script>
-//   var skyline;
-//   let myChart, s3mInstance;
+let cutFillAnalysis = null;
 
 export default {
   name: "Sm3dSmashing",
-  props: {
-    //   spatialAnalysisUrl: {
-    //     type: String,
-    //   },
-  },
+  props: {},
   data() {
     return {
       sharedState: store.state,
+      handler_Cut_fill: new Cesium.DrawHandler(
+        viewer,
+        Cesium.DrawMode.Polygon,
+        0
+      ),
     };
   },
   computed: {
@@ -44,7 +44,82 @@ export default {
   },
   beforeDestroy() {},
   mounted() {},
-  methods: {},
+  methods: {
+    createSmashing() {
+      //绘制多边形
+      const that = this;
+      that.handler_Cut_fill.clear();
+      viewer.scene.globe.removeAllExcavationRegion();
+
+      that.handler_Cut_fill.activeEvt.addEventListener(function (isActive) {
+        if (isActive == true) {
+          viewer.enableCursorStyle = false;
+          viewer._element.style.cursor = "";
+          // $('body').removeClass('drawCur').addClass('drawCur');
+        } else {
+          viewer.enableCursorStyle = true;
+          // $('body').removeClass('drawCur');
+        }
+      });
+      that.handler_Cut_fill.movingEvt.addEventListener(function (
+        windowPosition
+      ) {
+        if (windowPosition.x < 200 && windowPosition.y < 150) {
+          tooltip.setVisible(false);
+          return;
+        }
+        if (that.handler_Cut_fill.isDrawing) {
+          tooltip.showAt(
+            windowPosition,
+            "<p>点击确定开挖区域中间点</p><p>右键单击结束绘制,进行开挖</p>"
+          );
+        } else {
+          tooltip.showAt(windowPosition, "<p>点击绘制开挖区域第一个点</p>");
+        }
+      });
+      that.handler_Cut_fill.drawEvt.addEventListener(function (result) {
+        if (!result.object.positions) {
+          tooltip.showAt(result, "<p>请绘制正确的多边形</p>");
+          that.handler_Cut_fill.polygon.show = false;
+          that.handler_Cut_fill.polyline.show = false;
+          that.handler_Cut_fill.deactivate();
+          that.handler_Cut_fill.activate();
+          return;
+        }
+
+        var array = [].concat(result.object.positions);
+
+        tooltip.setVisible(false);
+        var positions = [];
+        for (var i = 0, len = array.length; i < len; i++) {
+          var cartographic = Cesium.Cartographic.fromCartesian(array[i]);
+          var longitude = Cesium.Math.toDegrees(cartographic.longitude);
+          var latitude = Cesium.Math.toDegrees(cartographic.latitude);
+          var h = cartographic.height;
+
+          if (
+            positions.indexOf(longitude) == -1 &&
+            positions.indexOf(latitude) == -1
+          ) {
+            positions.push(longitude);
+            positions.push(latitude);
+            positions.push(h);
+          }
+        }
+        viewer.scene.globe.removeAllExcavationRegion();
+        console.log(positions, "positions");
+        store.state.tempLatData.addFlattenRegion({
+          position: positions,
+          name: "flatten" + Math.random(),
+        });
+        that.handler_Cut_fill.polygon.show = false;
+        that.handler_Cut_fill.polyline.show = false;
+        that.handler_Cut_fill.deactivate();
+        // that.handler_Cut_fill.activate();
+      });
+      that.handler_Cut_fill.activate();
+    },
+  },
   watch: {},
 };
 </script>

+ 1 - 0
src/components/Combinations/LayerManage/LayerManage.vue

@@ -393,6 +393,7 @@ export default {
               keyWord: "SmID",
             });
           }
+          store.state.tempLatData = layers[0][0]
           // for (var i = 0; i < layers.length; i++) {
           //   let style = new Cesium.Style3D();
           //   style.bottomAltitude = window.modelBottomAltitude; //底部高度

+ 1 - 1
static/Config/config.js

@@ -18,7 +18,7 @@ window.mapview = [110.0353, 16.3, 300000.0];
 //window.baseImgLayer = "http://127.0.0.1:8090/iserver/services/map-sanyadsm/rest/maps/%E6%B5%B7%E5%8D%97%E5%B2%9B%E5%BD%B1%E5%83%8F15%E7%BA%A7_Level_15%40DataSource";
 window.baseImgLayer = "http://192.168.60.3:8099/iserver/services/map-WorkSpace/rest/maps/%E6%B5%B7%E5%8D%97%E5%B2%9B%E5%BD%B1%E5%83%8F15%E7%BA%A7_Level_15%40DataSource";
 //三维模型查询地址
-window.baseModelQueryLayer = "http://192.168.100.238:8090/iserver/services/data-building/rest/data/featureResults.rjson?returnContent=true";
+window.baseModelQueryLayer = "http://192.168.60.3:8099/iserver/services/data-building/rest/data/featureResults.rjson?returnContent=true";
 /**
  * 模型对应数据图层
  * url:数据服务地址