管道基础大数据平台系统开发-【前端】-新系統界面
584911253@qq.com
2023-03-28 c3c23814c1802121af66feecdf4238f1d60c4651
src/views/Tools/LayerTree.vue
@@ -90,6 +90,13 @@
      </div>
      <div
        class="edit"
        @click="pellucidity()"
        v-if="showlocal"
      >
        <i class="el-icon-tickets"></i>&nbsp;&nbsp;透明度
      </div>
      <div
        class="edit"
        @click="histogram()"
        v-show="shwoHistogram"
      >
@@ -397,6 +404,13 @@
            );
          }
        }
        var list = this.$store.state.setAlphaList;
        for (var i = 0; i < list.length; i++) {
          if (list[i].name == label) {
            list.splice(i, 1)
          }
        }
      }
      var layers_ol = window.map.getAllLayers();
      for (var i in layers_ol) {
@@ -420,6 +434,22 @@
    },
    //模型设置透明度
    pellucidity() {
      this.foo();
      this.menuVisible = false
      var tile = this.currentData
      for (var j in Viewer.scene.primitives._primitives) {
        if (Viewer.scene.primitives._primitives[j].id == tile.cnName) {
          this.$store.state.setAlphaDity = this.currentData;
          this.$bus.$emit("showPellucidity", true);
          break;
        }
      }
    },
    //模型定位
    positioning() {
      this.menuVisible = false
@@ -661,6 +691,12 @@
              Viewer.scene.primitives.remove(Viewer.scene.primitives._primitives[j])
            }
          }
          var list = this.$store.state.setAlphaList;
          for (var i = 0; i < list.length; i++) {
            if (list[i].name == tile.cnName) {
              list.splice(i, 1)
            }
          }
        }
      }
@@ -668,7 +704,7 @@
      // if (checked.checkedKeys) {
      //   for (var i in result) {
      //
      //
      //   }
      // } else {
@@ -822,6 +858,7 @@
        } else {
          url = modelUrl + "/" + res.url
        }
        var tileset = Viewer.scene.primitives.add(
          new Cesium.Cesium3DTileset({
            name: res.cnName,
@@ -832,12 +869,40 @@
            skipLevelOfDetail: true, // 在遍历时候跳过详情:false
          })
        );
        tileset.readyPromise.then((tileset) => {
          tileset.id = res.cnName;
          tileset.layerId = res.id;
          this.tileSet(tileset, parseFloat(res.elev))
          Viewer.flyTo(tileset);
          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);
        });
        this.$store.state.setAlphaList.push({
          name: res.cnName,
          alpha: 1
        })
        window.model = tileset
      } else if (res.serveType == "TMS") {
        var url = res.url;
@@ -869,12 +934,28 @@
          url: url[0],
          layers: url[1]
        }, "0", undefined, true, "");
        this.mptLayer.push(layer)
        setTimeout(() => {
          this.setChangeWMS();
        }, 500);
      }
    },
    async getTilesetArgs(tileset, res) {
      if (res.pubid > 0) {
        const data = await comprehensive_selectPubById({ id: res.pubid })
        if (data.code != 200) {
        } else {
          this.reload(tileset, data.result.json)
        }
      } else {
        this.tileSet(tileset, parseFloat(res.elev))
      }
    },
    async setQueryPubid(res) {
@@ -903,7 +984,15 @@
        this.setChangeWMS();
      }
    },
    reload(tileset, res) {
      var vm = JSON.parse(res)
      var pos = Cesium.Cartesian3.fromDegrees(vm.lon, vm.lat, vm.height);
      var converter = Cesium.Transforms.eastNorthUpToFixedFrame;
      var hpr = new Cesium.HeadingPitchRoll(Cesium.Math.toRadians(vm.yaw), 0, 0);
      var matrix = Cesium.Transforms.headingPitchRollToFixedFrame(pos, hpr, Cesium.Ellipsoid.WGS84, converter);
      tileset._root.transform = matrix;
      Viewer.flyTo(tileset);
    },
    tileSet(tileset, height) {
      //3dtile模型的边界球体
      var boundingSphere = tileset.boundingSphere;
@@ -916,6 +1005,7 @@
      var translation = Cesium.Cartesian3.subtract(Cartesian3_offset, Cartesian3_original, new Cesium.Cartesian3());
      //修改模型矩阵
      tileset.modelMatrix = Cesium.Matrix4.fromTranslation(translation);
      Viewer.flyTo(tileset);
    },
    setTreeData(source) {
      let cloneData = JSON.parse(JSON.stringify(source)); // 对源数据深度克隆