Newer
Older
KaiFengPC / src / views / sponeScreen / gisMF / cesiumMapLegend.js
@jimengfei jimengfei on 9 Aug 15 KB updata
import builtCity from '@/assets/geojson/kaifeng/builtCity.json';
import centerCity from '@/assets/geojson/kaifeng/centerCity.json';
import cityArea from '@/assets/geojson/kaifeng/cityArea.json';
import riverLake from '@/assets/geojson/kaifeng/riverLake.json';
import pipeFlow from '@/assets/geojson/kaifeng/pipeFlow.json';
import { oneMapFacilityPumpList } from '@/api/scada/pumpStationInformation';
import { haiMianfacilitySewagePage } from '@/api/scada/sewage';
import { waterloggingPointList, queryProjectStation, getStationList } from '@/api/sponeScreen/syntherticData.js';
import { realtimeRainfallStatistics } from '@/api/floodSys/oneMap.js';
import bus from '@/bus';
let YSBZ,
  WSBZ,
  HLBZ,
  WSCLC,
  waterLogingPoint,
  projectStation,
  ysArea,
  wsArea,
  hsArea,
  wscArea,
  rainStationData,
  rainStationArea,
  riverSuperVise;
let legendDataList;
export default class cesiumMapCommonLegend {
  //获取站点数据
  static async getStationData() {
    let results = await Promise.all([
      oneMapFacilityPumpList(),
      haiMianfacilitySewagePage(),
      realtimeRainfallStatistics({ monitorTargetType: 'rainfall', orderBy: 'tt desc' }),
      getStationList(),
    ]);
    let resRainwater = results[0];
    let resWSCLC = results[1];
    let rainStation = results[2];
    let stationDataList = results[3];
    //雨水泵站
    let YSBZDataList = resRainwater.data.filter(data => data.pumpType == 'rain_water'); //雨水泵站
    let WSBZDataList = resRainwater.data.filter(data => data.pumpType == 'sewage_water'); //污水泵站
    let HLBZDataList = resRainwater.data.filter(data => data.pumpType == 'confluence'); //合流泵站
    let rainDataList = rainStation.data; //雨量站
    let riverDataList = stationDataList.data.filter(data => data.siteType == 'water_level'); //河道监测
    rainDataList.forEach(item => {
      item.stName = item.stName + '/' + item.pn05 + 'mm';
    });
    YSBZ = this.getGeojsonData(YSBZDataList);
    WSBZ = this.getGeojsonData(WSBZDataList);
    HLBZ = this.getGeojsonData(HLBZDataList);
    riverSuperVise = this.getGeojsonData(riverDataList);
    ysArea = this.getPolygonGeojson(YSBZDataList); //雨水泵站范围
    wsArea = this.getPolygonGeojson(WSBZDataList); //污水泵站范围
    hsArea = this.getPolygonGeojson(HLBZDataList); //合流泵站范围
    rainStationData = this.getGeojsonData(rainDataList);
    rainStationArea = this.getPolygonGeojson(rainDataList); //雨量站范围
    rainStationArea.features.forEach(feature => {
      feature.properties.fillcolor = 'rgba(41, 184, 219,0.7)';
    });

    let WSCLCDataList = resWSCLC.data;
    WSCLC = this.getGeojsonData(WSCLCDataList); //污水处理厂
    wscArea = this.getPolygonGeojson(WSCLCDataList); //污水处理厂范围
    let waterLogingRes = await waterloggingPointList();
    if (waterLogingRes && waterLogingRes.code == 200) {
      waterLogingPoint = this.getGeojsonData(waterLogingRes.data); //内涝点
    }
    let params = {};
    let projectStationRes = await queryProjectStation(params);
    if (projectStationRes && projectStationRes.code == 200) {
      projectStation = this.getGeojsonData(projectStationRes.data);
    }
    //发送图例
    legendDataList = this.legendData();
    bus.emit('cesiumLegendDataList', legendDataList);
  }
  //汇水范围json
  static getPolygonGeojson(dataList) {
    let features = [];
    let feature = {};
    dataList.forEach(data => {
      if (!data.geometrys) return;
      feature = turf.feature(Terraformer.WKT.parse(data.geometrys), data);
      features.push(feature);
    });
    return {
      type: 'FeatureCollection',
      features: features,
    };
  }
  //构建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.lonlat) {
        let lonlat = data.lonlat.split(',');
        feature = {
          type: 'Feature',
          geometry: {
            type: 'Point',
            coordinates: [Number(lonlat[0]), Number(lonlat[1])],
          },
          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,
        };
      } else if (data.longitude && data.latitude) {
        feature = {
          type: 'Feature',
          geometry: {
            type: 'Point',
            coordinates: [Number(data.longitude), Number(data.latitude)],
          },
          properties: data,
        };
      }
      features.push(feature);
    });
    return {
      type: 'FeatureCollection',
      features: features,
    };
  }
  static legendData() {
    return [
      {
        title: '基础图层',
        isCheck: false,
        children: [
          [
            {
              isCheck: true,
              name: '白色地图',
              url: 'whiteMap_icon.png',
              layername: 'whiteMap',
              type: 'background',
            },
            {
              isCheck: false,
              name: '深色地图',
              url: 'blackMap_icon.png',
              layername: 'blackMap',
              type: 'background',
            },
          ],
          [
            {
              isCheck: false,
              name: '影像图',
              url: 'imageMap_icon.png',
              layername: 'imageMap',
              type: 'background',
            },
            {
              isCheck: false,
              name: '气象云图',
              url: 'paiShuiArea3_icon.png',
              layername: 'weather_cloud',
              type: 'weather_cloud',
            },
            // {
            //   isCheck: false,
            //   name: '三维建筑',
            //   url: 'building_icon.png',
            //   layername: 'buildingModel',
            //   type: '3dModel',
            //   data: [
            //     'https://server1.wh-nf.cn:9000/newfiber-standard-kaifeng/2024/06/24/kaifengBuilding/kaifengBuilding/kaifengBuilding.scp',
            //   ],
            // },
          ],
          [
            {
              isCheck: false,
              name: '行政区划',
              url: 'cityArea_icon.png',
              layername: 'cityArea',
              type: 'polygon',
              data: cityArea,
            },
            {
              isCheck: false,
              name: '建成区',
              url: 'builtCity_icon.png',
              layername: 'builtCity',
              type: 'areaWall',
              data: builtCity,
            },
          ],
          [
            {
              isCheck: false,
              name: '中心城区',
              url: 'centerCity_icon.png',
              layername: 'centerCity',
              type: 'areaWall',
              data: centerCity,
            },
            {
              isCheck: false,
              name: '河湖水系',
              url: 'dynamicWater_icon.png',
              layername: 'dynamicWater',
              type: 'dynamicWater',
              data: riverLake,
            },
          ],
          [
            {
              isCheck: false,
              name: '排水分区一',
              url: 'paiShuiArea1_icon.png',
              layername: 'cesiumPaishuiArea1',
              type: 'cesiumPaishuiArea',
            },
            {
              isCheck: false,
              name: '地形地貌',
              url: 'topography_icon.png',
              layername: 'topography',
              type: 'pngImage',
            },
          ],
          [
            {
              isCheck: false,
              name: '排水分区二',
              url: 'paiShuiArea2_icon.png',
              layername: 'cesiumPaishuiArea2',
              type: 'cesiumPaishuiArea',
            },
            {
              isCheck: false,
              name: '供水厂',
              url: 'waterFactory_icon.png',
              layername: 'waterFactory',
              type: 'iconPoint',
            },
          ],
          [
            {
              isCheck: false,
              name: '排水分区三',
              url: 'paiShuiArea3_icon.png',
              layername: 'cesiumPaishuiArea3',
              type: 'cesiumPaishuiArea',
            },
            // {
            //   isCheck: false,
            //   name: '气象云图',
            //   url: 'paiShuiArea3_icon.png',
            //   layername: 'weather_cloud',
            //   type: 'weather_cloud',
            // },
          ],
        ],
      },
      {
        title: '雨水/污水系统',
        isCheck: false,
        children: [
          [
            {
              isCheck: false,
              name: '三维管网',
              layername: 'rainLine',
              url: 'rainLine_icon.png', //图层+json √
              type: '3dModel',
              data: [
                'https://server1.wh-nf.cn:9000/newfiber-standard-kaifeng/2024/06/24/pipeData/ysline/ysline.scp',
                'https://server1.wh-nf.cn:9000/newfiber-standard-kaifeng/2024/06/24/pipeData/YS_Point/YS_Point.scp',
                'https://server1.wh-nf.cn:9000/newfiber-standard-kaifeng/2024/06/24/pipeData/wsLine/wsLine.scp',
                'https://server1.wh-nf.cn:9000/newfiber-standard-kaifeng/2024/06/24/pipeData/WS_Point/WS_Point.scp',
                'https://server1.wh-nf.cn:9000/newfiber-standard-kaifeng/2024/06/24/pipeData/hsLine/hsLine.scp',
                'https://server1.wh-nf.cn:9000/newfiber-standard-kaifeng/2024/06/24/pipeData/hs_Point/hs_Point.scp',
              ],
            },
            {
              isCheck: false,
              name: '雨水泵站',
              layername: 'YSBZ',
              url: 'rainBengZhan_icon.png', //图层+json √
              mapUrl: 'paiLaoBeng.png',
              type: 'point',
              data: YSBZ,
              dataArea: ysArea,
            },
          ],
          [
            {
              isCheck: false,
              name: '污水泵站', //图层+json   √
              layername: 'WSBZ',
              url: 'sewageBenZhan_icon.png',
              mapUrl: 'wsBeng.png',
              type: 'point',
              data: WSBZ,
              dataArea: wsArea,
            },
            {
              isCheck: false,
              name: '合流泵站', //图层+json   √
              layername: 'combineBengZhan',
              url: 'combineBengZhan_icon.png',
              mapUrl: 'wsBeng.png',
              type: 'point',
              data: HLBZ,
              dataArea: hsArea,
            },
          ],
          [
            {
              isCheck: false,
              name: '污水处理厂',
              layername: 'sewageFactory', //图层+json   √
              url: 'sewageFactory_icon.png',
              mapUrl: 'WSC.png',
              type: 'point',
              data: WSCLC,
              //data: wuShuiChang,
              //dataArea: wscArea,
            },
            {
              isCheck: false,
              name: '管网流向',
              layername: 'pipeLineFlow',
              url: 'pipeLineFlow_icon.png',
              type: 'dynamicLine',
              data: pipeFlow,
            },
          ],
          [
            {
              isCheck: false,
              name: '雨水管网',
              layername: 'henan_kaifeng_ysline', //图层+json   √
              url: 'rainLine_icon.png',
              //mapUrl: 'WSC.png',
              type: 'mapServer',
              //data: WSCLC,
              //data: wuShuiChang,
              //dataArea: wscArea,
            },
            {
              isCheck: false,
              name: '雨水井',
              layername: 'henan_kaifeng_yspoint',
              url: 'ysj.svg',
              type: 'mapServer',
              //data: pipeFlow,
            },
          ],
          [
            {
              isCheck: false,
              name: '污水管网',
              layername: 'henan_kaifeng_wsline', //图层+json   √
              url: 'sewageLine_icon.png',
              //mapUrl: 'WSC.png',
              type: 'mapServer',
              //data: WSCLC,
              //data: wuShuiChang,
              //dataArea: wscArea,
            },
            {
              isCheck: false,
              name: '污水井',
              layername: 'henan_kaifeng_wspoint',
              url: 'wsj.svg',
              type: 'mapServer',
              //data: pipeFlow,
            },
          ],
          [
            {
              isCheck: false,
              name: '合流管网',
              layername: 'henan_kaifeng_hsline', //图层+json   √
              url: 'combineLine_icon.png',
              //mapUrl: 'WSC.png',
              type: 'mapServer',
              //data: WSCLC,
              //data: wuShuiChang,
              //dataArea: wscArea,
            },
            {
              isCheck: false,
              name: '合流井',
              layername: 'henan_kaifeng_hspoint',
              url: 'hsj.svg',
              type: 'mapServer',
              //data: pipeFlow,
            },
          ],
          // [
          //   {
          //     isCheck: false,
          //     name: '路网标注',
          //     layername: 'roadLabel', //图层+json   √
          //     url: 'pipeLineFlow_icon.png',
          //     //mapUrl: 'WSC.png',
          //     type: 'basicMap',
          //     //data: WSCLC,
          //     //data: wuShuiChang,
          //     //dataArea: wscArea,
          //   },
          // ],
        ],
      },
      {
        title: '感知监测',
        isCheck: false,
        children: [
          [
            {
              isCheck: false,
              name: '内涝积水点',
              layername: 'waterLoging', //图层+json  √
              url: 'waterLoging_icon.png',
              mapUrl: 'rain.png',
              type: 'point',
              data: waterLogingPoint,
            },
            {
              isCheck: false,
              name: '河道断面',
              layername: 'waterCourse',
              url: 'waterCourse_icon.png', //图层+json  √
              mapUrl: 'KDJZWMX.png',
              type: 'point',
              data: riverSuperVise,
            },
          ],
          [
            {
              isCheck: false,
              name: '雨量站',
              layername: 'rainStation',
              url: 'rainStation_icon.png', //图层+json  √
              mapUrl: 'yuanTou.png',
              type: 'point',
              data: rainStationData,
              dataArea: rainStationArea,
            },
            {
              isCheck: false,
              name: '源头地块',
              layername: 'origine', //图层+json  √
              url: 'origine_icon.png',
              mapUrl: 'rainSupervise.png',
              type: 'point',
              //data: pipeSupervise,
            },
          ],
          [
            {
              isCheck: false,
              name: '海绵设施',
              layername: 'spongeFacility',
              url: 'spongeFacility_icon.png', //图层+json  √
              mapUrl: 'yiLao.png',
              type: 'point',
              data: projectStation,
            },
          ],
        ],
      },
    ];
  }
}