Newer
Older
KaiFengPC / src / views / gisMapPage / LegendDataMain.js
@zhangdeliang zhangdeliang on 14 Aug 7 KB update
import { getStationList } from '@/api/sponeScreen/syntherticData';
import { listpipelinePoint } from '@/api/drainagePipeline/pipelinePoint';
import { facilityPumpList } from '@/api/scada/pumpStationInformation';
import { facilitySewageList } from '@/api/scada/sewage';
import { sectionWaterList } from '@/api/dataAnalysis/manualAssay';
import bus from '@/bus';
let rainStation;
let pipeSupervise;
let PKsupervise;
let waterlog;
let riverLake;
let legendDataList;
let drainOutlet;
let orinign;
let RainPort;
let YSBZ;
let WSBZ;
let WSCLC;
let waterSectionInfo;
export default class mapCommonLegend {
  //获取站点数据
  static async getStationData() {
    //雨污水排口
    let params = {
      pointType: 'RainPort',
    };
    let params1 = {
      pointType: 'Overflow',
    };
    let resRainPort = await listpipelinePoint(params);
    let resOverflow = await listpipelinePoint(params1);
    if (resRainPort && resRainPort.code == 200) {
      let RainPortDataList = resRainPort.data;
      RainPort = this.getGeojsonData(RainPortDataList);
    }
    if (resOverflow && resOverflow.code == 200) {
      let drainOutletData = resOverflow.data;
      drainOutlet = this.getGeojsonData(drainOutletData);
    }
    //雨水泵站
    let resRainwater = await facilityPumpList();
    if (resRainwater && resRainwater.code == 200) {
      let YSBZDataList = resRainwater.data.filter(data => data.pumpType == 'rain_water');
      let WSBZDataList = resRainwater.data.filter(data => data.pumpType == 'sewage_water');
      YSBZ = this.getGeojsonData(YSBZDataList);
      WSBZ = this.getGeojsonData(WSBZDataList);
      WSBZ.features.forEach((feature, index) => {
        if (!!!feature.geometry) {
          WSBZ.features.splice(index, 1);
        }
      });
    }
    //污水处理厂
    let resWSCLC = await facilitySewageList();
    if (resWSCLC && resWSCLC.code == 200) {
      let WSCLCDataList = resWSCLC.data;
      WSCLC = this.getGeojsonData(WSCLCDataList);
    }
    //人工采样
    let resWaterSect = await sectionWaterList();
    if (resWaterSect && resWaterSect.code == 200) {
      let waterSectDataList = resWaterSect.data;
      waterSectionInfo = this.getGeojsonData(waterSectDataList);
      console.log('waterSectDataList', waterSectDataList);
    }
    //雨量站、管网检测、排口监测、积水点、河湖断面、源头地块
    let res = await getStationList();
    if (res && res.code == 200) {
      let datas = res.data;
      // console.log(datas);
      let rainDataList = datas.filter(data => data.monitorTargetType == 'rainfall');
      let pipeSuperviseDataList = datas.filter(data => data.monitorTargetType == 'pipeline');
      let PKsuperviseDataList = datas.filter(data => data.monitorTargetType == 'drain_outlet');
      let waterlogDataList = datas.filter(data => data.monitorTargetType == 'waterlogging');
      let riverLakeDataList = datas.filter(data => data.monitorTargetType == 'river');
      let orinignDataList = datas.filter(data => data.monitorTargetType == 'typical_land');
      // let drainOutletData = datas.filter(
      //   data => data.monitorTargetType == 'drain_outlet' && data.siteType == 'flow' && data.stName.includes('溢流口')
      // );
      rainStation = this.getGeojsonData(rainDataList);
      pipeSupervise = this.getGeojsonData(pipeSuperviseDataList);
      PKsupervise = this.getGeojsonData(PKsuperviseDataList);
      waterlog = this.getGeojsonData(waterlogDataList);
      riverLake = this.getGeojsonData(riverLakeDataList);
      orinign = this.getGeojsonData(orinignDataList);
      //drainOutlet = this.getGeojsonData(drainOutletData);
      //发送图例
      legendDataList = this.legendData();
      bus.emit('legendDataMainList', legendDataList);
    }
  }
  //构建geojson格式
  static getGeojsonData(dataList) {
    let features = [];
    let feature = {};
    dataList.forEach(data => {
      if (data.lonLat) {
        let lonlat = data.lonLat.split(',');
        feature = {
          type: 'Feature',
          geometry: {
            type: 'Point',
            coordinates: [Number(lonlat[0]), Number(lonlat[1])],
          },
          properties: data,
        };
      } else if (data.geometrys) {
        let geometry = Terraformer.WKT.parse(data.geometrys);
        feature = {
          type: 'Feature',
          geometry: geometry,
          properties: data,
        };
      } else if (data.lon && data.lat) {
        feature = {
          type: 'Feature',
          geometry: {
            type: 'Point',
            coordinates: [Number(data.lon), Number(data.lat)],
          },
          properties: data,
        };
      }
      features.push(feature);
    });
    return {
      type: 'FeatureCollection',
      features: features,
    };
  }
  static legendData() {
    return [
      {
        title: '感知监测',
        isCheck: false,
        children: [
          {
            isCheck: false,
            name: '源头地块',
            layername: 'orinign', //图层+json  √
            url: 'orinigns.png',
            mapUrl: 'orinign.png',
            type: 'point',
            data: orinign,
          },
          {
            isCheck: false,
            name: '雨量监测',
            layername: 'rainStation', //图层+json  √
            url: 'rains.png',
            mapUrl: 'rain.png',
            type: 'point',
            data: rainStation,
          },
          {
            isCheck: false,
            name: '管网监测',
            layername: 'pipeSupervise', //图层+json  √
            url: 'rainSupervises.png',
            mapUrl: 'rainSupervise.png',
            type: 'point',
            data: pipeSupervise,
          },
          // {
          //   isCheck: false,
          //   name: '排口监测',
          //   layername: 'PKsupervise',
          //   url: 'YQGXMXs.png', //图层+json  √
          //   mapUrl: 'YQGXMX.png',
          //   type: 'point',
          //   data: PKsupervise,
          // },
          {
            isCheck: false,
            name: '内涝积水点',
            layername: 'waterlog',
            url: 'yiLaos.png', //图层+json  √
            mapUrl: 'yiLao.png',
            type: 'point',
            data: waterlog,
          },
          {
            isCheck: false,
            name: '河道监测',
            layername: 'riverLake',
            url: 'KDJZWMX s.png', //图层+json  √
            mapUrl: 'KDJZWMX.png',
            type: 'point',
            data: riverLake,
          },
          {
            isCheck: false,
            name: '人工采样',
            layername: 'waterSectionInfo',
            url: 'yuanTous.png', //图层+json  √
            mapUrl: 'yuanTou.png',
            type: 'point',
            data: waterSectionInfo,
          },
          {
            isCheck: true,
            name: '雨水泵站',
            layername: 'YSBZ',
            url: 'paiLaoBengs.png', //图层+json √
            mapUrl: 'paiLaoBeng.png',
            type: 'point',
            data: YSBZ,
          },
          {
            isCheck: false,
            name: '污水泵站', //图层+json   √
            layername: 'WSBZ',
            url: 'wsBengs.png',
            mapUrl: 'wsBeng.png',
            type: 'point',
            data: WSBZ,
          },
          {
            isCheck: false,
            name: '污水处理厂',
            layername: 'WSCLC', //图层+json   √
            url: 'WSCs.png',
            mapUrl: 'WSC.png',
            type: 'point',
            data: WSCLC,
          },
        ],
      },
    ];
  }
}