Newer
Older
KaiFengPC / src / views / gisMapPage / commonLegend.js
@zhangdeliang zhangdeliang 10 days ago 11 KB update
// import wuShuiChang from '@/assets/geojson/kaifeng/wuShuiChang.json';
// import ysBengZhan from '@/assets/geojson/kaifeng/ysBengZhan.json';
// import wsBengZhan from '@/assets/geojson/kaifeng/wsBengZhan.json';

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 { realtimeDataByPump } from '@/api/floodSys/oneMap.js';
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;
let PLBZ;
window.allStationList = [];
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);
      allStationList.push(resRainPort.data);
    }
    if (resOverflow && resOverflow.code == 200) {
      let drainOutletData = resOverflow.data;
      drainOutlet = this.getGeojsonData(drainOutletData);
      allStationList.push(resOverflow.data);
    }
    //雨水泵站
    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');
      let PLBZDataList = resRainwater.data.filter(data => data.pumpType == 'drain_flooded');
      YSBZ = this.getGeojsonData(YSBZDataList);
      WSBZ = this.getGeojsonData(WSBZDataList);
      PLBZ = this.getGeojsonData(PLBZDataList);
      WSBZ.features.forEach((feature, index) => {
        if (!!!feature.geometry) {
          WSBZ.features.splice(index, 1);
        }
      });
      allStationList.push(YSBZDataList);
      allStationList.push(WSBZDataList);
      allStationList.push(PLBZDataList);
    }
    //污水处理厂
    let resWSCLC = await facilitySewageList();
    if (resWSCLC && resWSCLC.code == 200) {
      let WSCLCDataList = resWSCLC.data;
      WSCLC = this.getGeojsonData(WSCLCDataList);
      allStationList.push(resWSCLC.data);
    }
    //人工采样
    let resWaterSect = await sectionWaterList();
    if (resWaterSect && resWaterSect.code == 200) {
      let waterSectDataList = resWaterSect.data;
      waterSectionInfo = this.getGeojsonData(waterSectDataList);
      allStationList.push(resWaterSect.data);
    }
    //雨量站、管网检测、排口监测、积水点、河湖断面、源头地块
    let res = await getStationList();
    if (res && res.code == 200) {
      let datas = res.data;
      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);
      allStationList.push(res.data);
      //发送图例
      legendDataList = this.legendData();
      bus.emit('legendDataList', legendDataList);
    }
    allStationList = allStationList.flat();
  }
  //构建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: '基础信息',
        noAllCheck: true,
        children: [
          {
            isCheck: false,
            name: '影像图',
            url: 'ysMap.png',
            layername: 'imageTiler',
            type: 'background',
          },
          // {
          //   isCheck: false,
          //   name: '三维建筑',
          //   url: 'rainAreas.png',
          //   layername: 'kaifengBuilding',
          //   type: 'background',
          // },
        ],
      },
      {
        title: '雨水系统',
        isCheck: false,
        children: [
          {
            isCheck: false,
            name: '雨水分区',
            layername: 'YSFQ1',
            url: 'rainAreas.png', //图层+标注+json √
            type: 'mapServer',
          },
          {
            isCheck: false,
            name: '排涝泵站',
            layername: 'PLBZ',
            url: 'waiPaiBengs.png', //图层+json √
            mapUrl: 'waiPaiBeng.png',
            type: 'point',
            data: PLBZ,
          },
          {
            isCheck: false,
            name: '雨水泵站',
            layername: 'YSBZ',
            url: 'paiLaoBengs.png', //图层+json √
            mapUrl: 'paiLaoBeng.png',
            type: 'point',
            data: YSBZ,
            //data: ysBengZhan,
          },
          {
            isCheck: false,
            name: '雨水管网',
            layername: 'ysLine1',
            url: 'xiufu.png', //图层+json √
            type: 'mapServer',
          },
          {
            isCheck: false,
            name: '管网流向',
            layername: 'pipeline_info_flow_ys',
            url: 'natureWaters1.png',
            type: 'dynamicWater',
          },
          // {
          //   isCheck: false,
          //   name: '雨水排口',
          //   layername: 'paiKou',
          //   url: 'paiKous.png', //图层+json √
          //   mapUrl: 'paiKou.png',
          //   type: 'point',
          //   data: RainPort,
          // },
        ],
      },
      {
        title: '污水系统',
        isCheck: false,
        children: [
          {
            isCheck: false, //  √
            name: '污水分区',
            layername: 'WSFQ',
            url: 'wsAreas.png',
            type: 'mapServer',
          },
          {
            isCheck: false,
            name: '污水处理厂',
            layername: 'WSCLC', //图层+json   √
            url: 'WSCs.png',
            mapUrl: 'WSC.png',
            type: 'point',
            data: WSCLC,
            //data: wuShuiChang,
          },
          {
            isCheck: false,
            name: '污水泵站', //图层+json   √
            layername: 'WSBZ',
            url: 'wsBengs.png',
            mapUrl: 'wsBeng.png',
            type: 'point',
            data: WSBZ,
            //data: wsBengZhan,
          },
          {
            isCheck: false,
            name: '污水管网',
            layername: 'wsLine1',
            url: 'qingyu.png', //服务  √
            type: 'mapServer',
          },
          {
            isCheck: false,
            name: '管网流向',
            layername: 'pipeline_info_flow_ws1',
            url: 'natureWaters.png',
            type: 'dynamicWater',
          },
        ],
      },
      {
        title: '感知监测',
        isCheck: false,
        children: [
          {
            isCheck: false,
            name: '雨量站',
            layername: 'rainStation', //图层+json  √
            url: 'rains.png',
            mapUrl: 'rain.png',
            type: 'point',
            data: rainStation,
          },
          {
            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: 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: 'orinign', //图层+json  √
            url: 'orinigns.png',
            mapUrl: 'orinign.png',
            type: 'point',
            data: orinign,
          },
          // {
          //   isCheck: false,
          //   name: '河道水质',
          //   layername: 'waterSectionInfo',
          //   url: 'yuanTous.png', //图层+json  √
          //   mapUrl: 'yuanTou.png',
          //   type: 'point',
          //   data: waterSectionInfo,
          // },
        ],
      },
    ];
  }
}