yxl
2025-02-13 92f7479c89d8573d954e5bf37a464c1bbef396eb
src/assets/js/mapSetFunc.js
@@ -13,11 +13,28 @@
      case "aroundPoi":
        this.creatAroundPoi(res);
        break;
      case "getStrike":
        this.creatAroundPoi(res);
        break;
      case "queryRelationship":
        this.creatQueryRelationship(res);
        break;
      case "queryMeta":
        this.creatQueryMeta(res);
        break;
      case "aroundPoi_2":
        // this.addWfsLayer(res);
        this.addTetrahedron(res);
        break;
      case "getParam":
        this.addTetrahedron(res);
        break;
      case "getTAIWAN":
        this.addWfsLayer(res);
        // this.addTetrahedron(res);
        break;
      case "attackentity":
        this.addPolyLine(res);
        break;
    }
  },
@@ -37,16 +54,19 @@
    this.setModelChangeColor(colors);
  },
  setModelChangeColor(res) {
    const modelLayer = mapServer.listData.filter((res) => {
      if (res.name == config.modelLayer) {
        return res;
    console.log('mapServer.listData', mapServer.listData, config.modelLayer);
    const modelLayer = mapServer.listData.filter((obj) => {
      if (obj.name == config.modelLayer) {
        return obj;
      }
    });
    if (modelLayer.length <= 0) return;
    earthCtrl.userScene.flyTo(modelLayer[0].layer);
    modelLayer[0].layer.style = new Cesium.Cesium3DTileStyle({
      color: {
        evaluateColor: (feature) => {
          const id = feature.getProperty("id");
          console.log("id**********", id);
          const color = res.filter((item) => {
            if (item.ids.indexOf(id) > -1) {
              return item;
@@ -153,7 +173,7 @@
  },
  creatPoiMap(res) {
    res.data.forEach((poi,index) => {
    res.data.forEach((poi, index) => {
      // const poi = res.data[0];
      console.log('poi------', poi)
      const label = earthCtrl.factory.createLabel({
@@ -225,6 +245,20 @@
    return name;
  },
  creatAroundPoi(res) {
    let colors = [];
    res.data.forEach((element) => {
      colors.push({
        name: element.type,
        color: element.color,
        ids: element.list
      });
    })
    console.log('colors----', colors);
    store.state.setListColor = colors;
    store.state.showLenged = true;
    this.setModelChangeColor(colors);
  },
  creatAroundPoi1111(res) {
    const poi = res.data;
    var std = [];
    var feature = {
@@ -306,6 +340,185 @@
      }
    });
  },
  // 添加wfs
  addWfsLayer(res) {
    if (window.terrain) {
      window.terrain.removeFromMap();
      window.terrain = null;
    }
    // earthCtrl.viewer.scene.globe.show = false;
    earthCtrl.viewer.camera.flyTo({
      destination: {
        x: -3475710.5684351875,
        y: 5625834.799523204,
        z: 2729961.751894543,
      },
      orientation: {
        heading: 5.73978482494632,
        pitch: -1.2817819264676036,
        roll: 6.282989918773924,
      },
    });
    const layer1 = earthCtrl.factory.createWfsLayer('point', {
      urls: 'https://cim.smartearth.cn/geoserver/JiaShanBase/ows',
      layer: 'JiaShanBase:RadarSpot',
      text: '[JiaShanBase:Type]',
      color: '#de3',
      disableDepthTestDistance: Infinity
    })
    this.layerList.push({
      layer: layer1,
      func: res.func
    });
    const layer2 = earthCtrl.factory.createWfsLayer('polyline', {
      urls: 'https://cim.smartearth.cn/geoserver/JiaShanBase/ows',
      layer: 'JiaShanBase:RadarL',
      width: 1.5,
      color: '#87CEFA',
      disableDepthTestDistance: Number.POSITIVE_INFINITY,
    })
    this.layerList.push({
      layer: layer2,
      func: res.func
    });
    const layer3 = earthCtrl.factory.createWfsLayer('polyline', {
      urls: 'https://cim.smartearth.cn/geoserver/JiaShanBase/ows',
      layer: 'JiaShanBase:RadarM',
      width: 1.5,
      color: '#de3',
      disableDepthTestDistance: Number.POSITIVE_INFINITY,
    })
    this.layerList.push({
      layer: layer3,
      func: res.func
    });
    const layer4 = earthCtrl.factory.createWfsLayer('polyline', {
      urls: 'https://cim.smartearth.cn/geoserver/JiaShanBase/ows',
      layer: 'JiaShanBase:RadarS',
      width: 1.5,
      color: '#FF0000',
      disableDepthTestDistance: Number.POSITIVE_INFINITY,
    })
    this.layerList.push({
      layer: layer4,
      func: res.func
    });
    this.addRaderLayer(res);
  },
  //雷达遮罩扫描
  addRaderLayer(res) {
    //雷达遮罩扫描(自定义)
    const option = {
      radius: 150000,  //半径
      yaw: 0,  //雷达方向(可选)
      angle: 120,  //雷达夹角(可选)
      scanAngle: 30,  //扫描夹角(可选)
      speed: 5,  //倍速(可选)
      maxLat: 90,  //下维度(可选)
      minLat: 45,  //上维度(可选)
      stackPartitions: 40,  //横向网格数(可选)
      slicePartitions: 80,  //纵向网格数(可选)
      //color: 'rgba(255,255,255,0.5)',  //雷达遮罩颜色(可选)
      //outlineColor: 'rgba(255,255,255,0.5)',  //雷达遮罩边框线颜色(可选)
      //scanColor: 'rgba(255,0,0,0.5)',   //扫描颜色(可选)
    };
    const position1 = [121.614202387521061, 23.990136825668284, 0];
    // 雷达遮罩
    const layer = earthCtrl.factory.createRadarMaskScan('雷达遮罩扫描1', position1, option)
    this.layerList.push({
      layer: layer,
      func: 'radarMaskScan'
    });
  },
  //视锥
  addTetrahedron(res) {
    const modelLayer = mapServer.listData.filter((obj) => {
      if (obj.name == config.modelLayer) {
        return obj;
      }
    });
    let ids = [];
    res.data.forEach((item, index) => {
      const tetrahedron = earthCtrl.factory.addTetrahedron({
        position: {
          lon: item.lontitude,
          lat: item.lattitude,
          height: item.height
        },
        multiple: 0.05,
        scale: new SmartEarth.Cesium.Cartesian3(30, 30, 30),
        color: "#FF0000",
        outlineColor: "#FF0000"
      });
      if (index == 0) {
        // 将经纬度转换为Cartesian3坐标
        const position = Cesium.Cartesian3.fromDegrees(item.lontitude, item.lattitude - 0.01, 500);
        // 创建一个边界球 (Bounding Sphere),假设半径为500
        const boundingSphere = new Cesium.BoundingSphere(position, 1000);
        // 使用 flyToBoundingSphere 定位相机
        earthCtrl.viewer.camera.flyToBoundingSphere(boundingSphere, {
          duration: 3.0,  // 飞行的时间
          offset: new Cesium.HeadingPitchRange(0, Cesium.Math.toRadians(-30), 6.28316028073749),
        });
        // earthCtrl.camera.flyTo(item.lontitude, item.lattitude, 5000, 0, -90, 0, 2);
      }
      ids.push(item.uuid);
      this.layerList.push({
        layer: tetrahedron,
        func: 'tetrahedron'
      });
    });
    modelLayer[0].layer.style = new Cesium.Cesium3DTileStyle({
      color: {
        evaluateColor: (feature) => {
          const id = feature.getProperty("id");
          if (ids.indexOf(id) > -1) {
            console.log("id**********", id);
            return new SmartEarth.Cesium.Color.fromCssColorString(
              '#FF0000'
            );
          }
        }
      }
    });
  },
  //绘制线
  addPolyLine(res) {
    // 解析 LINESTRING 字符串为经纬度坐标数组
    const coordinates = res.bombpoint
      .replace("LINESTRING", "") // 去除 'LINESTRING' 部分
      .replace(/[()]/g, "") // 去除括号
      .split(",") // 按逗号分割
      .map(coord => {
        const [lon, lat] = coord.trim().split(" "); // 将每对坐标分开
        return [parseFloat(lon), parseFloat(lat)]; // 转换为数字
      });
    const positions = coordinates.map(coord => {
      return {
        x: coord[0],
        y: coord[1],
        z: 21
      };
    });
    positions.forEach((item, index) => {
      const particle = earthCtrl.factory.createParticleEffect("flame", item, {
        translation: SmartEarth.Cesium.Cartesian3.fromElements(0, 0, 0), //平移
        emissionRate: 500,
        startScale: 15,
        endScale: 45,
      });
      if (index == positions.length / 2) {
        earthCtrl.camera.flyTo(item.x, item.y, 3000, 0, -90, 0, 2);
      }
      this.layerList.push({
        layer: particle,
        func: 'attackentity'
      });
    })
  },
  removeAll() {
    store.state.setListColor = [];
    store.state.showLenged = false;
@@ -343,6 +556,37 @@
        this.layerList.splice(i, 1);
        i--;
      }
      else if (obj.func == "aroundPoi_2") {
        this.layerList[i].layer.destroy();
        this.layerList.splice(i, 1);
        i--;
      }
      else if (obj.func == "getTAIWAN") {
        this.layerList[i].layer.destroy();
        this.layerList.splice(i, 1);
        i--;
      }
      else if (obj.func == "radarMaskScan") {
        this.layerList[i].layer.deleteObject();
        this.layerList.splice(i, 1);
        i--;
      }
      else if (obj.func == "tetrahedron") {
        this.layerList[i].layer.deleteObject();
        this.layerList.splice(i, 1);
        i--;
      }
      else if (obj.func == "attackentity") {
        this.layerList[i].layer.deleteObject();
        this.layerList.splice(i, 1);
        i--;
      }
    }
    if (!window.terrain) {
      window.terrain = earthCtrl.factory.createTerrainLayer({
        sourceType: "ctb",
        url: config.terrainUrl
      });
    }
  }
};