管道基础大数据平台系统开发-【前端】-新系統界面
Surpriseplus
2023-03-16 7a8747bc51caf48afcc1e5b41be9eb27d8deb728
src/views/Synthesis/LeftMenu.vue
@@ -90,10 +90,11 @@
            >
              <el-form-item :label="$t('common.name')">
                <el-input v-model="formInline.name"></el-input>
                <!-- <el-input v-model="formInline.name"></el-input> -->
                {{formInline.name}}
              </el-form-item>
              <el-form-item :label="$t('common.type')">
                <el-select
                <!-- <el-select
                  v-model="formInline.type"
                  style="width:100%"
                >
@@ -104,13 +105,15 @@
                    :value="item.value"
                  >
                  </el-option>
                </el-select>
                </el-select> -->
                {{formInline.type}}
              </el-form-item>
              <el-form-item :label="$t('common.bak')">
                <el-input v-model="formInline.bak"></el-input>
                <!-- <el-input v-model="formInline.bak"></el-input> -->
                {{formInline.bak}}
              </el-form-item>
              <el-form-item>
              <!-- <el-form-item>
                <el-button
                  v-show="isShowModel"
                  type="success"
@@ -119,14 +122,14 @@
                  @click="InsertData"
                >{{$t('common.increase')}}</el-button>
                <el-button
                  v-show="!isShowModel"
                  v-show=" isShowModel"
                  type="info"
                  plain
                  size="small"
                  @click="EditData"
                >{{$t('common.update')}}</el-button>
              </el-form-item>
              </el-form-item>
              </el-form-item> -->
            </el-form>
          </el-tab-pane>
@@ -134,6 +137,7 @@
            label="附件"
            name="second"
          >
            <el-table
              :data="tableData"
              ref="filterTable"
@@ -251,8 +255,8 @@
  comprehensive_deletes,
  comprehensive_selectModelByPageAndCount,
  comprehensive_insertModel,
  comprehensive_updateModel
} from "../../api/api.js";
  comprehensive_updateModel, selectByBuffer
} from '../../api/api.js'
import {
  OverviewMap,
  defaults as defaultControls,
@@ -471,6 +475,7 @@
            name: "空间查询",
            css: "twoMenu_imge52",
          },
        ],
        [
          {
@@ -647,25 +652,28 @@
      },
      activeName: "first",
      isShowModel: false,
      options: [{
        value: '倾斜模型',
        label: '倾斜模型'
      }, {
        value: 'BIM模型',
        label: 'BIM模型'
      }, {
        value: '点云模型',
        label: '点云模型'
      }, {
        value: '地质设计模型',
        label: '地质设计模型'
      }, {
        value: '人工模型',
        label: '人工模型'
      }, {
        value: '其他模型',
        label: '其他模型'
      }]
      options: [
        {
          value: '倾斜模型',
          label: '倾斜模型'
        }, {
          value: 'BIM模型',
          label: 'BIM模型'
        }, {
          value: '点云模型',
          label: '点云模型'
        }, {
          value: '地质设计模型',
          label: '地质设计模型'
        }, {
          value: '人工模型',
          label: '人工模型'
        }, {
          value: '其他模型',
          label: '其他模型'
        }],
      modelClip: false,
      showPickUp: false,
    };
  },
  methods: {
@@ -673,13 +681,16 @@
    setChangeTwoMenu(res) {
      var val = res.id[0];
      if (window.model != null) {
        window.model.deleteObject();
        window.model = null;
        // window.model.deleteObject();
        // window.model = null;
      }
      sgworld.Analysis.clearCurtainContrast();
      this.showPickUp = false;
      if (this.isMenuFlag == "d") {
        this.clearAllAnalsy();
      }
      this.$store.state.propertiesFlag = '';
      if (this.isMenuFlag != val) {
        if (res.id != "b9") {
@@ -687,7 +698,7 @@
          this.$store.state.mapMenuBoxFlag = null;
          this.$store.state.mapPopBoolean = false;
          this.$store.state.mapPopBoxFlag = null;
          sgworld.Creator.SimpleGraphic.clear();
          this.isMenuFlag = val;
          if (this.entityaLayers.length != 0) {
            for (var i in this.entityaLayers) {
@@ -707,7 +718,10 @@
        }
      }
      this.showTwoMenuFlag = res.id;
      if (val != 'h') {
        sgworld.Creator.SimpleGraphic.clear();
        Viewer.entities.removeAll();
      }
      switch (val) {
        case "a": //图层管理
          this.setCoverage(res.id);
@@ -737,6 +751,7 @@
      }
    },
    setPlot(res) {
      switch (res) {
        case "h1":
          sgworld.Creator.createSimpleGraphic(
@@ -1381,12 +1396,32 @@
    setIquery(res) {
      switch (res) {
        case "e2":
          this.showPickUp = false;
          this.$store.state.mapMenuBoolean = !this.$store.state.mapMenuBoolean;
          this.$store.state.mapMenuBoxFlag = "1";
          break;
        case "e1":
          this.$store.state.mapMenuBoolean = !this.$store.state.mapMenuBoolean;
          this.$store.state.mapMenuBoxFlag = "2";
          this.showPickUp = false;
          break;
        //拾取功能
        case "e3":
          this.$store.state.mapMenuBoolean = false;
          this.showPickUp = !this.showPickUp;
          if (this.showPickUp) {
            let that = this;
            Viewer.screenSpaceEventHandler.setInputAction(function (event) {
              let p = sgworld.Navigate.getMouseDegrees(event);
              console.log(p);
              if (that.showPickUp) {
                that.getPickUpData(p);
              }
            }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
          } else {
            this.$refs.queryinfo.closeAll();
            Viewer.screenSpaceEventHandler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK);
          }
          break;
      }
    },
@@ -1413,15 +1448,17 @@
    setAnalsy(res) {
      //this.$refs && this.$refs.queryinfo && this.$refs.queryinfo.close("queryinfo");
      this.$bus.$emit("closeMenuPop", res);
      var that = this;
      switch (res) {
        case "d1": //等高线分析
          this.closePipelinePop();
          that.isolineFlag = !that.isolineFlag;
          elevationTool.tf = that.isolineFlag;
          elevationTool.render();
          break;
        case "d2": //坡度分析
          this.closePipelinePop();
          that.isslopeFlag = !that.isslopeFlag;
          var val = {
            name: "Lengend",
@@ -1440,6 +1477,7 @@
          break;
        case "d3": //路径分析
          this.closePipelinePop();
          this.isRouter = !this.isRouter;
          let value;
          if (this.isRouter) {
@@ -1458,6 +1496,7 @@
          this.$bus.$emit("mapChangeBox", value);
          break;
        case "d4": //剖面分析
          this.closePipelinePop();
          if (window.AnalysisDXPM) {
            window.AnalysisDXPM.end && window.AnalysisDXPM.end("cancel");
            this.clear(res);
@@ -1466,6 +1505,7 @@
          }
          break;
        case "d5": //洪水淹没分析
          this.closePipelinePop();
          if (window.AnalysisFlood) {
            this.clear(res);
          } else {
@@ -1473,6 +1513,7 @@
          }
          break;
        case "d6": //土方量分析
          this.closePipelinePop();
          if (window.TFvolumetricMeasurementTool) {
            TFvolumetricMeasurementTool.cleanUp();
            if (TFvolumetricMeasurementTool._mouseHandler) {
@@ -1505,23 +1546,54 @@
          }
          break;
        case "d7": //三维截面分析
          this.closePipelinePop();
          // if(window.MXModel) {
          //   Viewer.screenSpaceEventHandler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK);
          //   window.MXModel=null;
          // } else {
          var that = this;
          window.model = sgworld.Creator.create3DTilesets(
            "",
            modelUrl + "/tileset/m/SN/tileset.json",
            {},
            {},
            "0",
            true,
            (data) => {
              sgworld.Navigate.flyToObj(data);
              that.setclippingModel();
          that.modelClip = !that.modelClip;
          if (that.modelClip) {
            that.$store.state.propertiesFlag = '3';
            if (window.model) {
              that.modelClipping();
            }
          );
            else {
              var tileset = Viewer.scene.primitives.add(
                new Cesium.Cesium3DTileset({
                  name: res.cnName,
                  url: modelUrl + "/tileset/m/SN/tileset.json",
                  maximumScreenSpaceError: 64, // 最大屏幕空间错误:16
                  maximumMemoryUsage: 768, // 最大内存:512
                  dynamicScreenSpaceError: true, // 减少离相机较远的屏幕空间错误:false
                  skipLevelOfDetail: true, // 在遍历时候跳过详情:false
                })
              );
              tileset.readyPromise.then((tileset) => {
                tileset.id = res.cnName;
                tileset.layerId = res.id;
                Viewer.flyTo(tileset);
                that.modelClipping();
              });
              window.model = tileset
            }
          }
          else {
            that.$store.state.propertiesFlag = '';
            Viewer.entities.removeAll();
          }
          // window.model = sgworld.Creator.create3DTilesets(
          //   "",
          //   modelUrl + "/tileset/m/SN/tileset.json",
          //   {},
          //   {},
          //   "0",
          //   true,
          //   (data) => {
          //     sgworld.Navigate.flyToObj(data);
          //     that.setclippingModel();
          //   }
          // );
          break;
        case "d9": //管道分析
@@ -1549,6 +1621,7 @@
          break;
        case "d8": //影像对比
          this.closePipelinePop();
          if (this.isContrastFlag == false) {
            this.isContrastFlag = true;
            sgworld.Analysis.createCurtainContrast(2, 1);
@@ -1558,6 +1631,7 @@
          }
          break;
        case "d10": //地面整平
          this.closePipelinePop();
          var val = {
            name: "Trrain",
            id: res,
@@ -1595,6 +1669,7 @@
          break;
        case "d11": //地形开挖
          this.closePipelinePop();
          // this.$refs &&
          //   this.$refs.terrainDig &&
          //   this.$refs.terrainDig.open("管道空间分析", null, {
@@ -1619,6 +1694,7 @@
          break;
        case "d12": //通视分析
          this.closePipelinePop();
          if (window.TSExcavation != null) {
            window.TSExcavation._SimpleGraphic.drawHandler &&
              window.TSExcavation._SimpleGraphic.drawHandler.destroy();
@@ -1635,6 +1711,7 @@
          }
          break;
        case "d13": //视域分析
          this.closePipelinePop();
          if (window.SYExcavatio) {
            window.SYExcavatio.end && window.SYExcavatio.end();
            window.SYExcavatio.close();
@@ -1654,6 +1731,7 @@
          }
          break;
        case "d14": //圆形时域分析
          this.closePipelinePop();
          if (window.YXSYExcavation) {
            window.YXSYExcavation.end && window.YXSYExcavation.end();
            window.YXSYExcavation.close();
@@ -1674,6 +1752,262 @@
          break;
      }
    },
    //模型裁切
    modelClipping() {
      const scene = Viewer.scene;
      let targetY = 0.0;
      let planeEntities = [];
      let selectedPlane;
      // let clippingPlanes = new Cesium.ClippingPlaneCollection({
      //   planes: [ // ClippingPlane对象数组集合
      //     new Cesium.ClippingPlane( // 裁切面
      //       new Cesium.Cartesian3(0.0, 0.0, -1.0), // 法线方向
      //       0// 原点到平面的最短距离,设置0就好
      //     ),
      //   ],
      //   enabled: true,
      //   edgeWidth: 1.0, // 模型被裁切部分的截面线宽
      // });
      let clippingPlanes = new Cesium.ClippingPlaneCollection({
        planes: [ // ClippingPlane对象数组集合
          //前后切割
          new Cesium.ClippingPlane(new Cesium.Cartesian3(0, 1, 0), 0), //后
          new Cesium.ClippingPlane(new Cesium.Cartesian3(0, -1, 0), 0),  //前
          // 左右切割
          new Cesium.ClippingPlane(new Cesium.Cartesian3(1.0, 0.0, 0), 0), //左
          new Cesium.ClippingPlane(new Cesium.Cartesian3(-1.0, 0.0, 0), 0),  //右
          // 上下切割
          new Cesium.ClippingPlane(new Cesium.Cartesian3(0, 0.0, -1), 0),  //上→下
          // new Cesium.ClippingPlane(new Cesium.Cartesian3(0, 0.0, 1), 0),  //下→上、
        ],
        enabled: true,
        edgeWidth: 1.0, // 模型被裁切部分的截面线宽
        unionClippingRegions: true, //true 才能多个切割
      });
      let boundingSphere = window.model.boundingSphere;
      // 创建一个坐标轴,便于测试
      var transform = Cesium.Transforms.eastNorthUpToFixedFrame(boundingSphere.center);
      var modelMatrixPrimitive = Viewer.scene.primitives.add(new Cesium.DebugModelMatrixPrimitive({
        // modelMatrix: transform,
        length: 140.0
      }));
      // // 创建添加裁剪平面
      // for (let i = 0; i < clippingPlanes.length; ++i) {
      //   const plane = clippingPlanes.get(i);
      //   const planeEntity = Viewer.entities.add({
      //     position: boundingSphere.center,
      //     plane: {
      //       dimensions: new Cesium.Cartesian2(
      //         boundingSphere.radius * 1.5,
      //         boundingSphere.radius * 1.5
      //       ),//切面的长和宽
      //       material: Cesium.Color.WHITE.withAlpha(0.1),
      //       plane: new Cesium.CallbackProperty(
      //         // 添加绑定事件,不断调用
      //         createPlaneUpdateFunction(plane),
      //         false
      //       ),
      //       outline: true,
      //       outlineColor: Cesium.Color.WHITE,
      //     },
      //   });
      //   planeEntities.push(planeEntity);
      // }
      // 创建添加裁剪平面
      let m_box;
      for (let i = 0; i < clippingPlanes.length; ++i) {
        let plane = clippingPlanes.get(i);
        let getPlaneType = getType4Plane(plane);
        let planeEntity = Viewer.entities.add({ //添加平面实体 直观裁切面
          id: 'ClipPlane' + i,
          position: boundingSphere.center,// 根据3dtiles同步调整裁切面高度
          plane: {
            dimensions: new Cesium.Cartesian2(80, 80),//切面的长和宽
            plane: new Cesium.CallbackProperty(createPlaneUpdateFunction_box(plane, getPlaneType, boundingSphere.center), false),
            material: Cesium.Color.WHITE.withAlpha(0.01),
            outline: false,
            outlineColor: Cesium.Color.WHITE,
          }
        });
        if (!m_box) {
          m_box = Viewer.entities.add({
            id: 'ClopBox',
            modelMatrixPrimitive: modelMatrixPrimitive,
            position: boundingSphere.center,
            box: {
              dimensions: new Cesium.Cartesian3(boundingSphere.radius * 1.2, boundingSphere.radius * 1.2, 40),
              material: Cesium.Color.WHITE.withAlpha(0.3),
            }
          })
        }
      }
      window.model.clippingPlanes = clippingPlanes;
      // 绑定上移动事件
      // const downHandler = new Cesium.ScreenSpaceEventHandler(
      //   Viewer.scene.canvas
      // );
      // downHandler.setInputAction(function (movement) {
      //   const pickedObject = scene.pick(movement.position);
      //   if (
      //     Cesium.defined(pickedObject) &&
      //     Cesium.defined(pickedObject.id.plane)
      //   ) {
      //     selectedPlane = pickedObject.id.plane;
      //     selectedPlane.material = Cesium.Color.WHITE.withAlpha(0.05);
      //     selectedPlane.outlineColor = Cesium.Color.WHITE;
      //     scene.screenSpaceCameraController.enableInputs = false;
      //   }
      // }, Cesium.ScreenSpaceEventType.LEFT_DOWN);
      // 绑定下移动事件
      // const upHandler = new Cesium.ScreenSpaceEventHandler(
      //   Viewer.scene.canvas
      // );
      // upHandler.setInputAction(function () {
      //   if (Cesium.defined(selectedPlane)) {
      //     selectedPlane.material = Cesium.Color.WHITE.withAlpha(0.1);
      //     selectedPlane.outlineColor = Cesium.Color.WHITE;
      //     selectedPlane = undefined;
      //   }
      //   scene.screenSpaceCameraController.enableInputs = true;
      // }, Cesium.ScreenSpaceEventType.LEFT_UP);
      // Update plane on mouse move
      // const moveHandler = new Cesium.ScreenSpaceEventHandler(
      //   Viewer.scene.canvas
      // );
      // moveHandler.setInputAction(function (movement) {
      //   if (Cesium.defined(selectedPlane)) {
      //     const deltaY = movement.startPosition.y - movement.endPosition.y;
      //     targetY += deltaY;
      //     console.log("targetY----",targetY)
      //   }
      // }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
      function createPlaneUpdateFunction(plane) {
        return function () {
          plane.distance = targetY;
          return plane;
        };
      }
      //获取切面的type // 上、下、左、右、前、后
      function getType4Plane(plane) {
        var m_type;
        var normal = plane._normal;
        var x = normal.x;
        var y = normal.y;
        var z = normal.z;
        if (x == 1 && y == 0 && z == 0) {
          m_type = 'left';
        }
        else if (x == -1 && y == 0 && z == 0) {
          m_type = 'right';
        }
        else if (x == 0 && y == 1 && z == 0) {
          m_type = 'behind';
        }
        else if (x == 0 && y == -1 && z == 0) {
          m_type = 'front';
        }
        else if (x == 0 && y == 0 && z == -1) {
          m_type = 'top';
        }
        return m_type;
      }
      function createPlaneUpdateFunction_box(plane, type, origin) {
        return function () {
          var num_x = window.localStorage.getItem('slider_x') / 100000;
          var num_y = window.localStorage.getItem('slider_y') / 100000;
          var num_z = window.localStorage.getItem('slider_z') / 1.5;//读取滑动条值
          var origin_degree = cartesian3ToDegrees(origin);
          var target_degree_x = [origin_degree[0] + num_x, origin_degree[1], +origin_degree[2]];
          var target_degree_y = [origin_degree[0], origin_degree[1] + num_y, +origin_degree[2]];
          var target_degree_z = [origin_degree[0], origin_degree[1], +origin_degree[2] + num_z];
          var m_dis_x = Cesium.Cartesian3.distance(origin, Cesium.Cartesian3.fromDegrees(target_degree_x[0], target_degree_x[1], target_degree_x[2]));
          var m_dis_y = Cesium.Cartesian3.distance(origin, Cesium.Cartesian3.fromDegrees(target_degree_y[0], target_degree_y[1], target_degree_y[2]));
          var m_dis_z = Cesium.Cartesian3.distance(origin, Cesium.Cartesian3.fromDegrees(target_degree_z[0], target_degree_z[1], target_degree_z[2]));
          createPlanePos(origin_degree, num_x, num_y, num_z);
          let distance = 140;
          if (type == 'left') {
            if (num_x < 0) {
              plane.distance = distance - (-m_dis_x);
              return plane;
            } else {
              plane.distance = distance - m_dis_x
              return plane;
            }
          }
          else if (type == 'behind') {
            if (num_y < 0) {
              plane.distance = distance - (-m_dis_y);
              return plane;
            } else {
              plane.distance = distance - m_dis_y;
              return plane;
            }
          }
          else if (type == 'right') {
            if (num_x < 0) {
              plane.distance = distance - m_dis_x;
              return plane;
            } else {
              plane.distance = distance - (-m_dis_x);
              return plane;
            }
          }
          else if (type == 'front') {
            if (num_y < 0) {
              plane.distance = distance - m_dis_y;
              return plane;
            } else {
              plane.distance = distance - (-m_dis_y);
              return plane;
            }
          }
          else if (type == 'top') {
            if (num_z < 0) {
              plane.distance = m_dis_z;
              // console.log('num_z=========',num_z)
              // console.log('m_dis_z=========',m_dis_z)
              // plane.distance = distance - m_dis_z;
              return plane;
            } else {
              // plane.distance = 100;
              plane.distance = distance - (-m_dis_z);
              return plane;
            }
          }
          return plane;
        };
      }
      function createPlanePos(origin, x, y, z) {
        var clipbox = Viewer.entities.getById('ClopBox');
        if (clipbox) {
          clipbox.position = new Cesium.CallbackProperty(function () {
            return Cesium.Cartesian3.fromDegrees(origin[0] + x, origin[1] + y, +origin[2] + z);//实时返回当前盒子的位置
          }, false);
        }
      }
      function cartesian3ToDegrees(cartesian3) {
        var ellipsoid = Viewer.scene.globe.ellipsoid;
        var cartographic = ellipsoid.cartesianToCartographic(cartesian3);
        var lat = Cesium.Math.toDegrees(cartographic.latitude);
        var lng = Cesium.Math.toDegrees(cartographic.longitude);
        var alt = cartographic.height;
        var pos = [lng, lat, alt];
        return pos;
      }
    },
    //关闭管道信息弹窗
    closePipelinePop() {
      this.$refs &&
        this.$refs.queryinfo &&
        this.$refs.queryinfo.close("queryinfo");
    },
    setclippingModel() {
      if (window.model) {
@@ -1896,9 +2230,11 @@
      if (data.code != 200) {
        return this.$message.error("图层列表查询失败");
      }
      var std = data.result;
      var that = this;
      var checkKey = [];
      let checkedLayers = [];
      var val = std.filter((str) => {
        if (str.type == 1) {
          return str;
@@ -1906,13 +2242,21 @@
        if (str.url != null && str.type == 2) {
          if (str.isShow == 1) {
            checkKey.push(str.id);
            that.setAddLayers(str);
          }
          return str;
        }
      });
      var value = std.filter((str) => {
        if (str.url != null && str.type == 2 && str.isShow == 1) {
          return str;
        }
      })
      this.setAddLayers(value);
      var res = this.setTreeData(val);
      //存储选中图层
      // sessionStorage.setItem("checkedLayers", JSON.stringify(checkedLayers));
      for (var i in res) {
        res[i].children = res[i].children.filter((val) => {
@@ -1921,8 +2265,9 @@
          }
        });
      }
      this.$store.state.treeData = res;
      // this.$refs.tree.setCheckedKeys(checkKey);
      this.$store.state.checkedKeys = checkKey;
    },
    setTreeData(source) {
@@ -1937,101 +2282,105 @@
      });
    },
    setAddLayers(res) {
      if (res.serveType == "WMS") {
        var resource = geoServerURl;
        if (res.resource != null && res.resource != undefined) {
          resource = res.resource;
      var std = [[]];
      for (var i in res) {
        switch (res[i].serveType) {
          case "WMS":
            std[0].push(res[i])
            break;
        }
        var imageryLayers = window.Viewer.scene.imageryLayers;
        let layerWMS = new Cesium.WebMapServiceImageryProvider({
          url: resource,
          layers: res.url,
          parameters: {
            transparent: true,
            format: "image/png",
            srs: "EPSG:4490",
            styles: "",
          },
          tileWidth: 512,
          tileHeight: 512,
        });
        layerWMS.name = res.cnName;
        //透明度
        var tdtAnnoLayer = imageryLayers.addImageryProvider(layerWMS);
        if (res.opacity) {
          tdtAnnoLayer.alpha = parseInt(res.opacity) / 100;
        }
        var layer2 = new Image({
          name: res.cnName,
          source: new ImageWMS({
            crossOrigin: "anonymous",
            url: resource,
            params: {
              FORMAT: "image/png",
              VERSION: "1.1.1",
              LAYERS: res.url,
            },
          }),
        });
        if (res.opacity) {
          layer2.setOpacity(parseInt(res.opacity) / 100);
        }
        window.map.addLayer(layer2);
      } else if (res.serveType == "WFS") {
        var url =
          res.resource +
          "?service=WFS&version=1.0.0&request=GetFeature&typeName=" +
          res.url +
          "&outputFormat=application%2Fjson";
        $.ajax({
          url: url,
          cache: false,
          async: true,
          success: function (data) {
            var datasource = Cesium.GeoJsonDataSource.load(data, {
              stroke: Cesium.Color.YELLOW,
              fill: Cesium.Color.YELLOW.withAlpha(0.1),
              alpha: 0.1,
              strokeWidth: 8,
              clampToGround: true, //是否贴地
            });
            datasource.then((data) => {
              data.name = res.cnName;
              window.Viewer.dataSources.add(data);
            });
          },
          error: function (data) {
            console.log("error");
          },
        });
        var vectorLayer = new VectorLayer({
          name: res.cnName,
          source: new VectorSource({
            url: url,
            format: new GeoJSON(),
          }),
        });
        window.map.addLayer(vectorLayer);
      } else if (res.serveType == "Tileset") {
        var tileset = Viewer.scene.primitives.add(
          new Cesium.Cesium3DTileset({
            name: res.cnName,
            url: modelUrl + "/" + res.url, //192.168.20.106,to4
            maximumScreenSpaceError: 64, // 最大屏幕空间错误:16
            maximumMemoryUsage: 768, // 最大内存:512
            dynamicScreenSpaceError: true, // 减少离相机较远的屏幕空间错误:false
            skipLevelOfDetail: true, // 在遍历时候跳过详情:false
          })
        );
        tileset.readyPromise.then(function (tileset) {
          tileset.id = res.cnName;
          tileset.layerId = res.id;
          Viewer.flyTo(tileset);
        });
      }
      if (std[0].length != 0) {
        this.setAddWmsLayer(std[0])
      }
    },
    setAddWmsLayer(res) {
      for (var i = 0; i < window.Viewer.imageryLayers._layers.length; i++) {
        var val_id = window.Viewer.imageryLayers._layers[i].imageryProvider.name;
        if (val_id == "Wms_Layer") {
          window.Viewer.imageryLayers.remove(
            window.Viewer.imageryLayers._layers[i]
          );
        }
      }
      var layers_ol = window.map.getAllLayers();
      for (var i in layers_ol) {
        var layerOl = layers_ol[i];
        if (layerOl.values_.name == "Wms_Layer") {
          window.map.removeLayer(layers_ol[i]); //显示图层
        }
      }
      var url = [];
      for (var i in res) {
        url.push(res[i].url)
      }
      url = url.reverse();
      var that = this;
      var getFeatureInfoFormat = new Cesium.GetFeatureInfoFormat("html", null, function (html) {
        that.getFeatureInfo(html)
      });
      window.layerWMS = new Cesium.WebMapServiceImageryProvider({
        url: geoServerURl,
        layers: url.toString(),
        getFeatureInfoParameters: { info_format: 'text/html' },
        enablePickFeatures: true,
        getFeatureInfoFormats: [getFeatureInfoFormat],
        parameters: {
          transparent: true,
          format: "image/png",
          srs: "EPSG:4490",
          styles: "",
        },
        tileWidth: 512,
        tileHeight: 512,
      });
      layerWMS.name = "Wms_Layer";
      window.Viewer.scene.imageryLayers.addImageryProvider(window.layerWMS);
      var layer2 = new Image({
        name: "Wms_Layer",
        source: new ImageWMS({
          crossOrigin: "anonymous",
          url: geoServerURl,
          params: {
            FORMAT: "image/png",
            VERSION: "1.1.1",
            LAYERS: url.toString(),
          },
        }),
      });
      if (res.opacity) {
        layer2.setOpacity(parseInt(res.opacity) / 100);
      }
      window.map.addLayer(layer2);
    },
    async getFeatureInfo(html) {
      var start = html.indexOf("<caption class=\"featureInfo\">") + "<caption class=\"featureInfo\">".length;
      var end = html.indexOf("</caption>");
      var tab = html.substr(start, end - start);
      start = html.lastIndexOf(tab) + tab.length + 1;
      end = html.indexOf("</td>", start);
      var gid = html.substr(start, end - start);
      if (gid && tab) {
        this.$store.state.pickoption = {
          gid: gid,
          name: tab.replaceAll("_", "")
        }
        this.$refs &&
          this.$refs.queryinfo &&
          this.$refs.queryinfo.close("queryinfo");
        this.$store.state.mapPopBoxFlag = "4";
        this.$refs &&
          this.$refs.queryinfo &&
          this.$refs.queryinfo.open("拾取分析", null,);
      }
    },
    showModelAttach() {
      if (this.$store.state.attachModel) {
        var name = this.$store.state.attachinfo.cnName;
@@ -2253,6 +2602,57 @@
    handleAttatchChange(val) {
      this.attacgSelection = val;
    },
    //拾取数据获取
    async getPickUpData(info) {
      let checkedLayers = JSON.parse(sessionStorage.getItem("checkedLayers"));
      let showPop = false;
      for (const item of checkedLayers) {
        let name = item.url.replaceAll("LF:", "");
        name = name.replaceAll("_", "");
        let params = {
          buffer: 10,
          limit: 20,
          name: name,
          wkt: `POINT (${info.lon} ${info.lat})`,
        }
        const res = await selectByBuffer(params);
        if (res.result && res.result.length > 0) {
          this.$store.state.mapPopBoxFlag = "4";
          this.$store.state.pickUpPointInfo = info;
          this.$refs &&
            this.$refs.queryinfo &&
            this.$refs.queryinfo.open("拾取分析", null,);
          showPop = true;
          break;
        }
      }
      if (!showPop) {
        this.$message.warning("暂无数据!");
      }
    },
    showPopBox() {
      if (this.$store.state.showPopBoxFlag == true) {
        this.$refs && this.$refs.queryinfo && this.$refs.queryinfo.close();
        this.$refs &&
          this.$refs.queryinfo &&
          this.$refs.queryinfo.open("属性", null, {
            close: () => {
              this.$store.state.showPopBoxFlag == false
              if (this.$store.state.primitLayer != null) {
                sgworld.Creator.DeleteObject(this.$store.state.primitLayer);
                this.$store.state.primitLayer = null;
              }
              if (window.Viewer.scene.primitives.length != 0) {
                window.Viewer.scene.primitives.removeAll();
              }
            },
          });
      }
    }
  },
  mounted() {
    this.measureData = new Map();
@@ -2269,7 +2669,9 @@
        this.menuChange(res);
      }
    });
    this.$bus.$on("showMenuLayer", ((res) => {
      this.setAddLayers(res);
    }));
    this.$store.state.showAllLayers = true;
    this.$store.state.layerMnage = false;
    this.$store.state.treeData = null;
@@ -2284,6 +2686,9 @@
    catch(newVal, oldVal) {
      this.showModelCatch();
    },
    popObj(newVal, oldVal) {
      this.showPopBox();
    }
  },
  computed: {
    Obj() {
@@ -2292,6 +2697,9 @@
    catch() {
      return this.$store.state.catModel;
    },
    popObj() {
      return this.$store.state.showPopBoxFlag;
    }
  },
};
</script>