Newer
Older
KaiFengPC / src / views / sponeScreen / gisMF / cesiumMapLegend.js
@jimengfei jimengfei on 19 Jul 13 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 } from '@/api/sponeScreen/syntherticData.js';
import { getStationList } from '@/api/sponeScreen/syntherticData';
import bus from '@/bus';
let YSBZ, WSBZ, HLBZ, WSCLC, waterLogingPoint, projectStation, ysArea, wsArea, hsArea, wscArea, rainStationData, rainStationArea;
let legendDataList;
export default class cesiumMapCommonLegend {
  //获取站点数据
  static async getStationData() {
    let results = await Promise.all([oneMapFacilityPumpList(), haiMianfacilitySewagePage(), getStationList()]);
    let resRainwater = results[0];
    let resWSCLC = results[1];
    let rainStation = results[2];
    //雨水泵站
    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.filter(data => data.monitorTargetType == 'rainfall'); //雨量站
    YSBZ = this.getGeojsonData(YSBZDataList);
    WSBZ = this.getGeojsonData(WSBZDataList);
    HLBZ = this.getGeojsonData(HLBZDataList);
    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('legendDataList', 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: false,
              name: '白色地图',
              url: 'whiteMap_icon.png',
              layername: 'whiteMap',
              type: 'background',
            },
            {
              isCheck: true,
              name: '深色地图',
              url: 'blackMap_icon.png',
              layername: 'blackMap',
              type: 'background',
            },
          ],
          [
            {
              isCheck: false,
              name: '影像图',
              url: 'imageMap_icon.png',
              layername: 'imageMap',
              type: 'background',
            },
            {
              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',
              ],
            },
            {
              isCheck: false,
              name: '雨水泵站',
              layername: 'YSBZ',
              url: 'rainBengZhan_icon.png', //图层+json √
              mapUrl: 'paiLaoBeng.png',
              type: 'point',
              data: YSBZ,
              dataArea: ysArea,
            },
          ],
          [
            {
              isCheck: false,
              name: '污水管网',
              layername: 'sewageLine',
              url: 'sewageLine_icon.png', //服务  √
              type: '3dModel',
              data: [
                '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',
              ],
            },
            {
              isCheck: false,
              name: '污水泵站', //图层+json   √
              layername: 'WSBZ',
              url: 'sewageBenZhan_icon.png',
              mapUrl: 'wsBeng.png',
              type: 'point',
              data: WSBZ,
              dataArea: wsArea,
            },
          ],
          [
            {
              isCheck: false,
              name: '合流管网',
              layername: 'combineLine',
              url: 'combineLine_icon.png', //服务  √
              type: '3dModel',
              data: [
                '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: '合流泵站', //图层+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,
            },
          ],
        ],
      },
      {
        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: riverLake,
            },
          ],
          [
            {
              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,
            },
          ],
        ],
      },
    ];
  }
}