Browse Source

模型拉伸基础高程获取和设置

maxiaoxiao 6 months ago
parent
commit
ccac809311
2 changed files with 55 additions and 8 deletions
  1. 4 1
      src/components/mapView/range.vue
  2. 51 7
      src/views/modelStretch/index.vue

+ 4 - 1
src/components/mapView/range.vue

@@ -118,7 +118,7 @@ export default {
           this.model.xzfw = res.data.id;
           this.model.geom = res.data.geom;
           this.addPolygon(parse(res.data.geom));
-          if (this.$props.type == "cutfill") {
+          if (this.$props.type == "cutfill" || this.$props.type == "up") {
             this.$emit("cutfill", this.model.geom);
           }
         }
@@ -240,6 +240,9 @@ export default {
             this.$emit("cutfill", this.model.geom);
             return;
           }
+          if (this.$props.type == "up") {
+            this.$emit("cutfill", wktPolygon, res.positions);
+          }
 
           const formdata = new FormData();
           // formdata.append("file", file.raw);

+ 51 - 7
src/views/modelStretch/index.vue

@@ -11,7 +11,29 @@
     <div class="xz_box">
       <el-form :model="form" ref="ruleForm" label-width="100px" :rules="rules">
         <el-form-item label="平面范围:" prop="xzmj">
-          <range type="hgxfx" :keys="['hx', 'sc']" class="range" ref="range" />
+          <range
+            type="up"
+            :keys="['hx', 'sc']"
+            class="range"
+            ref="range"
+            @cutfill="getDsm"
+          />
+        </el-form-item>
+        <!-- <el-form-item label="点击获取高程" label-width="130px">
+          <el-button type="primary" size="mini" @click="clickPoint">
+            查询
+          </el-button>
+        </el-form-item> -->
+        <el-form-item label="模型初始基准:" prop="height">
+          <el-input
+            v-model="form.height"
+            placeholder="模型拉伸初始高度"
+            size="mini"
+            class="heightinput"
+          ></el-input>
+          <el-button type="primary" size="mini" @click="clickPoint">
+            点击获取
+          </el-button>
         </el-form-item>
         <el-row :gutter="10">
           <el-col :span="13" style="text-align: center">
@@ -67,7 +89,8 @@
             </div> -->
       </el-form>
       <div class="Btns">
-        <el-button size="mini" @click="clear">清 除</el-button>
+        <el-button size="mini" @click="clear">清 除所有</el-button>
+        <el-button size="mini" @click="reset">重新拉伸</el-button>
         <el-button type="primary" size="mini" @click="submit">确 定</el-button>
       </div>
     </div>
@@ -78,7 +101,7 @@
 import range from "@/components/mapView/range.vue"; ///mapview/range
 import {} from "@/api/map";
 import parse from "wellknown";
-import { getCentroid } from "@/utils/MapHelper/help.js";
+import { getCentroid, pickPoint } from "@/utils/MapHelper/help.js";
 let polygonids = [];
 let dataSources = {};
 export default {
@@ -88,7 +111,7 @@ export default {
   },
   data() {
     return {
-      form: { BuildingHeight: 50, FLOORH: 5, xzmj: 0 },
+      form: { BuildingHeight: 50, FLOORH: 5, xzmj: 0, height: 0 },
       rules: {
         xzmj: [{ required: true, message: "请填写范围的数据" }],
         BuildingHeight: [{ required: true, message: "请填写模型高度" }],
@@ -117,6 +140,19 @@ export default {
       store.setToolBarAction(13);
       this.clear();
     },
+    clickPoint() {
+      pickPoint(true, (lon, lat, height) => {
+        this.form.height = Number(height.toFixed(6));
+      });
+    },
+    getDsm(geom, positions) {
+      if (positions) {
+        const filteredArr = positions.filter((item, index) => {
+          if ((index + 1) % 3 == 0) return item;
+        });
+        this.form.height = Number(Math.max(...filteredArr).toFixed(6));
+      } else this.form.height = 0;
+    },
     pullUp(item, height) {
       let upid = "up" + item.id;
       if (!dataSources[upid])
@@ -223,16 +259,20 @@ export default {
         });
     },
     clear() {
+      this.form.height = 0;
       this.$refs.range.reset();
       // this.pullClear();
       // this.removeEntities();
       viewer.entities.removeAll();
       viewer.dataSources.removeAll();
     },
+    reset() {
+      viewer.entities.removeAll();
+      viewer.dataSources.removeAll();
+    },
     submit() {
       var _temp = this.$refs.range.getRange();
       this.form.xzfw = _temp.xzfw;
-
       this.$refs.ruleForm.validate((valid) => {
         if (valid) {
           if (!this.form.xzfw) {
@@ -273,7 +313,7 @@ export default {
       // that.removeEntities();
       // //基础高度(地形高度)加入地形后可删除
       let jcgd = 0;
-      jcgd = this.getjcHigeht(this.form.geojson);
+      jcgd = this.form.height; //this.getjcHigeht(this.form.geojson);
       //顶部高度,底部高度
       let maxH = jcgd,
         minH = jcgd;
@@ -284,7 +324,8 @@ export default {
       ) {
         maxH += this.form.FLOORH;
         minH = maxH - this.form.FLOORH;
-        if (maxH > this.form.BuildingHeight) maxH = this.form.BuildingHeight;
+        if (maxH - jcgd > this.form.BuildingHeight)
+          maxH = this.form.BuildingHeight + jcgd;
         console.log("maxH:" + maxH + "----minH:" + minH);
         this.loadGeoJSON(this.form.geojson, "#ffffff", "", minH, maxH, "");
         // this.addPrimitive(this.form.geojson);
@@ -411,6 +452,9 @@ export default {
   .inputwidth {
     width: calc(100% - 20px);
   }
+  .heightinput {
+    width: calc(100% - 100px);
+  }
 
   .Btns {
     width: 100%;