管道基础大数据平台系统开发-【前端】-新系統界面
wulitaotao
2023-02-22 75b9ebdf49c6fe06623278a64aed87cc523c46df
src/views/Synthesis/LeftMenu.vue
@@ -35,6 +35,7 @@
</template>
<script>
import { transform } from 'ol/proj';
import mapinfo from '../Tools/mapinfo.vue';
import maplayer from '../Tools/maplayer.vue';
@@ -47,6 +48,7 @@
  FullScreen,
  ScaleLine,
  Rotate,
} from "ol/control.js"
import * as turf from '@turf/turf';
import { geometry } from '@turf/turf';
@@ -354,18 +356,18 @@
            css: 'twoMenu_imge86',
          },
          // {
          //   id: 'h9',
          //   label: 'synthesis.import1',
          //   name: '导入SHP',
          //   css: 'twoMenu_imge85',
          // },
          // {
          //   id: 'h10',
          //   label: 'synthesis.export1',
          //   name: '导出SHP',
          //   css: 'twoMenu_imge86',
          // },
          {
            id: 'h9',
            label: 'synthesis.import1',
            name: '导入SHP',
            css: 'twoMenu_imge85',
          },
          {
            id: 'h10',
            label: 'synthesis.export1',
            name: '导出SHP',
            css: 'twoMenu_imge86',
          },
          {
@@ -403,26 +405,12 @@
      scaleLine: null,
      Excavation: false,
      entityaLayers: [],
      isMenuFlag: null,
    };
  },
  methods: {
    //二級菜单点击切换
    setChangeTwoMenu(res) {
      //清除绘制图形对象
      // sgworld.Creator.SimpleGraphic.clear();
      if (window.Viewer.scene.primitives.length != null) {
        window.Viewer.scene.primitives.removeAll();
      }
      if (this.$store.state.primitLayer != null) {
        sgworld.Creator.DeleteObject(this.$store.state.primitLayer);
        this.$store.state.primitLayer = null;
      }
      //关闭打开的信息窗体
      this.showTwoMenuFlag = res.id;
      this.$store.state.mapMenuBoolean = false;
      this.$store.state.mapMenuBoxFlag = null;
      this.$store.state.mapPopBoolean = false;
@@ -432,12 +420,37 @@
        window.model.deleteObject();
        window.model = null;
      }
      sgworld.Analysis.clearCurtainContrast();
      if (this.isMenuFlag == "d") {
        this.clearAllAnalsy();
      }
      if (this.isMenuFlag !=val) {
        sgworld.Creator.SimpleGraphic.clear();
        this.isMenuFlag = val;
        if (this.entityaLayers.length != 0) {
          for (var i in this.entityaLayers) {
            sgworld.Viewer.entities.remove(this.entityaLayers[i]);
          }
          this.entityaLayers = [];
        }
        for (var i in this.$store.state.queryInfo) {
          sgworld.Viewer.entities.remove(this.$store.state.queryInfo[i]);
        }
        this.$store.state.queryInfo = [];
        if (this.$store.state.primitLayer != null) {
          sgworld.Viewer.entities.remove(this.$store.state.primitLayer);
          sgworld.Creator.DeleteObject(this.$store.state.primitLayer);
          this.$store.state.primitLayer = null;
        }
      }
      this.showTwoMenuFlag = res.id;
      switch (val) {
        case 'a': //图层管理
          this.setCoverage(res.id);
          break;
        case 'b':
@@ -592,7 +605,7 @@
          var north = Cesium.Math.toDegrees(entities[i].rectangle.coordinates.getValue().north);
          var west = Cesium.Math.toDegrees(entities[i].rectangle.coordinates.getValue().west);
          var south = Cesium.Math.toDegrees(entities[i].rectangle.coordinates.getValue().south);
          var line = turf.lineString([[east, north], [west, south]])
          var line = turf.polygon([[[east, north], [west, north], [west, south], [east, south], [east, north]]])
          wkt = this.$wkt.convert(line.geometry)
          var fill = entities[i].rectangle._material._color._value;
          fillColor = fill.red + ',' + fill.green + ',' + fill.blue;
@@ -720,45 +733,91 @@
          console.error(e);
        }
      });
      document.getElementById("shpFile").value = ""
    },
    showShpEntity(res) {
      for (var i in res) {
        var wkt = this.$wkt.parse(res[i].wkt);
        var fillColor = res[i].fillColor.split(",");
       var color = new Cesium.Color(fillColor[0], fillColor[1], fillColor[2], res[i].opacity)
        var color = new Cesium.Color(parseFloat(fillColor[0]), parseFloat(fillColor[1]), parseFloat(fillColor[2]), res[i].opacity);
        var name = res[i].name
        switch (res[i].type) {
          case 'rectangle':
            debugger
            break;
          case 'point':
            debugger
            break;
          case 'polygon':
            var std = [];
            var geo = wkt.coordinates[0];
            for (var i in geo) {
              std.push(geo[i][0])
              std.push(geo[i][1])
            }
            const entity = Viewer.entities.add({
              name: 'Wyoming',
            var entity = Viewer.entities.add({
              name: name,
              polygon: {
                hierarchy: Cesium.Cartesian3.fromDegreesArray(std),
                //height : 100000,
                material:color,
                material: color,
                outline: true,
                outlineColor: color,
              }
            })
            this.entityaLayers.push(entity)
            break;
          case 'point':
            let point = Viewer.entities.add({
              name: name,
              position: Cesium.Cartesian3.fromDegrees(wkt.coordinates[0], wkt.coordinates[1]), //经纬度转世界坐标
              point: {
                show: true,
                color: color,
                pixelSize: 10,
                outlineColor: color,
                outlineWidth: 3,
                heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
                disableDepthTestDistance: Number.POSITIVE_INFINITY,
              },
            });
            this.entityaLayers.push(point)
            break;
          case 'polyline':
            debugger
            var std = [];
            var geo = wkt.coordinates;
            for (var i in geo) {
              std.push(geo[i][0])
              std.push(geo[i][1])
            }
            let line = Viewer.entities.add({
              name: name,
              polyline: {
                //经纬度数组转世界坐标,带高度的话是fromDegreesArrayHeights
                positions: Cesium.Cartesian3.fromDegreesArray(std),
                width: 10,
                material: color,
                clampToGround: true,
              }
            })
            this.entityaLayers.push(line)
            break;
          case 'label':
            debugger
            const label = Viewer.entities.add({
              position: Cesium.Cartesian3.fromDegrees(wkt.coordinates[0], wkt.coordinates[1]),
              label: {
                text: name,
                fillColor: color,
                font: '28px',
                horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
                verticalOrigin: Cesium.VerticalOrigin.TOP,
                heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
                disableDepthTestDistance: Number.POSITIVE_INFINITY,
              },
            })
            this.entityaLayers.push(label)
            break;
        }
      }
@@ -1027,6 +1086,23 @@
          break;
      }
    },
    clearAllAnalsy() {
      // switch (this.showTwoMenuFlag) {
      //   case 'd1':
      //     that.isolineFlag = false;
      //     elevationTool.tf = that.isolineFlag;
      //     elevationTool.render();
      //     break;
      //   case 'd2':
      //     that.isslopeFlag = false;
      //     elevationTool.type = 'none';
      //     elevationTool.render();
      //     break;
      // }
    },
    setAnalsy(res) {
      //this.$refs && this.$refs.queryinfo && this.$refs.queryinfo.close("queryinfo");
      var that = this;
@@ -1038,12 +1114,14 @@
          break;
        case 'd2':
          that.isslopeFlag = !that.isslopeFlag;
          window.PDelevationTool= new SmartEarth.ElevationTool(sgworld);//全局变量
          if (that.isslopeFlag == true) {
            elevationTool.type = 'slope';
            PDelevationTool.type = 'slope';
            PDelevationTool.tf = this.checked;
          } else {
            elevationTool.type = 'none';
            PDelevationTool.type = 'none';
          }
          elevationTool.render();
          PDelevationTool.render();
          break;
        case 'd3':
          var value = {
@@ -1126,28 +1204,23 @@
          }
          break;
        case 'd10':
          if (window.TerrainFlattening) {
            window.TerrainFlattening.remove();
            window.TerrainFlattening = null;
          } else {
            sgworld.Creator.createSimpleGraphic(
              'polygon',
              {
                clampToGround: true,
              },
              function (entity) {
                var positions = entity.polygon.hierarchy.getValue().positions;
                sgworld.Creator.SimpleGraphic.remove(entity.id);
                window.TerrainFlattening =
                  sgworld.Creator.createTerrainModifier(
                    '地形压平',
                    positions,
                    10,
                    {}
                  );
              }
            );
          if(window.DXTerrainFlattening!=null){
            DXTerrainFlattening.remove();
          }
          sgworld.Creator.createSimpleGraphic(
                'polygon',
                {
                    clampToGround: true,
                },
                function (entity) {
                    let   positions = entity.polygon.hierarchy.getValue().positions;
                    console.log(positions);
                    sgworld.Creator.SimpleGraphic.remove(entity.id);
                    window.DXTerrainFlattening = sgworld.Creator.createTerrainModifier("地形压平", positions, 10, {});
                }
            );
          break;
        case 'd11':
@@ -1164,11 +1237,11 @@
          break;
        case "d12":
          if (window.Excavation) {
            window.Excavation.deleteObject()
            window.Excavation = null
          if (window.TSExcavation!=null) {
            window.TSExcavation.deleteObject()
            window.TSExcavation = null
          } else {
            window.Excavation = sgworld.Analysis.createSightLine({
            window.TSExcavation = sgworld.Analysis.createSightLine({
              type: "default",
            })
          }
@@ -1455,7 +1528,7 @@
    font-size: 16px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    border: 1px solid rgba(0, 0, 0, 0);
    padding: 10px;
    min-width: 100px;
    margin-left: 10px;