月球大数据地理空间分析展示平台-【前端】-月球2期前端
surprise
2023-10-17 25ad6779e118f2f01e9cda45c67f7b27d55a984a
src/assets/js/Map/menuTool.js
@@ -463,154 +463,6 @@
      }
    });
  },
  getEntityAttribute(type, res) {
    var obj = {}
    store.state.temporaryLayer = null;
    if (type == 'point') {
      var mataColor = res.point.color._value;
      var outlineColor = res.point.outlineColor._value;
      obj = {
        id: (new Date()).getTime(),
        cnName: res.name,
        metaAlpha: mataColor.alpha,
        outlineAlpha: outlineColor.alpha,
        metaColor: this.colorRgbToHex('rgb(' + (mataColor.red * 255) + ',' + (mataColor.green * 255) + ',' + (mataColor.blue * 255) + ')'),
        outlineColor: this.colorRgbToHex('rgb(' + (outlineColor.red * 255) + ',' + (outlineColor.green * 255) + ',' + (outlineColor.blue * 255) + ')'),
        pixelSize: res.point.pixelSize._value,
        outlineWidth: res.point.outlineWidth._value,
        near: res.point._distanceDisplayCondition._value.near,
        far: res.point._distanceDisplayCondition._value.far,
        geometry: this.setCartesianToEightFour(res.position.getValue()),
        type: 'point',
        shpType: 'temporaryLayer',
        layerType: '基本点',
      }
    } else if (type == 'label') {
      var mataColor = res.label.fillColor._value;
      var outlineColor = res.label.outlineColor._value;
      var backColor = res.label.backgroundColor._value;
      obj = {
        id: (new Date()).getTime(),
        cnName: res.name,
        text: res.label.text._value,
        font: res.label.font._value,
        metaAlpha: mataColor.alpha,
        outlineAlpha: outlineColor.alpha,
        backAlpha: backColor.alpha,
        backColor: this.colorRgbToHex('rgb(' + (backColor.red * 255) + ',' + (backColor.green * 255) + ',' + (backColor.blue * 255) + ')'),
        metaColor: this.colorRgbToHex('rgb(' + (mataColor.red * 255) + ',' + (mataColor.green * 255) + ',' + (mataColor.blue * 255) + ')'),
        outlineColor: this.colorRgbToHex('rgb(' + (outlineColor.red * 255) + ',' + (outlineColor.green * 255) + ',' + (outlineColor.blue * 255) + ')'),
        scale: res.label.scale._value,
        verticalOrigin: Cesium.VerticalOrigin.CENTER,//垂直位置
        horizontalOrigin: Cesium.HorizontalOrigin.CENTER,//水平位置
        outlineWidth: res.label.outlineWidth._value,
        showBackground: false,
        outline: true,
        near: res.label._distanceDisplayCondition._value.near,
        far: res.label._distanceDisplayCondition._value.far,
        geometry: this.setCartesianToEightFour(res.position.getValue()),
        type: 'label',
        shpType: 'temporaryLayer',
        layerType: '文本点',
        heightReference: true,
        checked: true
      }
    } else if (type == 'polygon') {
      var mataColor = res.polygon.material.color._value;
      var outlineColor = res.polygon.outlineColor._value;
      var val = res.polygon.hierarchy.getValue().positions;
      var geom = [];
      for (var i in val) {
        var coord = this.setCartesianToEightFour(val[i])
        geom.push(coord.lng, coord.lat)
      }
      obj = {
        id: (new Date()).getTime(),
        cnName: res.name,
        metaAlpha: mataColor.alpha,
        outlineAlpha: outlineColor.alpha,
        metaColor: this.colorRgbToHex('rgb(' + (mataColor.red * 255) + ',' + (mataColor.green * 255) + ',' + (mataColor.blue * 255) + ')'),
        outlineColor: this.colorRgbToHex('rgb(' + (outlineColor.red * 255) + ',' + (outlineColor.green * 255) + ',' + (outlineColor.blue * 255) + ')'),
        near: res.polygon._distanceDisplayCondition._value.near,
        far: res.polygon._distanceDisplayCondition._value.far,
        geometry: geom,
        type: 'polygon',
        shpType: 'temporaryLayer',
        layerType: '多边形',
        heightReference: true,
        checked: true
      }
    } else if (type == 'polyline') {
      var mataColor = res.polyline.material.color._value;
      var outlineColor = res.polyline.material.outlineColor._value;
      var val = res.polyline.positions.getValue();
      var geom = [];
      for (var i in val) {
        var coord = this.setCartesianToEightFour(val[i])
        geom.push([coord.lng, coord.lat])
      }
      obj = {
        id: (new Date()).getTime(),
        cnName: res.name,
        metaColor: this.colorRgbToHex('rgb(' + (mataColor.red * 255) + ',' + (mataColor.green * 255) + ',' + (mataColor.blue * 255) + ')'),
        outlineColor: this.colorRgbToHex('rgb(' + (outlineColor.red * 255) + ',' + (outlineColor.green * 255) + ',' + (outlineColor.blue * 255) + ')'),
        near: res.polyline._distanceDisplayCondition._value.near,
        far: res.polyline._distanceDisplayCondition._value.far,
        metaAlpha: mataColor.alpha,
        outlineAlpha: outlineColor.alpha,
        outlineWidth: res.polyline.material.outlineWidth._value,
        width: res.polyline.width,
        geometry: geom,
        type: 'polyline',
        shpType: 'temporaryLayer',
        layerType: '线',
        heightReference: true,
        checked: true
      }
    } else if (type === 'rectangle') {
      var mataColor = res.rectangle.material.color._value;
      var outlineColor = res.rectangle.outlineColor._value;
      var west = Cesium.Math.toDegrees(
        res.rectangle._coordinates.getValue().west
      ); // 根据弧度获取到经度
      var east = Cesium.Math.toDegrees(
        res.rectangle._coordinates.getValue().east
      ); // 根据弧度获取到纬度
      var north = Cesium.Math.toDegrees(
        res.rectangle._coordinates.getValue().north
      ); // 根据弧度获取到经度
      var south = Cesium.Math.toDegrees(
        res.rectangle._coordinates.getValue().south
      ); // 根据弧度获取到纬度
      var geom = [west, south, east, north]
      obj = {
        id: (new Date()).getTime(),
        cnName: res.name,
        metaColor: this.colorRgbToHex('rgb(' + (mataColor.red * 255) + ',' + (mataColor.green * 255) + ',' + (mataColor.blue * 255) + ')'),
        outlineColor: this.colorRgbToHex('rgb(' + (outlineColor.red * 255) + ',' + (outlineColor.green * 255) + ',' + (outlineColor.blue * 255) + ')'),
        near: res.rectangle._distanceDisplayCondition._value.near,
        far: res.rectangle._distanceDisplayCondition._value.far,
        metaAlpha: mataColor.alpha,
        outlineAlpha: outlineColor.alpha,
        outlineWidth: res.rectangle.outlineWidth._value,
        rotation: 0,
        geometry: geom,
        type: 'rectangle',
        shpType: 'temporaryLayer',
        layerType: '矩形',
        heightReference: true,
      }
    }
    store.state.temporaryLayer = obj;
  },
  colorRgbToHex(str) {