管道基础大数据平台系统开发-【前端】-新系統界面
src/views/Tools/LayerTree.vue
@@ -735,30 +735,6 @@
      } else {
        this.childOption.push(source)
      }
      // let cloneData = JSON.parse(JSON.stringify(source)); // 对源数据深度克隆
      // var std = [];
      // if (cloneData.children) {
      //   var child = cloneData.children;
      //   child.filter((father) => {
      //     if (father.children) {
      //       father.father
      //     } else {
      //     }
      //   })
      // }
      // cloneData.filter((father) => {
      //   // 循环所有项
      //   console.log(father)
      //   // let branchArr = cloneData.filter((child) => father.id == child.pid); // 对比ID,分别上下级菜单,并返回数据
      //   // branchArr.length > 0 ? (father.children = branchArr) : ""; // 给父级添加一个children属性,并赋值
      //   // // 属于同一对象问题,例如:令 a=b、c=1 ,然后再令 b.c=c , 那么 a.c=b.c=c=1 ;同理,后续令 c.d=2 ,那么 a.c.d 也是=2;
      //   // // 由此循环多次后,就能形成相应的树形数据结构
      //   // return father.pid == 0; // 返回一级菜单
      // });
    },
    setAddLayers(res) {
@@ -846,6 +822,7 @@
        } else {
          url = modelUrl + "/" + res.url
        }
        var tileset = Viewer.scene.primitives.add(
          new Cesium.Cesium3DTileset({
            name: res.cnName,
@@ -856,11 +833,14 @@
            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;
          this.getTilesetArgs(tileset, res);
          //
        });
        window.model = tileset
      } else if (res.serveType == "TMS") {
@@ -901,6 +881,23 @@
      }
    },
    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) {
      const data = await comprehensive_selectPubById({ id: res.pubid })
      if (data.code != 200) {
@@ -927,7 +924,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;
@@ -940,6 +945,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)); // 对源数据深度克隆