Newer
Older
KaiFengPC / src / views / gisMapPage / healthLegend.js
@zhangdeliang zhangdeliang on 28 Aug 6 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 bus from '@/bus';
let rainStation;
let pipeSupervise;
let PKsupervise;
let legendDataList;
let drainOutlet;
let RainPort;
let YSBZ;
let WSBZ;
let WSCLC;
export default class mapHealthLegend {
  //获取站点数据
  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 res = await getStationList();
    if (res && res.code == 200) {
      let datas = res.data;
      let pipeSuperviseDataList = datas.filter(data => data.monitorTargetType == 'pipeline');
      let PKsuperviseDataList = datas.filter(data => data.monitorTargetType == 'drain_outlet');
      pipeSupervise = this.getGeojsonData(pipeSuperviseDataList);
      PKsupervise = this.getGeojsonData(PKsuperviseDataList);

      //发送图例
      legendDataList = this.legendData();
      bus.emit('healthLegend', 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,
        };
      } else if (data.originalX && data.originalY) {
        feature = {
          type: 'Feature',
          geometry: {
            type: 'Point',
            coordinates: [Number(data.originalX), Number(data.originalY)],
          },
          properties: data,
        };
      }
      features.push(feature);
    });
    return {
      type: 'FeatureCollection',
      features: features,
    };
  }
  static legendData() {
    return [
      {
        title: '雨水系统',
        children: [
          {
            isCheck: false,
            name: '雨水分区',
            layername: 'YSFQ1',
            url: 'rainAreas.png', //图层+标注+json √
            type: 'mapServer',
          },
          {
            isCheck: false,
            name: '雨水管网',
            layername: 'ysLine1',
            url: 'xiufu.png', //图层+json √
            type: 'mapServer',
          },
          {
            isCheck: false,
            name: '雨水排口',
            layername: 'paiKou',
            url: 'paiKous.png', //图层+json √
            mapUrl: 'paiKou.png',
            type: 'point',
            data: RainPort,
          },
          {
            isCheck: false,
            name: '雨水泵站',
            layername: 'YSBZ',
            url: 'paiLaoBengs.png', //图层+json √
            mapUrl: 'paiLaoBeng.png',
            type: 'point',
            data: YSBZ,
          },
        ],
      },
      {
        title: '污水系统',
        children: [
          {
            isCheck: false, //  √
            name: '排水分区',
            layername: 'WSFQ',
            url: 'wsAreas.png',
            type: 'mapServer',
          },
          {
            isCheck: false,
            name: '污水管网',
            layername: 'wsLine1',
            url: 'qingyu.png', //服务  √
            type: 'mapServer',
          },
          {
            isCheck: false,
            name: '合流制溢流口',
            layername: 'drainOutlet', //图层+json  √
            url: 'DFHZ1.png',
            mapUrl: 'DFHZ2.png',
            type: 'point',
            data: drainOutlet,
          },
          {
            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,
          },
        ],
      },
      {
        title: '感知监测',
        children: [
          {
            isCheck: false,
            name: '管网监测',
            layername: 'pipeSupervise', //图层+json  √
            url: 'rainSupervises.png',
            mapUrl: 'rainSupervise.png',
            type: 'point',
            data: pipeSupervise,
          },
          {
            isCheck: false,
            name: '排口监测',
            layername: 'PKsupervise',
            url: 'YQGXMX s.png', //图层+json  √
            mapUrl: 'YQGXMX.png',
            type: 'point',
            data: PKsupervise,
          },
        ],
      },
    ];
  }
}