管道基础大数据平台系统开发-【前端】-新系統界面
Surpriseplus
2023-05-22 ff5731b6a22c9f2451dc8065d2fa32153bdd4a1a
src/views/Tools/LayerTree.vue
@@ -271,7 +271,6 @@
      mptLayer: [],
      optionts: [],
      proValue: null,
      setCheeckedLayer: []
    };
  },
  methods: {
@@ -325,10 +324,16 @@
      this.currentNode = Node;
      this.$store.state.propertiesName = this.currentData;
      if (this.currentData.serveType == "Tileset") {
      this.showModelAttach = false;
      this.shwoTitle = false;
      this.menuVisible = true;
      if (this.currentData.serveType == 'TMS') {
        this.shwoTitle = true
      } else if (this.currentData.serveType == "Tileset" || this.currentData.serveType == "3DML") {
        this.showModelAttach = true;
      } else {
        this.showModelAttach = false;
      } else if (this.currentData.serveType == "DEM" || this.currentData.serveType == "DOM" || this.currentData.serveType == "MPT") {
        this.menuVisible = false;
      }
      if (this.currentData.enName == "s_explorationpoint") {
        this.shwoHistogram = true;
@@ -341,7 +346,7 @@
      } else {
        this.firstLevel = true;
      }
      if (Node.data.children == null && Node.data.serveType == "Tileset") {
      if (Node.data.children == null && Node.data.serveType == "Tileset" || Node.data.serveType == "3DML") {
        this.showlocal = true;
        this.showopaque = true;
      } else if (Node.data.children == null && Node.data.serveType == "TMS") {
@@ -351,7 +356,7 @@
        this.showlocal = false;
        this.showopaque = false;
      }
      this.menuVisible = true;
      this.$refs.card.$el.style.left = event.pageX + 20 + "px";
      this.$refs.card.$el.style.top = event.pageY + "px";
@@ -493,8 +498,7 @@
    //模型定位
    async positioning() {
      this.menuVisible = false
      if (this.currentData.serveType == 'Tileset') {
      if (this.currentData.serveType == 'Tileset' || this.currentData.serveType == '3DML') {
        for (var i in Viewer.scene.primitives._primitives) {
          if (
            Viewer.scene.primitives._primitives[i].id == this.currentData.cnName
@@ -511,7 +515,6 @@
          });
        }
      }
    },
    // 编辑节点
    editNode(data) {
@@ -601,6 +604,9 @@
            case 'WFS':
              listWFS.push(this.childOption[i])
              break;
            case '3DML':
              listTileset.push(this.childOption[i])
              break;
            case 'Tileset':
              listTileset.push(this.childOption[i])
              break;
@@ -610,7 +616,6 @@
            case 'TMS':
              listTMS.push(this.childOption[i])
              break;
          }
        }
        this.setChangeWMS(listWMS, checked);
@@ -621,7 +626,7 @@
      } else if (data.type == 2) {
        if (data.serveType == "WMS") {
          this.setChangeWMS([data], checked);
        } else if (data.serveType == "Tileset") {
        } else if (data.serveType == "Tileset" || data.serveType == "3DML") {
          this.setChangeTileset([data], checked);
        } else if (data.serveType == "TMS") {
          this.setChangeTMS([data], checked);
@@ -903,7 +908,7 @@
          }),
        });
        window.map.addLayer(vectorLayer);
      } else if (res.serveType == "Tileset") {
      } else if (res.serveType == "Tileset" || res.serveType == "3DML") {
        var url;
        if (res.url.indexOf("{host}") != -1) {
          url = res.url.replace("{host}", iisHost);
@@ -923,33 +928,35 @@
        );
        tileset.readyPromise.then((tileset) => {
          tileset.id = res.cnName;
          tileset.layerId = res.id;
          tileset.pubid = res.pubid;
          // Cesium.Matrix4.equals(a,b)判断两个四维矩阵是否相等
          // 整个根节点模型矩阵,该tileSet=>世界坐标系
          // 单位矩阵,对角线值为1.0的4*4矩阵
          if (!Cesium.Matrix4.equals(tileset.root.transform, Cesium.Matrix4.IDENTITY)) {
            // 获取模型的世界坐标(笛卡尔)
            // Cesium.Matrix4.getTranslation 通过仿射变换矩阵获取该tileSet的世界坐标
            const transformCenter = Cesium.Matrix4.getTranslation(
              tileset.root.transform,
              new Cesium.Cartesian3()
            );
            // 将笛卡尔坐标转换为WGS84经纬度坐标(模型的)
            const transformCartographic = Cesium.Cartographic.fromCartesian(
              transformCenter
            );
            // 将笛卡尔坐标转换为WGS84经纬度坐标(截面的)
            const boundingSphereCartographic = Cesium.Cartographic.fromCartesian(
              tileset.boundingSphere.center
            );
            const height = boundingSphereCartographic.height - transformCartographic.height;
            // 从一个Cartesian3对象生成Matrix4变换矩阵(裁切面的)
            window.modelHeight = height;
          } else window.modelHeight = 0;
          this.getTilesetArgs(tileset, res);
          if (res.serveType != '3DML') {
            // Cesium.Matrix4.equals(a,b)判断两个四维矩阵是否相等
            // 整个根节点模型矩阵,该tileSet=>世界坐标系
            // 单位矩阵,对角线值为1.0的4*4矩阵
            if (!Cesium.Matrix4.equals(tileset.root.transform, Cesium.Matrix4.IDENTITY)) {
              // 获取模型的世界坐标(笛卡尔)
              // Cesium.Matrix4.getTranslation 通过仿射变换矩阵获取该tileSet的世界坐标
              const transformCenter = Cesium.Matrix4.getTranslation(
                tileset.root.transform,
                new Cesium.Cartesian3()
              );
              // 将笛卡尔坐标转换为WGS84经纬度坐标(模型的)
              const transformCartographic = Cesium.Cartographic.fromCartesian(
                transformCenter
              );
              // 将笛卡尔坐标转换为WGS84经纬度坐标(截面的)
              const boundingSphereCartographic = Cesium.Cartographic.fromCartesian(
                tileset.boundingSphere.center
              );
              const height = boundingSphereCartographic.height - transformCartographic.height;
              // 从一个Cartesian3对象生成Matrix4变换矩阵(裁切面的)
              window.modelHeight = height;
            } else window.modelHeight = 0;
            this.getTilesetArgs(tileset, res);
          }
        });
        this.$store.state.setAlphaList.push({
          name: res.cnName,
@@ -973,7 +980,6 @@
            })
          );
          layer.name = res.cnName;
          layer.id = "TMS"
          this.setChangeWMS();
        }
@@ -1001,7 +1007,12 @@
        if (data.code != 200) {
        } else {
          this.reload(tileset, data.result.json)
          if (res.serveType != '3DML') {
            this.reload(tileset, data.result.json)
          } else {
            this.tileSet(tileset, parseFloat(res.elev))
          }
        }
      } else {
        this.tileSet(tileset, parseFloat(res.elev))
@@ -1045,12 +1056,12 @@
        layer.name = res.cnName;
        // if (data.result.geom) {
        //   var wkt = this.$wkt.parse(data.result.geom);
        //   Viewer.camera.flyTo({
        //     destination: Cesium.Cartesian3.fromDegrees(wkt.coordinates[1], wkt.coordinates[0], 2000),
        //   });
        // }
        if (data.result.geom) {
          // var wkt = this.$wkt.parse(data.result.geom);
          // Viewer.camera.flyTo({
          //   destination: Cesium.Cartesian3.fromDegrees(wkt.coordinates[1], wkt.coordinates[0], 2000),
          // });
        }
        this.setChangeWMS();
      }
    },
@@ -1186,20 +1197,9 @@
      }
      this.$refs.tree.setCheckedKeys(std);
    },
    getNewTree(obj, result) {
      for (const i in obj) {
        result.push(obj[i])
        if (obj[i].children && obj[i].children.length > 0) {
          this.getNewTree(obj[i].children, result)
        }
      }
      return result
    },
    // 查询
    filterNode(value, data) {
      if (!value) return true;
      return data.cnName.indexOf(value) !== -1;
    },
@@ -1214,6 +1214,7 @@
            return rs
          }
        })
        var val = this.$store.state.oldTree.filter(rs => {
          if (rs.enName == st_code[0].code) {
            return rs
@@ -1242,30 +1243,37 @@
          }
        }
        this.cannelTerrainLayer();
        this.setTerrainMptLayer();
        //清空图层树选中状态
        this.$refs.tree.setCheckedKeys([]);
        if (val.length > 0) {
          if (val[0].type == 1 && val[0].isProject == 1) {//项目分类
            var std = [];
            var std_check = [];
            for (var i in val) {
              var std_val = this.getNewTree([this.$refs.tree.getNode(val[i].id).data], [])
              for (var j in std_val) {
                std.push(std_val[j])
                std_check.push(std_val[j])
              }
            }
            var value = this.$store.state.isProjectLayer;
            for (var i in value) {
              std.push(value[i])
              std_check.push(value[i])
            }
            this.setProjectLayer(std);
            this.setProjectLayer(std_check);
          } else {
            this.setChangeProLayer();
          }
        } else {
          this.setChangeProLayer();
        }
      } else {
        this.removeAllLayer();
        this.$store.state.pigCode = null;
@@ -1274,57 +1282,8 @@
        for (var i in this.setCheeckedLayer) {
          std.push(this.$refs.tree.getNode(this.setCheeckedLayer[i]).data)
        }
        this.setProjectLayer(std);
      }
    },
    setProjectLayer(res) {
      var layerid = [];
      for (var i in res) {
        layerid.push(res[i].id)
      }
      this.$refs.tree.setCheckedKeys(layerid);
      // var value = this.$refs.tree.getCheckedNodes();
      // this.$bus.$emit("showMenuLayer", value);
      var listWMS = [];
      var listWFS = [];
      var listTileset = [];
      var listTMS = [];
      var listMpt = [];
      for (var i in res) {
        if (res[i].type == 2) {
          switch (res[i].serveType) {
            case 'WMS':
              listWMS.push(res[i])
              break;
            case 'WFS':
              listWFS.push(res[i])
              break;
            case 'Tileset':
              listTileset.push(res[i])
              break;
            case 'Mpt':
              listMpt.push(res[i])
              break;
            case 'TMS':
              listTMS.push(res[i])
              break;
          }
        }
      }
      // this.setChangeProLayer();
      this.setChangeWMS(listWMS, true);
      this.setChangeWFS(listWFS, true);
      this.setChangeTileset(listTileset, true);
      this.setChangeTMS(listTMS, true);
      this.setChangeMpt(listMpt, true);
    },
    removeAllLayer() {
      for (var j in Viewer.scene.primitives._primitives) {
@@ -1349,12 +1308,87 @@
      }
      this.mptLayer = [];
    },
    setProjectLayer(res) {
      var layerid = [];
      for (var i in res) {
        layerid.push(res[i].id)
      }
      this.$refs.tree.setCheckedKeys(layerid);
      // var value = this.$refs.tree.getCheckedNodes();
      // this.$bus.$emit("showMenuLayer", value);
      var listWMS = [];
      var listWFS = [];
      var listTileset = [];
      var listTMS = [];
      var listMpt = [];
      for (var i in res) {
        if (res[i].type == 2) {
          switch (res[i].serveType) {
            case 'WMS':
              listWMS.push(res[i])
              break;
            case 'WFS':
              listWFS.push(res[i])
              break;
            case '3DML':
            case 'Tileset':
              listTileset.push(res[i])
              break;
            case 'Mpt':
              listMpt.push(res[i])
              break;
            case 'TMS':
              listTMS.push(res[i])
              break;
          }
        }
      }
      // this.setChangeProLayer();
      this.setChangeWMS(listWMS, true);
      this.setChangeWFS(listWFS, true);
      this.setChangeTileset(listTileset, true);
      this.setChangeTMS(listTMS, true);
      this.setChangeMpt(listMpt, true);
    },
    getNewTree(obj, result) {
      for (const i in obj) {
        console.log(obj[i].cnName)
        result.push(obj[i])
        if (obj[i].children && obj[i].children.length > 0) {
          this.getNewTree(obj[i].children, result)
        }
      }
      return result
    },
    cannelTerrainLayer() {
      //清空地形
      if (window.terrainMptLayer) {
        window.terrainMptLayer.deleteObject();
        window.terrainMptLayer = null;
      }
      if (window.terrainDemLayer) {
        Viewer.terrainProvider = new Cesium.EllipsoidTerrainProvider();
        window.terrainDemLayer = null;
      }
    },
    setTerrainMptLayer() {
      // //默认地形MPT
      // var option = {
      //   url: window.sceneConfig.SGUrl,
      //   layerName: window.sceneConfig.mptName,
      //   requestVertexNormals: true,
      // };
      // window.terrainMptLayer = sgworld.Creator.sfsterrainprovider("", option, "", true, "");
      window.terrainDemLayer = new Cesium.CesiumTerrainProvider({
        // url: LFData + '/3d/terrain/dem20230321'
        url: demLayer
      });
      Viewer.terrainProvider = window.terrainDemLayer
    },
    setChangeProLayer() {
      var value = this.$store.state.isProjectLayer;
      if (value.length != 0) {
        var std = [];