diff --git a/src/utils/gis/NewFiberMapUtils.js b/src/utils/gis/NewFiberMapUtils.js index 6c7fcc6..9b11300 100644 --- a/src/utils/gis/NewFiberMapUtils.js +++ b/src/utils/gis/NewFiberMapUtils.js @@ -1,78 +1,77 @@ -import request from "../request"; +import request from '../request'; -import rainStation_icon from "@/assets/cesiumMap/legendIcon/rainStation_icon.png"; -import spongeFacility_icon from "@/assets/cesiumMap/legendIcon/spongeFacility_icon.png"; -import sewageBenZhan_icon from "@/assets/cesiumMap/legendIcon/sewageBenZhan_icon.png" -import rainBengZhan_icon from "@/assets/cesiumMap/legendIcon/rainBengZhan_icon.png" -import combineBengZhan_icon from "@/assets/cesiumMap/legendIcon/combineBengZhan_icon.png" +import rainStation_icon from '@/assets/cesiumMap/legendIcon/rainStation_icon.png'; +import spongeFacility_icon from '@/assets/cesiumMap/legendIcon/spongeFacility_icon.png'; +import sewageBenZhan_icon from '@/assets/cesiumMap/legendIcon/sewageBenZhan_icon.png'; +import rainBengZhan_icon from '@/assets/cesiumMap/legendIcon/rainBengZhan_icon.png'; +import combineBengZhan_icon from '@/assets/cesiumMap/legendIcon/combineBengZhan_icon.png'; -import riverFlow from "@/assets/geojson/kaifeng/riverFlow.json"; +import riverFlow from '@/assets/geojson/kaifeng/riverFlow.json'; import cesiumMapLegend from '@/views/sponeScreen/gisMF/cesiumMapLegend.js'; -import newfiberVectorLayer from "@/views/sponeScreen/gisMF/newfiberVectorLayer"; +import newfiberVectorLayer from '@/views/sponeScreen/gisMF/newfiberVectorLayer'; import { facilityPumpList } from '@/api/scada/pumpStationInformation'; -let mapParams={ - geojson:{ - point:{ - type: NewFiberMap.Enum.VectorType.ICON, - options: { - url: "/static/images/icon.png", - width: 20, - height: 20, - verticalOrigin: Cesium.HorizontalOrigin.RIGHT, - pixelOffset: [0, -10], - }, - labelOptions: { - font: "17px PingFang SC", - style: Cesium.LabelStyle.FILL_AND_OUTLINE, - outlineColor: "rgba(20,83,154,1)", - outline: true, - outlineWidth: 3, - color: "#ffffff", - pixelOffset: [0, 25], - distanceDisplayCondition: [0, 5100], - }, - }, - warning:{ - type: NewFiberMap.Enum.VectorType.SPECIAL_CIRCLE, - options: { - radius: 70, - material: new NewFiberMap.Material.CircleDiffuseMaterialProperty({ - color: Cesium.Color.fromCssColorString("rgba(255,0,0, .5)"), - speed: 50, - }), - }, - }, - polyline: { - type: NewFiberMap.Enum.VectorType.POLYLINE, - options: { - show: true, - width: 6, - material:new Cesium.Spriteline1MaterialProperty(3000,'/static/images/spriteline.png'), - clampToGround: true - } - }, - polygon:{ - type: NewFiberMap.Enum.VectorType.POLYGON, - options: { - width: 1, - material: "rgba(46,196,203,0.5)", - outlineColor: "rgba(0,244,255,1)", - }, - } - } +let mapParams = { + geojson: { + point: { + type: NewFiberMap.Enum.VectorType.ICON, + options: { + url: '/static/images/icon.png', + width: 20, + height: 20, + verticalOrigin: Cesium.HorizontalOrigin.RIGHT, + pixelOffset: [0, -10], + }, + labelOptions: { + font: '17px PingFang SC', + style: Cesium.LabelStyle.FILL_AND_OUTLINE, + outlineColor: 'rgba(20,83,154,1)', + outline: true, + outlineWidth: 3, + color: '#ffffff', + pixelOffset: [0, 25], + distanceDisplayCondition: [0, 5100], + }, + }, + warning: { + type: NewFiberMap.Enum.VectorType.SPECIAL_CIRCLE, + options: { + radius: 70, + material: new NewFiberMap.Material.CircleDiffuseMaterialProperty({ + color: Cesium.Color.fromCssColorString('rgba(255,0,0, .5)'), + speed: 50, + }), + }, + }, + polyline: { + type: NewFiberMap.Enum.VectorType.POLYLINE, + options: { + show: true, + width: 6, + material: new Cesium.Spriteline1MaterialProperty(3000, '/static/images/spriteline.png'), + clampToGround: true, + }, + }, + polygon: { + type: NewFiberMap.Enum.VectorType.POLYGON, + options: { + width: 1, + material: 'rgba(46,196,203,0.5)', + outlineColor: 'rgba(0,244,255,1)', + }, + }, + }, }; export default class NewFiberMapUtils { - - static defaultParams = { - keys:{ - //巡查默认专题图 - defaultPatrolDemo:'defaultPatrolDemo', - //排水防涝默认专题图 - defaultPreventWaterloggingDemo:'defaultPreventWaterloggingDemo', - weather_cloud:'weather_cloud' - }, - /* mapParams:{ + static defaultParams = { + keys: { + //巡查默认专题图 + defaultPatrolDemo: 'defaultPatrolDemo', + //排水防涝默认专题图 + defaultPreventWaterloggingDemo: 'defaultPreventWaterloggingDemo', + weather_cloud: 'weather_cloud', + }, + /* mapParams:{ geojson:{ point:{ type: NewFiberMap.Enum.VectorType.ICON, @@ -123,56 +122,88 @@ } } }*/ - } + }; + static async defaultPatrolDemo(newfiberMap) { + const { keys } = NewFiberMapUtils.defaultParams; + const defaulGeoJSONParams = _.cloneDeep(mapParams.geojson); + const icons = { ylz: rainStation_icon, hmss: spongeFacility_icon, car: '/images/car.png' }; + NewFiberMapUtils.removeByIds([keys.defaultPatrolDemo]); - static async defaultPatrolDemo(newfiberMap) { - const {keys} = NewFiberMapUtils.defaultParams; - const defaulGeoJSONParams = _.cloneDeep(mapParams.geojson); - const icons = {ylz:rainStation_icon, hmss:spongeFacility_icon, car:"/images/car.png"}; - NewFiberMapUtils.removeByIds([keys.defaultPatrolDemo]); + let results = await Promise.all(['/static/json/malfunction.json', '/static/json/track.json'].map(i => request(i))); + let warningData = _.cloneDeep(results[0]); + results[0].features.forEach( + i => + (i.properties.style_ = _.cloneDeep({ + id: keys.defaultPatrolDemo, + name: i.properties.name, + ...defaulGeoJSONParams.point, + options: Object.assign(defaulGeoJSONParams.point.options, { url: icons[i.properties.type] }), + })) + ); + warningData.features.forEach(i => (i.properties.style_ = { id: keys.defaultPatrolDemo, ...defaulGeoJSONParams.warning })); + let markers = warningData.features.concat(results[0].features); + newfiberMap.geojsonToMap(turf.featureCollection(markers)); - let results = await Promise.all(['/static/json/malfunction.json','/static/json/track.json'].map(i => request(i))); - let warningData = _.cloneDeep(results[0]); - results[0].features.forEach(i => (i.properties.style_ = _.cloneDeep({id:keys.defaultPatrolDemo,name:i.properties.name,...(defaulGeoJSONParams.point),options:Object.assign(defaulGeoJSONParams.point.options,{url:icons[i.properties.type]})}))); - warningData.features.forEach(i => (i.properties.style_ = {id:keys.defaultPatrolDemo,...(defaulGeoJSONParams.warning)})); - let markers = warningData.features.concat(results[0].features); - newfiberMap.geojsonToMap(turf.featureCollection(markers)); + newfiberMap.patrolDemoTracks = results[1].features.map(feature => { + let datas = turf.getCoords(feature.geometry).map(coords => ({ l: coords[0], a: coords[1], height: 10, time: 10 })); + return new NewFiberMap.Layer.RunningPath({ + paths: datas, + name, + newfiberMap, + options: { + style: { move: icons.car }, + perSec: 5, + speed: 10, + pathColor: [38, 178, 107, 1], + passPathColor: [89, 91, 93, 1], + isStart: false, + isEnd: false, + fields: { lng: 'l', lat: 'a', height: 'height', time: 'time' }, + }, + }); + }); - newfiberMap.patrolDemoTracks = results[1].features.map(feature => { - let datas = turf.getCoords(feature.geometry).map(coords => ({l:coords[0],a:coords[1],height:10,time:10})); - return new NewFiberMap.Layer.RunningPath({paths:datas,name, newfiberMap,options:{style:{move:icons.car},perSec:5,speed:10,pathColor:[38,178,107,1],passPathColor:[89,91,93,1], isStart:false, isEnd:false, fields:{lng:'l',lat:'a',height: 'height',time:'time'}}}); - }); + let timeout = setTimeout(() => { + newfiberMap.setView({ + lng: 114.332, + lat: 34.662, + heading: 2.281299097855777, + zoom: 6358.12942752382, + pitch: -25.2508969308367, + roll: 0.005453465256790101, + }); + clearTimeout(timeout); + }, 4000); + } - let timeout = setTimeout(() => { - newfiberMap.setView({ - lng: 114.312, - lat: 34.502, - heading: 2.281299097855777, - zoom: 16358.12942752382, - pitch: -25.2508969308367, - roll: 0.005453465256790101, - }); - clearTimeout(timeout); - }, 4000); - } - - static async defaultPreventWaterlogging(newfiberMap){ - const { keys} = NewFiberMapUtils.defaultParams; - NewFiberMapUtils.removeByIds([keys.defaultPreventWaterloggingDemo]); - const defaulGeoJSONParams = _.cloneDeep(mapParams.geojson); - const icons = { - "confluence":sewageBenZhan_icon, - "rain_water":rainBengZhan_icon, - "sewage_water":combineBengZhan_icon, - } - let result = await facilityPumpList(); - let pumpData = result.data.filter(i => i.lon && i.lat &&i.geometrys); - let points = pumpData.map(i => turf.point([i.lon,i.lat].map(Number),{style_:{id:keys.defaultPreventWaterloggingDemo,name:i.pumpName,...(defaulGeoJSONParams.point),options:{...defaulGeoJSONParams.point.options,url:icons[i.pumpType]}}})) - console.log('points',points); - let polygons = pumpData.map(i => turf.feature(Terraformer.WKT.parse(i.geometrys),{style_:{id:keys.defaultPatrolDemo,...defaulGeoJSONParams.polygon}})); - NewFiberMapUtils.weatherToMap(newfiberMap); - /* let modelLegends = cesiumMapLegend.map(i => i.children).flat(Infinity).filter(i => i.layername.includes('Line') && i.type == '3dModel'); + static async defaultPreventWaterlogging(newfiberMap) { + const { keys } = NewFiberMapUtils.defaultParams; + NewFiberMapUtils.removeByIds([keys.defaultPreventWaterloggingDemo]); + const defaulGeoJSONParams = _.cloneDeep(mapParams.geojson); + // const icons = { + // confluence: sewageBenZhan_icon, + // rain_water: rainBengZhan_icon, + // sewage_water: combineBengZhan_icon, + // }; + // let result = await facilityPumpList(); + // let pumpData = result.data.filter(i => i.lon && i.lat && i.geometrys); + // let points = pumpData.map(i => + // turf.point([i.lon, i.lat].map(Number), { + // style_: { + // id: keys.defaultPreventWaterloggingDemo, + // name: i.pumpName, + // ...defaulGeoJSONParams.point, + // options: { ...defaulGeoJSONParams.point.options, url: icons[i.pumpType] }, + // }, + // }) + // ); + // console.log('points', points); + // let polygons = pumpData.map(i => + // turf.feature(Terraformer.WKT.parse(i.geometrys), { style_: { id: keys.defaultPatrolDemo, ...defaulGeoJSONParams.polygon } }) + // ); + NewFiberMapUtils.weatherToMap(newfiberMap); + /* let modelLegends = cesiumMapLegend.map(i => i.children).flat(Infinity).filter(i => i.layername.includes('Line') && i.type == '3dModel'); let modelIds = modelLegends.map(i => i.layername); let models = newfiberMap.getMap().scene.primitives._primitives.filter(i => modelIds.includes(i.newfiberId)); if (models.length > 0) { @@ -180,87 +211,88 @@ } else { modelLegends.forEach(i => i.data.forEach(url => newfiberVectorLayer.add3DModelLayers(newfiberMap, url, i.layername))); }*/ - riverFlow.features.forEach(i => i.properties.style_ = {id: keys.defaultPreventWaterloggingDemo, ...(defaulGeoJSONParams.polyline)}); - newfiberMap.geojsonToMap(riverFlow); - newfiberMap.geojsonToMap(turf.featureCollection([...points,...polygons])); - } + riverFlow.features.forEach(i => (i.properties.style_ = { id: keys.defaultPreventWaterloggingDemo, ...defaulGeoJSONParams.polyline })); + newfiberMap.geojsonToMap(riverFlow); + //newfiberMap.geojsonToMap(turf.featureCollection([...points, ...polygons])); + } - static async weatherToMap(newfiberMap){ - const {keys} = NewFiberMapUtils.defaultParams; - const urls = [ - "/images/weather/QPFRef_202406210650.png", - "/images/weather/QPFRef_202406210700.png", - "/images/weather/QPFRef_202406210710.png", - "/images/weather/QPFRef_202406210720.png", - "/images/weather/QPFRef_202406210730.png", - "/images/weather/QPFRef_202406210740.png", - "/images/weather/QPFRef_202406210750.png", - "/images/weather/QPFRef_202406210800.png", - "/images/weather/QPFRef_202406210810.png", - "/images/weather/QPFRef_202406210820.png", - "/images/weather/QPFRef_202406210830.png", - "/images/weather/QPFRef_202406210840.png", - "/images/weather/QPFRef_202406210850.png", - "/images/weather/QPFRef_202406210900.png", - "/images/weather/QPFRef_202406210910.png", - "/images/weather/QPFRef_202406210920.png", - "/images/weather/QPFRef_202406210930.png", - "/images/weather/QPFRef_202406210940.png", - "/images/weather/QPFRef_202406210950.png", - "/images/weather/QPFRef_202406211000.png", - "/images/weather/QPFRef_202406211010.png", - "/images/weather/QPFRef_202406211020.png", - "/images/weather/QPFRef_202406211030.png", - "/images/weather/QPFRef_202406211040.png", - "/images/weather/QPFRef_202406211050.png", - "/images/weather/QPFRef_202406211100.png", - "/images/weather/QPFRef_202406211110.png", - "/images/weather/QPFRef_202406211120.png", - "/images/weather/QPFRef_202406211130.png", - "/images/weather/QPFRef_202406211140.png", - "/images/weather/QPFRef_202406211150.png", - "/images/weather/QPFRef_202406211200.png", - "/images/weather/QPFRef_202406211210.png", - "/images/weather/QPFRef_202406211220.png", - "/images/weather/QPFRef_202406211230.png", - "/images/weather/QPFRef_202406211240.png", - "/images/weather/QPFRef_202406211250.png", - "/images/weather/QPFRef_202406211300.png", - "/images/weather/QPFRef_202406211310.png", - "/images/weather/QPFRef_202406211320.png", - "/images/weather/QPFRef_202406211330.png", - "/images/weather/QPFRef_202406211340.png", - ]; - const defaulGeoJSONParams = _.cloneDeep(mapParams.geojson); - const bbox = [73.49899858945263, 10.228437, 135.08738720258265, 53.56131497236056]; - let polygon = turf.bboxPolygon(bbox); - let i = 0; - polygon.properties.style_ = { - id: keys.weather_cloud, - ...(_.cloneDeep((defaulGeoJSONParams.polygon))), - options: Object.assign(defaulGeoJSONParams.polygon.options, { - show:false, - material: new Cesium.ImageMaterialProperty({ - transparent: true, - alpha: 0.5, - image: new Cesium.CallbackProperty(function () { - return urls[i]; - }) - }) - }) - }; - newfiberMap.geojsonToMap(turf.featureCollection([polygon])); - newfiberMap.weatherInterVal = setInterval(() => { - i++; - if (i == urls.length) { - i = 0; - } - }, 1000); - } + static async weatherToMap(newfiberMap) { + const { keys } = NewFiberMapUtils.defaultParams; + const urls = [ + '/images/weather/QPFRef_202406210650.png', + '/images/weather/QPFRef_202406210700.png', + '/images/weather/QPFRef_202406210710.png', + '/images/weather/QPFRef_202406210720.png', + '/images/weather/QPFRef_202406210730.png', + '/images/weather/QPFRef_202406210740.png', + '/images/weather/QPFRef_202406210750.png', + '/images/weather/QPFRef_202406210800.png', + '/images/weather/QPFRef_202406210810.png', + '/images/weather/QPFRef_202406210820.png', + '/images/weather/QPFRef_202406210830.png', + '/images/weather/QPFRef_202406210840.png', + '/images/weather/QPFRef_202406210850.png', + '/images/weather/QPFRef_202406210900.png', + '/images/weather/QPFRef_202406210910.png', + '/images/weather/QPFRef_202406210920.png', + '/images/weather/QPFRef_202406210930.png', + '/images/weather/QPFRef_202406210940.png', + '/images/weather/QPFRef_202406210950.png', + '/images/weather/QPFRef_202406211000.png', + '/images/weather/QPFRef_202406211010.png', + '/images/weather/QPFRef_202406211020.png', + '/images/weather/QPFRef_202406211030.png', + '/images/weather/QPFRef_202406211040.png', + '/images/weather/QPFRef_202406211050.png', + '/images/weather/QPFRef_202406211100.png', + '/images/weather/QPFRef_202406211110.png', + '/images/weather/QPFRef_202406211120.png', + '/images/weather/QPFRef_202406211130.png', + '/images/weather/QPFRef_202406211140.png', + '/images/weather/QPFRef_202406211150.png', + '/images/weather/QPFRef_202406211200.png', + '/images/weather/QPFRef_202406211210.png', + '/images/weather/QPFRef_202406211220.png', + '/images/weather/QPFRef_202406211230.png', + '/images/weather/QPFRef_202406211240.png', + '/images/weather/QPFRef_202406211250.png', + '/images/weather/QPFRef_202406211300.png', + '/images/weather/QPFRef_202406211310.png', + '/images/weather/QPFRef_202406211320.png', + '/images/weather/QPFRef_202406211330.png', + '/images/weather/QPFRef_202406211340.png', + ]; + const defaulGeoJSONParams = _.cloneDeep(mapParams.geojson); + const bbox = [73.49899858945263, 10.228437, 135.08738720258265, 53.56131497236056]; + let polygon = turf.bboxPolygon(bbox); + let i = 0; + polygon.properties.style_ = { + id: keys.weather_cloud, + ..._.cloneDeep(defaulGeoJSONParams.polygon), + options: Object.assign(defaulGeoJSONParams.polygon.options, { + show: false, + material: new Cesium.ImageMaterialProperty({ + transparent: true, + alpha: 0.5, + image: new Cesium.CallbackProperty(function () { + return urls[i]; + }), + }), + }), + }; + newfiberMap.geojsonToMap(turf.featureCollection([polygon])); + newfiberMap.weatherInterVal = setInterval(() => { + i++; + if (i == urls.length) { + i = 0; + } + }, 1000); + } - static removeByIds(ids) { - const {keys} = NewFiberMapUtils.defaultParams; - newfiberMap.removeByIds(ids); - if (ids.includes(keys.defaultPatrolDemo)) if (newfiberMap.patrolDemoTracks) newfiberMap.patrolDemoTracks.forEach(i => i.destroy()), newfiberMap.patrolDemoTracks = undefined; - } + static removeByIds(ids) { + const { keys } = NewFiberMapUtils.defaultParams; + newfiberMap.removeByIds(ids); + if (ids.includes(keys.defaultPatrolDemo)) + if (newfiberMap.patrolDemoTracks) newfiberMap.patrolDemoTracks.forEach(i => i.destroy()), (newfiberMap.patrolDemoTracks = undefined); + } } diff --git a/src/utils/gis/NewFiberMapUtils.js b/src/utils/gis/NewFiberMapUtils.js index 6c7fcc6..9b11300 100644 --- a/src/utils/gis/NewFiberMapUtils.js +++ b/src/utils/gis/NewFiberMapUtils.js @@ -1,78 +1,77 @@ -import request from "../request"; +import request from '../request'; -import rainStation_icon from "@/assets/cesiumMap/legendIcon/rainStation_icon.png"; -import spongeFacility_icon from "@/assets/cesiumMap/legendIcon/spongeFacility_icon.png"; -import sewageBenZhan_icon from "@/assets/cesiumMap/legendIcon/sewageBenZhan_icon.png" -import rainBengZhan_icon from "@/assets/cesiumMap/legendIcon/rainBengZhan_icon.png" -import combineBengZhan_icon from "@/assets/cesiumMap/legendIcon/combineBengZhan_icon.png" +import rainStation_icon from '@/assets/cesiumMap/legendIcon/rainStation_icon.png'; +import spongeFacility_icon from '@/assets/cesiumMap/legendIcon/spongeFacility_icon.png'; +import sewageBenZhan_icon from '@/assets/cesiumMap/legendIcon/sewageBenZhan_icon.png'; +import rainBengZhan_icon from '@/assets/cesiumMap/legendIcon/rainBengZhan_icon.png'; +import combineBengZhan_icon from '@/assets/cesiumMap/legendIcon/combineBengZhan_icon.png'; -import riverFlow from "@/assets/geojson/kaifeng/riverFlow.json"; +import riverFlow from '@/assets/geojson/kaifeng/riverFlow.json'; import cesiumMapLegend from '@/views/sponeScreen/gisMF/cesiumMapLegend.js'; -import newfiberVectorLayer from "@/views/sponeScreen/gisMF/newfiberVectorLayer"; +import newfiberVectorLayer from '@/views/sponeScreen/gisMF/newfiberVectorLayer'; import { facilityPumpList } from '@/api/scada/pumpStationInformation'; -let mapParams={ - geojson:{ - point:{ - type: NewFiberMap.Enum.VectorType.ICON, - options: { - url: "/static/images/icon.png", - width: 20, - height: 20, - verticalOrigin: Cesium.HorizontalOrigin.RIGHT, - pixelOffset: [0, -10], - }, - labelOptions: { - font: "17px PingFang SC", - style: Cesium.LabelStyle.FILL_AND_OUTLINE, - outlineColor: "rgba(20,83,154,1)", - outline: true, - outlineWidth: 3, - color: "#ffffff", - pixelOffset: [0, 25], - distanceDisplayCondition: [0, 5100], - }, - }, - warning:{ - type: NewFiberMap.Enum.VectorType.SPECIAL_CIRCLE, - options: { - radius: 70, - material: new NewFiberMap.Material.CircleDiffuseMaterialProperty({ - color: Cesium.Color.fromCssColorString("rgba(255,0,0, .5)"), - speed: 50, - }), - }, - }, - polyline: { - type: NewFiberMap.Enum.VectorType.POLYLINE, - options: { - show: true, - width: 6, - material:new Cesium.Spriteline1MaterialProperty(3000,'/static/images/spriteline.png'), - clampToGround: true - } - }, - polygon:{ - type: NewFiberMap.Enum.VectorType.POLYGON, - options: { - width: 1, - material: "rgba(46,196,203,0.5)", - outlineColor: "rgba(0,244,255,1)", - }, - } - } +let mapParams = { + geojson: { + point: { + type: NewFiberMap.Enum.VectorType.ICON, + options: { + url: '/static/images/icon.png', + width: 20, + height: 20, + verticalOrigin: Cesium.HorizontalOrigin.RIGHT, + pixelOffset: [0, -10], + }, + labelOptions: { + font: '17px PingFang SC', + style: Cesium.LabelStyle.FILL_AND_OUTLINE, + outlineColor: 'rgba(20,83,154,1)', + outline: true, + outlineWidth: 3, + color: '#ffffff', + pixelOffset: [0, 25], + distanceDisplayCondition: [0, 5100], + }, + }, + warning: { + type: NewFiberMap.Enum.VectorType.SPECIAL_CIRCLE, + options: { + radius: 70, + material: new NewFiberMap.Material.CircleDiffuseMaterialProperty({ + color: Cesium.Color.fromCssColorString('rgba(255,0,0, .5)'), + speed: 50, + }), + }, + }, + polyline: { + type: NewFiberMap.Enum.VectorType.POLYLINE, + options: { + show: true, + width: 6, + material: new Cesium.Spriteline1MaterialProperty(3000, '/static/images/spriteline.png'), + clampToGround: true, + }, + }, + polygon: { + type: NewFiberMap.Enum.VectorType.POLYGON, + options: { + width: 1, + material: 'rgba(46,196,203,0.5)', + outlineColor: 'rgba(0,244,255,1)', + }, + }, + }, }; export default class NewFiberMapUtils { - - static defaultParams = { - keys:{ - //巡查默认专题图 - defaultPatrolDemo:'defaultPatrolDemo', - //排水防涝默认专题图 - defaultPreventWaterloggingDemo:'defaultPreventWaterloggingDemo', - weather_cloud:'weather_cloud' - }, - /* mapParams:{ + static defaultParams = { + keys: { + //巡查默认专题图 + defaultPatrolDemo: 'defaultPatrolDemo', + //排水防涝默认专题图 + defaultPreventWaterloggingDemo: 'defaultPreventWaterloggingDemo', + weather_cloud: 'weather_cloud', + }, + /* mapParams:{ geojson:{ point:{ type: NewFiberMap.Enum.VectorType.ICON, @@ -123,56 +122,88 @@ } } }*/ - } + }; + static async defaultPatrolDemo(newfiberMap) { + const { keys } = NewFiberMapUtils.defaultParams; + const defaulGeoJSONParams = _.cloneDeep(mapParams.geojson); + const icons = { ylz: rainStation_icon, hmss: spongeFacility_icon, car: '/images/car.png' }; + NewFiberMapUtils.removeByIds([keys.defaultPatrolDemo]); - static async defaultPatrolDemo(newfiberMap) { - const {keys} = NewFiberMapUtils.defaultParams; - const defaulGeoJSONParams = _.cloneDeep(mapParams.geojson); - const icons = {ylz:rainStation_icon, hmss:spongeFacility_icon, car:"/images/car.png"}; - NewFiberMapUtils.removeByIds([keys.defaultPatrolDemo]); + let results = await Promise.all(['/static/json/malfunction.json', '/static/json/track.json'].map(i => request(i))); + let warningData = _.cloneDeep(results[0]); + results[0].features.forEach( + i => + (i.properties.style_ = _.cloneDeep({ + id: keys.defaultPatrolDemo, + name: i.properties.name, + ...defaulGeoJSONParams.point, + options: Object.assign(defaulGeoJSONParams.point.options, { url: icons[i.properties.type] }), + })) + ); + warningData.features.forEach(i => (i.properties.style_ = { id: keys.defaultPatrolDemo, ...defaulGeoJSONParams.warning })); + let markers = warningData.features.concat(results[0].features); + newfiberMap.geojsonToMap(turf.featureCollection(markers)); - let results = await Promise.all(['/static/json/malfunction.json','/static/json/track.json'].map(i => request(i))); - let warningData = _.cloneDeep(results[0]); - results[0].features.forEach(i => (i.properties.style_ = _.cloneDeep({id:keys.defaultPatrolDemo,name:i.properties.name,...(defaulGeoJSONParams.point),options:Object.assign(defaulGeoJSONParams.point.options,{url:icons[i.properties.type]})}))); - warningData.features.forEach(i => (i.properties.style_ = {id:keys.defaultPatrolDemo,...(defaulGeoJSONParams.warning)})); - let markers = warningData.features.concat(results[0].features); - newfiberMap.geojsonToMap(turf.featureCollection(markers)); + newfiberMap.patrolDemoTracks = results[1].features.map(feature => { + let datas = turf.getCoords(feature.geometry).map(coords => ({ l: coords[0], a: coords[1], height: 10, time: 10 })); + return new NewFiberMap.Layer.RunningPath({ + paths: datas, + name, + newfiberMap, + options: { + style: { move: icons.car }, + perSec: 5, + speed: 10, + pathColor: [38, 178, 107, 1], + passPathColor: [89, 91, 93, 1], + isStart: false, + isEnd: false, + fields: { lng: 'l', lat: 'a', height: 'height', time: 'time' }, + }, + }); + }); - newfiberMap.patrolDemoTracks = results[1].features.map(feature => { - let datas = turf.getCoords(feature.geometry).map(coords => ({l:coords[0],a:coords[1],height:10,time:10})); - return new NewFiberMap.Layer.RunningPath({paths:datas,name, newfiberMap,options:{style:{move:icons.car},perSec:5,speed:10,pathColor:[38,178,107,1],passPathColor:[89,91,93,1], isStart:false, isEnd:false, fields:{lng:'l',lat:'a',height: 'height',time:'time'}}}); - }); + let timeout = setTimeout(() => { + newfiberMap.setView({ + lng: 114.332, + lat: 34.662, + heading: 2.281299097855777, + zoom: 6358.12942752382, + pitch: -25.2508969308367, + roll: 0.005453465256790101, + }); + clearTimeout(timeout); + }, 4000); + } - let timeout = setTimeout(() => { - newfiberMap.setView({ - lng: 114.312, - lat: 34.502, - heading: 2.281299097855777, - zoom: 16358.12942752382, - pitch: -25.2508969308367, - roll: 0.005453465256790101, - }); - clearTimeout(timeout); - }, 4000); - } - - static async defaultPreventWaterlogging(newfiberMap){ - const { keys} = NewFiberMapUtils.defaultParams; - NewFiberMapUtils.removeByIds([keys.defaultPreventWaterloggingDemo]); - const defaulGeoJSONParams = _.cloneDeep(mapParams.geojson); - const icons = { - "confluence":sewageBenZhan_icon, - "rain_water":rainBengZhan_icon, - "sewage_water":combineBengZhan_icon, - } - let result = await facilityPumpList(); - let pumpData = result.data.filter(i => i.lon && i.lat &&i.geometrys); - let points = pumpData.map(i => turf.point([i.lon,i.lat].map(Number),{style_:{id:keys.defaultPreventWaterloggingDemo,name:i.pumpName,...(defaulGeoJSONParams.point),options:{...defaulGeoJSONParams.point.options,url:icons[i.pumpType]}}})) - console.log('points',points); - let polygons = pumpData.map(i => turf.feature(Terraformer.WKT.parse(i.geometrys),{style_:{id:keys.defaultPatrolDemo,...defaulGeoJSONParams.polygon}})); - NewFiberMapUtils.weatherToMap(newfiberMap); - /* let modelLegends = cesiumMapLegend.map(i => i.children).flat(Infinity).filter(i => i.layername.includes('Line') && i.type == '3dModel'); + static async defaultPreventWaterlogging(newfiberMap) { + const { keys } = NewFiberMapUtils.defaultParams; + NewFiberMapUtils.removeByIds([keys.defaultPreventWaterloggingDemo]); + const defaulGeoJSONParams = _.cloneDeep(mapParams.geojson); + // const icons = { + // confluence: sewageBenZhan_icon, + // rain_water: rainBengZhan_icon, + // sewage_water: combineBengZhan_icon, + // }; + // let result = await facilityPumpList(); + // let pumpData = result.data.filter(i => i.lon && i.lat && i.geometrys); + // let points = pumpData.map(i => + // turf.point([i.lon, i.lat].map(Number), { + // style_: { + // id: keys.defaultPreventWaterloggingDemo, + // name: i.pumpName, + // ...defaulGeoJSONParams.point, + // options: { ...defaulGeoJSONParams.point.options, url: icons[i.pumpType] }, + // }, + // }) + // ); + // console.log('points', points); + // let polygons = pumpData.map(i => + // turf.feature(Terraformer.WKT.parse(i.geometrys), { style_: { id: keys.defaultPatrolDemo, ...defaulGeoJSONParams.polygon } }) + // ); + NewFiberMapUtils.weatherToMap(newfiberMap); + /* let modelLegends = cesiumMapLegend.map(i => i.children).flat(Infinity).filter(i => i.layername.includes('Line') && i.type == '3dModel'); let modelIds = modelLegends.map(i => i.layername); let models = newfiberMap.getMap().scene.primitives._primitives.filter(i => modelIds.includes(i.newfiberId)); if (models.length > 0) { @@ -180,87 +211,88 @@ } else { modelLegends.forEach(i => i.data.forEach(url => newfiberVectorLayer.add3DModelLayers(newfiberMap, url, i.layername))); }*/ - riverFlow.features.forEach(i => i.properties.style_ = {id: keys.defaultPreventWaterloggingDemo, ...(defaulGeoJSONParams.polyline)}); - newfiberMap.geojsonToMap(riverFlow); - newfiberMap.geojsonToMap(turf.featureCollection([...points,...polygons])); - } + riverFlow.features.forEach(i => (i.properties.style_ = { id: keys.defaultPreventWaterloggingDemo, ...defaulGeoJSONParams.polyline })); + newfiberMap.geojsonToMap(riverFlow); + //newfiberMap.geojsonToMap(turf.featureCollection([...points, ...polygons])); + } - static async weatherToMap(newfiberMap){ - const {keys} = NewFiberMapUtils.defaultParams; - const urls = [ - "/images/weather/QPFRef_202406210650.png", - "/images/weather/QPFRef_202406210700.png", - "/images/weather/QPFRef_202406210710.png", - "/images/weather/QPFRef_202406210720.png", - "/images/weather/QPFRef_202406210730.png", - "/images/weather/QPFRef_202406210740.png", - "/images/weather/QPFRef_202406210750.png", - "/images/weather/QPFRef_202406210800.png", - "/images/weather/QPFRef_202406210810.png", - "/images/weather/QPFRef_202406210820.png", - "/images/weather/QPFRef_202406210830.png", - "/images/weather/QPFRef_202406210840.png", - "/images/weather/QPFRef_202406210850.png", - "/images/weather/QPFRef_202406210900.png", - "/images/weather/QPFRef_202406210910.png", - "/images/weather/QPFRef_202406210920.png", - "/images/weather/QPFRef_202406210930.png", - "/images/weather/QPFRef_202406210940.png", - "/images/weather/QPFRef_202406210950.png", - "/images/weather/QPFRef_202406211000.png", - "/images/weather/QPFRef_202406211010.png", - "/images/weather/QPFRef_202406211020.png", - "/images/weather/QPFRef_202406211030.png", - "/images/weather/QPFRef_202406211040.png", - "/images/weather/QPFRef_202406211050.png", - "/images/weather/QPFRef_202406211100.png", - "/images/weather/QPFRef_202406211110.png", - "/images/weather/QPFRef_202406211120.png", - "/images/weather/QPFRef_202406211130.png", - "/images/weather/QPFRef_202406211140.png", - "/images/weather/QPFRef_202406211150.png", - "/images/weather/QPFRef_202406211200.png", - "/images/weather/QPFRef_202406211210.png", - "/images/weather/QPFRef_202406211220.png", - "/images/weather/QPFRef_202406211230.png", - "/images/weather/QPFRef_202406211240.png", - "/images/weather/QPFRef_202406211250.png", - "/images/weather/QPFRef_202406211300.png", - "/images/weather/QPFRef_202406211310.png", - "/images/weather/QPFRef_202406211320.png", - "/images/weather/QPFRef_202406211330.png", - "/images/weather/QPFRef_202406211340.png", - ]; - const defaulGeoJSONParams = _.cloneDeep(mapParams.geojson); - const bbox = [73.49899858945263, 10.228437, 135.08738720258265, 53.56131497236056]; - let polygon = turf.bboxPolygon(bbox); - let i = 0; - polygon.properties.style_ = { - id: keys.weather_cloud, - ...(_.cloneDeep((defaulGeoJSONParams.polygon))), - options: Object.assign(defaulGeoJSONParams.polygon.options, { - show:false, - material: new Cesium.ImageMaterialProperty({ - transparent: true, - alpha: 0.5, - image: new Cesium.CallbackProperty(function () { - return urls[i]; - }) - }) - }) - }; - newfiberMap.geojsonToMap(turf.featureCollection([polygon])); - newfiberMap.weatherInterVal = setInterval(() => { - i++; - if (i == urls.length) { - i = 0; - } - }, 1000); - } + static async weatherToMap(newfiberMap) { + const { keys } = NewFiberMapUtils.defaultParams; + const urls = [ + '/images/weather/QPFRef_202406210650.png', + '/images/weather/QPFRef_202406210700.png', + '/images/weather/QPFRef_202406210710.png', + '/images/weather/QPFRef_202406210720.png', + '/images/weather/QPFRef_202406210730.png', + '/images/weather/QPFRef_202406210740.png', + '/images/weather/QPFRef_202406210750.png', + '/images/weather/QPFRef_202406210800.png', + '/images/weather/QPFRef_202406210810.png', + '/images/weather/QPFRef_202406210820.png', + '/images/weather/QPFRef_202406210830.png', + '/images/weather/QPFRef_202406210840.png', + '/images/weather/QPFRef_202406210850.png', + '/images/weather/QPFRef_202406210900.png', + '/images/weather/QPFRef_202406210910.png', + '/images/weather/QPFRef_202406210920.png', + '/images/weather/QPFRef_202406210930.png', + '/images/weather/QPFRef_202406210940.png', + '/images/weather/QPFRef_202406210950.png', + '/images/weather/QPFRef_202406211000.png', + '/images/weather/QPFRef_202406211010.png', + '/images/weather/QPFRef_202406211020.png', + '/images/weather/QPFRef_202406211030.png', + '/images/weather/QPFRef_202406211040.png', + '/images/weather/QPFRef_202406211050.png', + '/images/weather/QPFRef_202406211100.png', + '/images/weather/QPFRef_202406211110.png', + '/images/weather/QPFRef_202406211120.png', + '/images/weather/QPFRef_202406211130.png', + '/images/weather/QPFRef_202406211140.png', + '/images/weather/QPFRef_202406211150.png', + '/images/weather/QPFRef_202406211200.png', + '/images/weather/QPFRef_202406211210.png', + '/images/weather/QPFRef_202406211220.png', + '/images/weather/QPFRef_202406211230.png', + '/images/weather/QPFRef_202406211240.png', + '/images/weather/QPFRef_202406211250.png', + '/images/weather/QPFRef_202406211300.png', + '/images/weather/QPFRef_202406211310.png', + '/images/weather/QPFRef_202406211320.png', + '/images/weather/QPFRef_202406211330.png', + '/images/weather/QPFRef_202406211340.png', + ]; + const defaulGeoJSONParams = _.cloneDeep(mapParams.geojson); + const bbox = [73.49899858945263, 10.228437, 135.08738720258265, 53.56131497236056]; + let polygon = turf.bboxPolygon(bbox); + let i = 0; + polygon.properties.style_ = { + id: keys.weather_cloud, + ..._.cloneDeep(defaulGeoJSONParams.polygon), + options: Object.assign(defaulGeoJSONParams.polygon.options, { + show: false, + material: new Cesium.ImageMaterialProperty({ + transparent: true, + alpha: 0.5, + image: new Cesium.CallbackProperty(function () { + return urls[i]; + }), + }), + }), + }; + newfiberMap.geojsonToMap(turf.featureCollection([polygon])); + newfiberMap.weatherInterVal = setInterval(() => { + i++; + if (i == urls.length) { + i = 0; + } + }, 1000); + } - static removeByIds(ids) { - const {keys} = NewFiberMapUtils.defaultParams; - newfiberMap.removeByIds(ids); - if (ids.includes(keys.defaultPatrolDemo)) if (newfiberMap.patrolDemoTracks) newfiberMap.patrolDemoTracks.forEach(i => i.destroy()), newfiberMap.patrolDemoTracks = undefined; - } + static removeByIds(ids) { + const { keys } = NewFiberMapUtils.defaultParams; + newfiberMap.removeByIds(ids); + if (ids.includes(keys.defaultPatrolDemo)) + if (newfiberMap.patrolDemoTracks) newfiberMap.patrolDemoTracks.forEach(i => i.destroy()), (newfiberMap.patrolDemoTracks = undefined); + } } diff --git a/src/views/sponeScreen/HaiMianScreen/index.vue b/src/views/sponeScreen/HaiMianScreen/index.vue index d4bc553..73ca7d3 100644 --- a/src/views/sponeScreen/HaiMianScreen/index.vue +++ b/src/views/sponeScreen/HaiMianScreen/index.vue @@ -91,8 +91,38 @@ function menuClick(id) { menuIndex.value = id; showPanel.value = false; + bus.emit('setIniteLayer', [ + { + layername: 'YSBZ', + show: true, + }, + { + layername: 'WSBZ', + show: true, + }, + { + layername: 'rainLine', + show: true, + }, + ]); NewFiberMapUtils.removeByIds(Object.values(NewFiberMapUtils.defaultParams.keys)); - if (id == 4) NewFiberMapUtils.defaultPreventWaterlogging(newfiberMap); + if (id == 4) { + bus.emit('setIniteLayer', [ + { + layername: 'YSBZ', + show: false, + }, + { + layername: 'WSBZ', + show: false, + }, + { + layername: 'rainLine', + show: false, + }, + ]); + NewFiberMapUtils.defaultPreventWaterlogging(newfiberMap); + } if (id == 5) NewFiberMapUtils.defaultPatrolDemo(newfiberMap); } // 图例控制 diff --git a/src/utils/gis/NewFiberMapUtils.js b/src/utils/gis/NewFiberMapUtils.js index 6c7fcc6..9b11300 100644 --- a/src/utils/gis/NewFiberMapUtils.js +++ b/src/utils/gis/NewFiberMapUtils.js @@ -1,78 +1,77 @@ -import request from "../request"; +import request from '../request'; -import rainStation_icon from "@/assets/cesiumMap/legendIcon/rainStation_icon.png"; -import spongeFacility_icon from "@/assets/cesiumMap/legendIcon/spongeFacility_icon.png"; -import sewageBenZhan_icon from "@/assets/cesiumMap/legendIcon/sewageBenZhan_icon.png" -import rainBengZhan_icon from "@/assets/cesiumMap/legendIcon/rainBengZhan_icon.png" -import combineBengZhan_icon from "@/assets/cesiumMap/legendIcon/combineBengZhan_icon.png" +import rainStation_icon from '@/assets/cesiumMap/legendIcon/rainStation_icon.png'; +import spongeFacility_icon from '@/assets/cesiumMap/legendIcon/spongeFacility_icon.png'; +import sewageBenZhan_icon from '@/assets/cesiumMap/legendIcon/sewageBenZhan_icon.png'; +import rainBengZhan_icon from '@/assets/cesiumMap/legendIcon/rainBengZhan_icon.png'; +import combineBengZhan_icon from '@/assets/cesiumMap/legendIcon/combineBengZhan_icon.png'; -import riverFlow from "@/assets/geojson/kaifeng/riverFlow.json"; +import riverFlow from '@/assets/geojson/kaifeng/riverFlow.json'; import cesiumMapLegend from '@/views/sponeScreen/gisMF/cesiumMapLegend.js'; -import newfiberVectorLayer from "@/views/sponeScreen/gisMF/newfiberVectorLayer"; +import newfiberVectorLayer from '@/views/sponeScreen/gisMF/newfiberVectorLayer'; import { facilityPumpList } from '@/api/scada/pumpStationInformation'; -let mapParams={ - geojson:{ - point:{ - type: NewFiberMap.Enum.VectorType.ICON, - options: { - url: "/static/images/icon.png", - width: 20, - height: 20, - verticalOrigin: Cesium.HorizontalOrigin.RIGHT, - pixelOffset: [0, -10], - }, - labelOptions: { - font: "17px PingFang SC", - style: Cesium.LabelStyle.FILL_AND_OUTLINE, - outlineColor: "rgba(20,83,154,1)", - outline: true, - outlineWidth: 3, - color: "#ffffff", - pixelOffset: [0, 25], - distanceDisplayCondition: [0, 5100], - }, - }, - warning:{ - type: NewFiberMap.Enum.VectorType.SPECIAL_CIRCLE, - options: { - radius: 70, - material: new NewFiberMap.Material.CircleDiffuseMaterialProperty({ - color: Cesium.Color.fromCssColorString("rgba(255,0,0, .5)"), - speed: 50, - }), - }, - }, - polyline: { - type: NewFiberMap.Enum.VectorType.POLYLINE, - options: { - show: true, - width: 6, - material:new Cesium.Spriteline1MaterialProperty(3000,'/static/images/spriteline.png'), - clampToGround: true - } - }, - polygon:{ - type: NewFiberMap.Enum.VectorType.POLYGON, - options: { - width: 1, - material: "rgba(46,196,203,0.5)", - outlineColor: "rgba(0,244,255,1)", - }, - } - } +let mapParams = { + geojson: { + point: { + type: NewFiberMap.Enum.VectorType.ICON, + options: { + url: '/static/images/icon.png', + width: 20, + height: 20, + verticalOrigin: Cesium.HorizontalOrigin.RIGHT, + pixelOffset: [0, -10], + }, + labelOptions: { + font: '17px PingFang SC', + style: Cesium.LabelStyle.FILL_AND_OUTLINE, + outlineColor: 'rgba(20,83,154,1)', + outline: true, + outlineWidth: 3, + color: '#ffffff', + pixelOffset: [0, 25], + distanceDisplayCondition: [0, 5100], + }, + }, + warning: { + type: NewFiberMap.Enum.VectorType.SPECIAL_CIRCLE, + options: { + radius: 70, + material: new NewFiberMap.Material.CircleDiffuseMaterialProperty({ + color: Cesium.Color.fromCssColorString('rgba(255,0,0, .5)'), + speed: 50, + }), + }, + }, + polyline: { + type: NewFiberMap.Enum.VectorType.POLYLINE, + options: { + show: true, + width: 6, + material: new Cesium.Spriteline1MaterialProperty(3000, '/static/images/spriteline.png'), + clampToGround: true, + }, + }, + polygon: { + type: NewFiberMap.Enum.VectorType.POLYGON, + options: { + width: 1, + material: 'rgba(46,196,203,0.5)', + outlineColor: 'rgba(0,244,255,1)', + }, + }, + }, }; export default class NewFiberMapUtils { - - static defaultParams = { - keys:{ - //巡查默认专题图 - defaultPatrolDemo:'defaultPatrolDemo', - //排水防涝默认专题图 - defaultPreventWaterloggingDemo:'defaultPreventWaterloggingDemo', - weather_cloud:'weather_cloud' - }, - /* mapParams:{ + static defaultParams = { + keys: { + //巡查默认专题图 + defaultPatrolDemo: 'defaultPatrolDemo', + //排水防涝默认专题图 + defaultPreventWaterloggingDemo: 'defaultPreventWaterloggingDemo', + weather_cloud: 'weather_cloud', + }, + /* mapParams:{ geojson:{ point:{ type: NewFiberMap.Enum.VectorType.ICON, @@ -123,56 +122,88 @@ } } }*/ - } + }; + static async defaultPatrolDemo(newfiberMap) { + const { keys } = NewFiberMapUtils.defaultParams; + const defaulGeoJSONParams = _.cloneDeep(mapParams.geojson); + const icons = { ylz: rainStation_icon, hmss: spongeFacility_icon, car: '/images/car.png' }; + NewFiberMapUtils.removeByIds([keys.defaultPatrolDemo]); - static async defaultPatrolDemo(newfiberMap) { - const {keys} = NewFiberMapUtils.defaultParams; - const defaulGeoJSONParams = _.cloneDeep(mapParams.geojson); - const icons = {ylz:rainStation_icon, hmss:spongeFacility_icon, car:"/images/car.png"}; - NewFiberMapUtils.removeByIds([keys.defaultPatrolDemo]); + let results = await Promise.all(['/static/json/malfunction.json', '/static/json/track.json'].map(i => request(i))); + let warningData = _.cloneDeep(results[0]); + results[0].features.forEach( + i => + (i.properties.style_ = _.cloneDeep({ + id: keys.defaultPatrolDemo, + name: i.properties.name, + ...defaulGeoJSONParams.point, + options: Object.assign(defaulGeoJSONParams.point.options, { url: icons[i.properties.type] }), + })) + ); + warningData.features.forEach(i => (i.properties.style_ = { id: keys.defaultPatrolDemo, ...defaulGeoJSONParams.warning })); + let markers = warningData.features.concat(results[0].features); + newfiberMap.geojsonToMap(turf.featureCollection(markers)); - let results = await Promise.all(['/static/json/malfunction.json','/static/json/track.json'].map(i => request(i))); - let warningData = _.cloneDeep(results[0]); - results[0].features.forEach(i => (i.properties.style_ = _.cloneDeep({id:keys.defaultPatrolDemo,name:i.properties.name,...(defaulGeoJSONParams.point),options:Object.assign(defaulGeoJSONParams.point.options,{url:icons[i.properties.type]})}))); - warningData.features.forEach(i => (i.properties.style_ = {id:keys.defaultPatrolDemo,...(defaulGeoJSONParams.warning)})); - let markers = warningData.features.concat(results[0].features); - newfiberMap.geojsonToMap(turf.featureCollection(markers)); + newfiberMap.patrolDemoTracks = results[1].features.map(feature => { + let datas = turf.getCoords(feature.geometry).map(coords => ({ l: coords[0], a: coords[1], height: 10, time: 10 })); + return new NewFiberMap.Layer.RunningPath({ + paths: datas, + name, + newfiberMap, + options: { + style: { move: icons.car }, + perSec: 5, + speed: 10, + pathColor: [38, 178, 107, 1], + passPathColor: [89, 91, 93, 1], + isStart: false, + isEnd: false, + fields: { lng: 'l', lat: 'a', height: 'height', time: 'time' }, + }, + }); + }); - newfiberMap.patrolDemoTracks = results[1].features.map(feature => { - let datas = turf.getCoords(feature.geometry).map(coords => ({l:coords[0],a:coords[1],height:10,time:10})); - return new NewFiberMap.Layer.RunningPath({paths:datas,name, newfiberMap,options:{style:{move:icons.car},perSec:5,speed:10,pathColor:[38,178,107,1],passPathColor:[89,91,93,1], isStart:false, isEnd:false, fields:{lng:'l',lat:'a',height: 'height',time:'time'}}}); - }); + let timeout = setTimeout(() => { + newfiberMap.setView({ + lng: 114.332, + lat: 34.662, + heading: 2.281299097855777, + zoom: 6358.12942752382, + pitch: -25.2508969308367, + roll: 0.005453465256790101, + }); + clearTimeout(timeout); + }, 4000); + } - let timeout = setTimeout(() => { - newfiberMap.setView({ - lng: 114.312, - lat: 34.502, - heading: 2.281299097855777, - zoom: 16358.12942752382, - pitch: -25.2508969308367, - roll: 0.005453465256790101, - }); - clearTimeout(timeout); - }, 4000); - } - - static async defaultPreventWaterlogging(newfiberMap){ - const { keys} = NewFiberMapUtils.defaultParams; - NewFiberMapUtils.removeByIds([keys.defaultPreventWaterloggingDemo]); - const defaulGeoJSONParams = _.cloneDeep(mapParams.geojson); - const icons = { - "confluence":sewageBenZhan_icon, - "rain_water":rainBengZhan_icon, - "sewage_water":combineBengZhan_icon, - } - let result = await facilityPumpList(); - let pumpData = result.data.filter(i => i.lon && i.lat &&i.geometrys); - let points = pumpData.map(i => turf.point([i.lon,i.lat].map(Number),{style_:{id:keys.defaultPreventWaterloggingDemo,name:i.pumpName,...(defaulGeoJSONParams.point),options:{...defaulGeoJSONParams.point.options,url:icons[i.pumpType]}}})) - console.log('points',points); - let polygons = pumpData.map(i => turf.feature(Terraformer.WKT.parse(i.geometrys),{style_:{id:keys.defaultPatrolDemo,...defaulGeoJSONParams.polygon}})); - NewFiberMapUtils.weatherToMap(newfiberMap); - /* let modelLegends = cesiumMapLegend.map(i => i.children).flat(Infinity).filter(i => i.layername.includes('Line') && i.type == '3dModel'); + static async defaultPreventWaterlogging(newfiberMap) { + const { keys } = NewFiberMapUtils.defaultParams; + NewFiberMapUtils.removeByIds([keys.defaultPreventWaterloggingDemo]); + const defaulGeoJSONParams = _.cloneDeep(mapParams.geojson); + // const icons = { + // confluence: sewageBenZhan_icon, + // rain_water: rainBengZhan_icon, + // sewage_water: combineBengZhan_icon, + // }; + // let result = await facilityPumpList(); + // let pumpData = result.data.filter(i => i.lon && i.lat && i.geometrys); + // let points = pumpData.map(i => + // turf.point([i.lon, i.lat].map(Number), { + // style_: { + // id: keys.defaultPreventWaterloggingDemo, + // name: i.pumpName, + // ...defaulGeoJSONParams.point, + // options: { ...defaulGeoJSONParams.point.options, url: icons[i.pumpType] }, + // }, + // }) + // ); + // console.log('points', points); + // let polygons = pumpData.map(i => + // turf.feature(Terraformer.WKT.parse(i.geometrys), { style_: { id: keys.defaultPatrolDemo, ...defaulGeoJSONParams.polygon } }) + // ); + NewFiberMapUtils.weatherToMap(newfiberMap); + /* let modelLegends = cesiumMapLegend.map(i => i.children).flat(Infinity).filter(i => i.layername.includes('Line') && i.type == '3dModel'); let modelIds = modelLegends.map(i => i.layername); let models = newfiberMap.getMap().scene.primitives._primitives.filter(i => modelIds.includes(i.newfiberId)); if (models.length > 0) { @@ -180,87 +211,88 @@ } else { modelLegends.forEach(i => i.data.forEach(url => newfiberVectorLayer.add3DModelLayers(newfiberMap, url, i.layername))); }*/ - riverFlow.features.forEach(i => i.properties.style_ = {id: keys.defaultPreventWaterloggingDemo, ...(defaulGeoJSONParams.polyline)}); - newfiberMap.geojsonToMap(riverFlow); - newfiberMap.geojsonToMap(turf.featureCollection([...points,...polygons])); - } + riverFlow.features.forEach(i => (i.properties.style_ = { id: keys.defaultPreventWaterloggingDemo, ...defaulGeoJSONParams.polyline })); + newfiberMap.geojsonToMap(riverFlow); + //newfiberMap.geojsonToMap(turf.featureCollection([...points, ...polygons])); + } - static async weatherToMap(newfiberMap){ - const {keys} = NewFiberMapUtils.defaultParams; - const urls = [ - "/images/weather/QPFRef_202406210650.png", - "/images/weather/QPFRef_202406210700.png", - "/images/weather/QPFRef_202406210710.png", - "/images/weather/QPFRef_202406210720.png", - "/images/weather/QPFRef_202406210730.png", - "/images/weather/QPFRef_202406210740.png", - "/images/weather/QPFRef_202406210750.png", - "/images/weather/QPFRef_202406210800.png", - "/images/weather/QPFRef_202406210810.png", - "/images/weather/QPFRef_202406210820.png", - "/images/weather/QPFRef_202406210830.png", - "/images/weather/QPFRef_202406210840.png", - "/images/weather/QPFRef_202406210850.png", - "/images/weather/QPFRef_202406210900.png", - "/images/weather/QPFRef_202406210910.png", - "/images/weather/QPFRef_202406210920.png", - "/images/weather/QPFRef_202406210930.png", - "/images/weather/QPFRef_202406210940.png", - "/images/weather/QPFRef_202406210950.png", - "/images/weather/QPFRef_202406211000.png", - "/images/weather/QPFRef_202406211010.png", - "/images/weather/QPFRef_202406211020.png", - "/images/weather/QPFRef_202406211030.png", - "/images/weather/QPFRef_202406211040.png", - "/images/weather/QPFRef_202406211050.png", - "/images/weather/QPFRef_202406211100.png", - "/images/weather/QPFRef_202406211110.png", - "/images/weather/QPFRef_202406211120.png", - "/images/weather/QPFRef_202406211130.png", - "/images/weather/QPFRef_202406211140.png", - "/images/weather/QPFRef_202406211150.png", - "/images/weather/QPFRef_202406211200.png", - "/images/weather/QPFRef_202406211210.png", - "/images/weather/QPFRef_202406211220.png", - "/images/weather/QPFRef_202406211230.png", - "/images/weather/QPFRef_202406211240.png", - "/images/weather/QPFRef_202406211250.png", - "/images/weather/QPFRef_202406211300.png", - "/images/weather/QPFRef_202406211310.png", - "/images/weather/QPFRef_202406211320.png", - "/images/weather/QPFRef_202406211330.png", - "/images/weather/QPFRef_202406211340.png", - ]; - const defaulGeoJSONParams = _.cloneDeep(mapParams.geojson); - const bbox = [73.49899858945263, 10.228437, 135.08738720258265, 53.56131497236056]; - let polygon = turf.bboxPolygon(bbox); - let i = 0; - polygon.properties.style_ = { - id: keys.weather_cloud, - ...(_.cloneDeep((defaulGeoJSONParams.polygon))), - options: Object.assign(defaulGeoJSONParams.polygon.options, { - show:false, - material: new Cesium.ImageMaterialProperty({ - transparent: true, - alpha: 0.5, - image: new Cesium.CallbackProperty(function () { - return urls[i]; - }) - }) - }) - }; - newfiberMap.geojsonToMap(turf.featureCollection([polygon])); - newfiberMap.weatherInterVal = setInterval(() => { - i++; - if (i == urls.length) { - i = 0; - } - }, 1000); - } + static async weatherToMap(newfiberMap) { + const { keys } = NewFiberMapUtils.defaultParams; + const urls = [ + '/images/weather/QPFRef_202406210650.png', + '/images/weather/QPFRef_202406210700.png', + '/images/weather/QPFRef_202406210710.png', + '/images/weather/QPFRef_202406210720.png', + '/images/weather/QPFRef_202406210730.png', + '/images/weather/QPFRef_202406210740.png', + '/images/weather/QPFRef_202406210750.png', + '/images/weather/QPFRef_202406210800.png', + '/images/weather/QPFRef_202406210810.png', + '/images/weather/QPFRef_202406210820.png', + '/images/weather/QPFRef_202406210830.png', + '/images/weather/QPFRef_202406210840.png', + '/images/weather/QPFRef_202406210850.png', + '/images/weather/QPFRef_202406210900.png', + '/images/weather/QPFRef_202406210910.png', + '/images/weather/QPFRef_202406210920.png', + '/images/weather/QPFRef_202406210930.png', + '/images/weather/QPFRef_202406210940.png', + '/images/weather/QPFRef_202406210950.png', + '/images/weather/QPFRef_202406211000.png', + '/images/weather/QPFRef_202406211010.png', + '/images/weather/QPFRef_202406211020.png', + '/images/weather/QPFRef_202406211030.png', + '/images/weather/QPFRef_202406211040.png', + '/images/weather/QPFRef_202406211050.png', + '/images/weather/QPFRef_202406211100.png', + '/images/weather/QPFRef_202406211110.png', + '/images/weather/QPFRef_202406211120.png', + '/images/weather/QPFRef_202406211130.png', + '/images/weather/QPFRef_202406211140.png', + '/images/weather/QPFRef_202406211150.png', + '/images/weather/QPFRef_202406211200.png', + '/images/weather/QPFRef_202406211210.png', + '/images/weather/QPFRef_202406211220.png', + '/images/weather/QPFRef_202406211230.png', + '/images/weather/QPFRef_202406211240.png', + '/images/weather/QPFRef_202406211250.png', + '/images/weather/QPFRef_202406211300.png', + '/images/weather/QPFRef_202406211310.png', + '/images/weather/QPFRef_202406211320.png', + '/images/weather/QPFRef_202406211330.png', + '/images/weather/QPFRef_202406211340.png', + ]; + const defaulGeoJSONParams = _.cloneDeep(mapParams.geojson); + const bbox = [73.49899858945263, 10.228437, 135.08738720258265, 53.56131497236056]; + let polygon = turf.bboxPolygon(bbox); + let i = 0; + polygon.properties.style_ = { + id: keys.weather_cloud, + ..._.cloneDeep(defaulGeoJSONParams.polygon), + options: Object.assign(defaulGeoJSONParams.polygon.options, { + show: false, + material: new Cesium.ImageMaterialProperty({ + transparent: true, + alpha: 0.5, + image: new Cesium.CallbackProperty(function () { + return urls[i]; + }), + }), + }), + }; + newfiberMap.geojsonToMap(turf.featureCollection([polygon])); + newfiberMap.weatherInterVal = setInterval(() => { + i++; + if (i == urls.length) { + i = 0; + } + }, 1000); + } - static removeByIds(ids) { - const {keys} = NewFiberMapUtils.defaultParams; - newfiberMap.removeByIds(ids); - if (ids.includes(keys.defaultPatrolDemo)) if (newfiberMap.patrolDemoTracks) newfiberMap.patrolDemoTracks.forEach(i => i.destroy()), newfiberMap.patrolDemoTracks = undefined; - } + static removeByIds(ids) { + const { keys } = NewFiberMapUtils.defaultParams; + newfiberMap.removeByIds(ids); + if (ids.includes(keys.defaultPatrolDemo)) + if (newfiberMap.patrolDemoTracks) newfiberMap.patrolDemoTracks.forEach(i => i.destroy()), (newfiberMap.patrolDemoTracks = undefined); + } } diff --git a/src/views/sponeScreen/HaiMianScreen/index.vue b/src/views/sponeScreen/HaiMianScreen/index.vue index d4bc553..73ca7d3 100644 --- a/src/views/sponeScreen/HaiMianScreen/index.vue +++ b/src/views/sponeScreen/HaiMianScreen/index.vue @@ -91,8 +91,38 @@ function menuClick(id) { menuIndex.value = id; showPanel.value = false; + bus.emit('setIniteLayer', [ + { + layername: 'YSBZ', + show: true, + }, + { + layername: 'WSBZ', + show: true, + }, + { + layername: 'rainLine', + show: true, + }, + ]); NewFiberMapUtils.removeByIds(Object.values(NewFiberMapUtils.defaultParams.keys)); - if (id == 4) NewFiberMapUtils.defaultPreventWaterlogging(newfiberMap); + if (id == 4) { + bus.emit('setIniteLayer', [ + { + layername: 'YSBZ', + show: false, + }, + { + layername: 'WSBZ', + show: false, + }, + { + layername: 'rainLine', + show: false, + }, + ]); + NewFiberMapUtils.defaultPreventWaterlogging(newfiberMap); + } if (id == 5) NewFiberMapUtils.defaultPatrolDemo(newfiberMap); } // 图例控制 diff --git a/src/views/sponeScreen/cityGK/PhysicalGeography.vue b/src/views/sponeScreen/cityGK/PhysicalGeography.vue index 6a751d9..6d28612 100644 --- a/src/views/sponeScreen/cityGK/PhysicalGeography.vue +++ b/src/views/sponeScreen/cityGK/PhysicalGeography.vue @@ -97,6 +97,14 @@ show: true, }, ]); + newfiberMap.setCenter({ + lng: 114.312, + lat: 34.202, + heading: 2.281299097855777, + zoom: 35358.12942752382, + pitch: -25.2508969308367, + roll: 0.005453465256790101, + }); }; const showCenterCity = () => { newfiberMap.removeByIds(['oneCenter']); @@ -118,6 +126,14 @@ show: false, }, ]); + newfiberMap.setCenter({ + lng: 114.312, + lat: 34.212, + heading: 2.281299097855777, + zoom: 60358.12942752382, + pitch: -45.2508969308367, + roll: 0.005453465256790101, + }); }; const showBuiltCity = () => { newfiberMap.removeByIds(['oneCenter']); @@ -139,6 +155,14 @@ show: true, }, ]); + newfiberMap.setCenter({ + lng: 114.312, + lat: 34.262, + heading: 2.281299097855777, + zoom: 42358.12942752382, + pitch: -35.2508969308367, + roll: 0.005453465256790101, + }); }; const showOneCenterLayer = () => { bus.emit('setIniteLayer', [ diff --git a/src/utils/gis/NewFiberMapUtils.js b/src/utils/gis/NewFiberMapUtils.js index 6c7fcc6..9b11300 100644 --- a/src/utils/gis/NewFiberMapUtils.js +++ b/src/utils/gis/NewFiberMapUtils.js @@ -1,78 +1,77 @@ -import request from "../request"; +import request from '../request'; -import rainStation_icon from "@/assets/cesiumMap/legendIcon/rainStation_icon.png"; -import spongeFacility_icon from "@/assets/cesiumMap/legendIcon/spongeFacility_icon.png"; -import sewageBenZhan_icon from "@/assets/cesiumMap/legendIcon/sewageBenZhan_icon.png" -import rainBengZhan_icon from "@/assets/cesiumMap/legendIcon/rainBengZhan_icon.png" -import combineBengZhan_icon from "@/assets/cesiumMap/legendIcon/combineBengZhan_icon.png" +import rainStation_icon from '@/assets/cesiumMap/legendIcon/rainStation_icon.png'; +import spongeFacility_icon from '@/assets/cesiumMap/legendIcon/spongeFacility_icon.png'; +import sewageBenZhan_icon from '@/assets/cesiumMap/legendIcon/sewageBenZhan_icon.png'; +import rainBengZhan_icon from '@/assets/cesiumMap/legendIcon/rainBengZhan_icon.png'; +import combineBengZhan_icon from '@/assets/cesiumMap/legendIcon/combineBengZhan_icon.png'; -import riverFlow from "@/assets/geojson/kaifeng/riverFlow.json"; +import riverFlow from '@/assets/geojson/kaifeng/riverFlow.json'; import cesiumMapLegend from '@/views/sponeScreen/gisMF/cesiumMapLegend.js'; -import newfiberVectorLayer from "@/views/sponeScreen/gisMF/newfiberVectorLayer"; +import newfiberVectorLayer from '@/views/sponeScreen/gisMF/newfiberVectorLayer'; import { facilityPumpList } from '@/api/scada/pumpStationInformation'; -let mapParams={ - geojson:{ - point:{ - type: NewFiberMap.Enum.VectorType.ICON, - options: { - url: "/static/images/icon.png", - width: 20, - height: 20, - verticalOrigin: Cesium.HorizontalOrigin.RIGHT, - pixelOffset: [0, -10], - }, - labelOptions: { - font: "17px PingFang SC", - style: Cesium.LabelStyle.FILL_AND_OUTLINE, - outlineColor: "rgba(20,83,154,1)", - outline: true, - outlineWidth: 3, - color: "#ffffff", - pixelOffset: [0, 25], - distanceDisplayCondition: [0, 5100], - }, - }, - warning:{ - type: NewFiberMap.Enum.VectorType.SPECIAL_CIRCLE, - options: { - radius: 70, - material: new NewFiberMap.Material.CircleDiffuseMaterialProperty({ - color: Cesium.Color.fromCssColorString("rgba(255,0,0, .5)"), - speed: 50, - }), - }, - }, - polyline: { - type: NewFiberMap.Enum.VectorType.POLYLINE, - options: { - show: true, - width: 6, - material:new Cesium.Spriteline1MaterialProperty(3000,'/static/images/spriteline.png'), - clampToGround: true - } - }, - polygon:{ - type: NewFiberMap.Enum.VectorType.POLYGON, - options: { - width: 1, - material: "rgba(46,196,203,0.5)", - outlineColor: "rgba(0,244,255,1)", - }, - } - } +let mapParams = { + geojson: { + point: { + type: NewFiberMap.Enum.VectorType.ICON, + options: { + url: '/static/images/icon.png', + width: 20, + height: 20, + verticalOrigin: Cesium.HorizontalOrigin.RIGHT, + pixelOffset: [0, -10], + }, + labelOptions: { + font: '17px PingFang SC', + style: Cesium.LabelStyle.FILL_AND_OUTLINE, + outlineColor: 'rgba(20,83,154,1)', + outline: true, + outlineWidth: 3, + color: '#ffffff', + pixelOffset: [0, 25], + distanceDisplayCondition: [0, 5100], + }, + }, + warning: { + type: NewFiberMap.Enum.VectorType.SPECIAL_CIRCLE, + options: { + radius: 70, + material: new NewFiberMap.Material.CircleDiffuseMaterialProperty({ + color: Cesium.Color.fromCssColorString('rgba(255,0,0, .5)'), + speed: 50, + }), + }, + }, + polyline: { + type: NewFiberMap.Enum.VectorType.POLYLINE, + options: { + show: true, + width: 6, + material: new Cesium.Spriteline1MaterialProperty(3000, '/static/images/spriteline.png'), + clampToGround: true, + }, + }, + polygon: { + type: NewFiberMap.Enum.VectorType.POLYGON, + options: { + width: 1, + material: 'rgba(46,196,203,0.5)', + outlineColor: 'rgba(0,244,255,1)', + }, + }, + }, }; export default class NewFiberMapUtils { - - static defaultParams = { - keys:{ - //巡查默认专题图 - defaultPatrolDemo:'defaultPatrolDemo', - //排水防涝默认专题图 - defaultPreventWaterloggingDemo:'defaultPreventWaterloggingDemo', - weather_cloud:'weather_cloud' - }, - /* mapParams:{ + static defaultParams = { + keys: { + //巡查默认专题图 + defaultPatrolDemo: 'defaultPatrolDemo', + //排水防涝默认专题图 + defaultPreventWaterloggingDemo: 'defaultPreventWaterloggingDemo', + weather_cloud: 'weather_cloud', + }, + /* mapParams:{ geojson:{ point:{ type: NewFiberMap.Enum.VectorType.ICON, @@ -123,56 +122,88 @@ } } }*/ - } + }; + static async defaultPatrolDemo(newfiberMap) { + const { keys } = NewFiberMapUtils.defaultParams; + const defaulGeoJSONParams = _.cloneDeep(mapParams.geojson); + const icons = { ylz: rainStation_icon, hmss: spongeFacility_icon, car: '/images/car.png' }; + NewFiberMapUtils.removeByIds([keys.defaultPatrolDemo]); - static async defaultPatrolDemo(newfiberMap) { - const {keys} = NewFiberMapUtils.defaultParams; - const defaulGeoJSONParams = _.cloneDeep(mapParams.geojson); - const icons = {ylz:rainStation_icon, hmss:spongeFacility_icon, car:"/images/car.png"}; - NewFiberMapUtils.removeByIds([keys.defaultPatrolDemo]); + let results = await Promise.all(['/static/json/malfunction.json', '/static/json/track.json'].map(i => request(i))); + let warningData = _.cloneDeep(results[0]); + results[0].features.forEach( + i => + (i.properties.style_ = _.cloneDeep({ + id: keys.defaultPatrolDemo, + name: i.properties.name, + ...defaulGeoJSONParams.point, + options: Object.assign(defaulGeoJSONParams.point.options, { url: icons[i.properties.type] }), + })) + ); + warningData.features.forEach(i => (i.properties.style_ = { id: keys.defaultPatrolDemo, ...defaulGeoJSONParams.warning })); + let markers = warningData.features.concat(results[0].features); + newfiberMap.geojsonToMap(turf.featureCollection(markers)); - let results = await Promise.all(['/static/json/malfunction.json','/static/json/track.json'].map(i => request(i))); - let warningData = _.cloneDeep(results[0]); - results[0].features.forEach(i => (i.properties.style_ = _.cloneDeep({id:keys.defaultPatrolDemo,name:i.properties.name,...(defaulGeoJSONParams.point),options:Object.assign(defaulGeoJSONParams.point.options,{url:icons[i.properties.type]})}))); - warningData.features.forEach(i => (i.properties.style_ = {id:keys.defaultPatrolDemo,...(defaulGeoJSONParams.warning)})); - let markers = warningData.features.concat(results[0].features); - newfiberMap.geojsonToMap(turf.featureCollection(markers)); + newfiberMap.patrolDemoTracks = results[1].features.map(feature => { + let datas = turf.getCoords(feature.geometry).map(coords => ({ l: coords[0], a: coords[1], height: 10, time: 10 })); + return new NewFiberMap.Layer.RunningPath({ + paths: datas, + name, + newfiberMap, + options: { + style: { move: icons.car }, + perSec: 5, + speed: 10, + pathColor: [38, 178, 107, 1], + passPathColor: [89, 91, 93, 1], + isStart: false, + isEnd: false, + fields: { lng: 'l', lat: 'a', height: 'height', time: 'time' }, + }, + }); + }); - newfiberMap.patrolDemoTracks = results[1].features.map(feature => { - let datas = turf.getCoords(feature.geometry).map(coords => ({l:coords[0],a:coords[1],height:10,time:10})); - return new NewFiberMap.Layer.RunningPath({paths:datas,name, newfiberMap,options:{style:{move:icons.car},perSec:5,speed:10,pathColor:[38,178,107,1],passPathColor:[89,91,93,1], isStart:false, isEnd:false, fields:{lng:'l',lat:'a',height: 'height',time:'time'}}}); - }); + let timeout = setTimeout(() => { + newfiberMap.setView({ + lng: 114.332, + lat: 34.662, + heading: 2.281299097855777, + zoom: 6358.12942752382, + pitch: -25.2508969308367, + roll: 0.005453465256790101, + }); + clearTimeout(timeout); + }, 4000); + } - let timeout = setTimeout(() => { - newfiberMap.setView({ - lng: 114.312, - lat: 34.502, - heading: 2.281299097855777, - zoom: 16358.12942752382, - pitch: -25.2508969308367, - roll: 0.005453465256790101, - }); - clearTimeout(timeout); - }, 4000); - } - - static async defaultPreventWaterlogging(newfiberMap){ - const { keys} = NewFiberMapUtils.defaultParams; - NewFiberMapUtils.removeByIds([keys.defaultPreventWaterloggingDemo]); - const defaulGeoJSONParams = _.cloneDeep(mapParams.geojson); - const icons = { - "confluence":sewageBenZhan_icon, - "rain_water":rainBengZhan_icon, - "sewage_water":combineBengZhan_icon, - } - let result = await facilityPumpList(); - let pumpData = result.data.filter(i => i.lon && i.lat &&i.geometrys); - let points = pumpData.map(i => turf.point([i.lon,i.lat].map(Number),{style_:{id:keys.defaultPreventWaterloggingDemo,name:i.pumpName,...(defaulGeoJSONParams.point),options:{...defaulGeoJSONParams.point.options,url:icons[i.pumpType]}}})) - console.log('points',points); - let polygons = pumpData.map(i => turf.feature(Terraformer.WKT.parse(i.geometrys),{style_:{id:keys.defaultPatrolDemo,...defaulGeoJSONParams.polygon}})); - NewFiberMapUtils.weatherToMap(newfiberMap); - /* let modelLegends = cesiumMapLegend.map(i => i.children).flat(Infinity).filter(i => i.layername.includes('Line') && i.type == '3dModel'); + static async defaultPreventWaterlogging(newfiberMap) { + const { keys } = NewFiberMapUtils.defaultParams; + NewFiberMapUtils.removeByIds([keys.defaultPreventWaterloggingDemo]); + const defaulGeoJSONParams = _.cloneDeep(mapParams.geojson); + // const icons = { + // confluence: sewageBenZhan_icon, + // rain_water: rainBengZhan_icon, + // sewage_water: combineBengZhan_icon, + // }; + // let result = await facilityPumpList(); + // let pumpData = result.data.filter(i => i.lon && i.lat && i.geometrys); + // let points = pumpData.map(i => + // turf.point([i.lon, i.lat].map(Number), { + // style_: { + // id: keys.defaultPreventWaterloggingDemo, + // name: i.pumpName, + // ...defaulGeoJSONParams.point, + // options: { ...defaulGeoJSONParams.point.options, url: icons[i.pumpType] }, + // }, + // }) + // ); + // console.log('points', points); + // let polygons = pumpData.map(i => + // turf.feature(Terraformer.WKT.parse(i.geometrys), { style_: { id: keys.defaultPatrolDemo, ...defaulGeoJSONParams.polygon } }) + // ); + NewFiberMapUtils.weatherToMap(newfiberMap); + /* let modelLegends = cesiumMapLegend.map(i => i.children).flat(Infinity).filter(i => i.layername.includes('Line') && i.type == '3dModel'); let modelIds = modelLegends.map(i => i.layername); let models = newfiberMap.getMap().scene.primitives._primitives.filter(i => modelIds.includes(i.newfiberId)); if (models.length > 0) { @@ -180,87 +211,88 @@ } else { modelLegends.forEach(i => i.data.forEach(url => newfiberVectorLayer.add3DModelLayers(newfiberMap, url, i.layername))); }*/ - riverFlow.features.forEach(i => i.properties.style_ = {id: keys.defaultPreventWaterloggingDemo, ...(defaulGeoJSONParams.polyline)}); - newfiberMap.geojsonToMap(riverFlow); - newfiberMap.geojsonToMap(turf.featureCollection([...points,...polygons])); - } + riverFlow.features.forEach(i => (i.properties.style_ = { id: keys.defaultPreventWaterloggingDemo, ...defaulGeoJSONParams.polyline })); + newfiberMap.geojsonToMap(riverFlow); + //newfiberMap.geojsonToMap(turf.featureCollection([...points, ...polygons])); + } - static async weatherToMap(newfiberMap){ - const {keys} = NewFiberMapUtils.defaultParams; - const urls = [ - "/images/weather/QPFRef_202406210650.png", - "/images/weather/QPFRef_202406210700.png", - "/images/weather/QPFRef_202406210710.png", - "/images/weather/QPFRef_202406210720.png", - "/images/weather/QPFRef_202406210730.png", - "/images/weather/QPFRef_202406210740.png", - "/images/weather/QPFRef_202406210750.png", - "/images/weather/QPFRef_202406210800.png", - "/images/weather/QPFRef_202406210810.png", - "/images/weather/QPFRef_202406210820.png", - "/images/weather/QPFRef_202406210830.png", - "/images/weather/QPFRef_202406210840.png", - "/images/weather/QPFRef_202406210850.png", - "/images/weather/QPFRef_202406210900.png", - "/images/weather/QPFRef_202406210910.png", - "/images/weather/QPFRef_202406210920.png", - "/images/weather/QPFRef_202406210930.png", - "/images/weather/QPFRef_202406210940.png", - "/images/weather/QPFRef_202406210950.png", - "/images/weather/QPFRef_202406211000.png", - "/images/weather/QPFRef_202406211010.png", - "/images/weather/QPFRef_202406211020.png", - "/images/weather/QPFRef_202406211030.png", - "/images/weather/QPFRef_202406211040.png", - "/images/weather/QPFRef_202406211050.png", - "/images/weather/QPFRef_202406211100.png", - "/images/weather/QPFRef_202406211110.png", - "/images/weather/QPFRef_202406211120.png", - "/images/weather/QPFRef_202406211130.png", - "/images/weather/QPFRef_202406211140.png", - "/images/weather/QPFRef_202406211150.png", - "/images/weather/QPFRef_202406211200.png", - "/images/weather/QPFRef_202406211210.png", - "/images/weather/QPFRef_202406211220.png", - "/images/weather/QPFRef_202406211230.png", - "/images/weather/QPFRef_202406211240.png", - "/images/weather/QPFRef_202406211250.png", - "/images/weather/QPFRef_202406211300.png", - "/images/weather/QPFRef_202406211310.png", - "/images/weather/QPFRef_202406211320.png", - "/images/weather/QPFRef_202406211330.png", - "/images/weather/QPFRef_202406211340.png", - ]; - const defaulGeoJSONParams = _.cloneDeep(mapParams.geojson); - const bbox = [73.49899858945263, 10.228437, 135.08738720258265, 53.56131497236056]; - let polygon = turf.bboxPolygon(bbox); - let i = 0; - polygon.properties.style_ = { - id: keys.weather_cloud, - ...(_.cloneDeep((defaulGeoJSONParams.polygon))), - options: Object.assign(defaulGeoJSONParams.polygon.options, { - show:false, - material: new Cesium.ImageMaterialProperty({ - transparent: true, - alpha: 0.5, - image: new Cesium.CallbackProperty(function () { - return urls[i]; - }) - }) - }) - }; - newfiberMap.geojsonToMap(turf.featureCollection([polygon])); - newfiberMap.weatherInterVal = setInterval(() => { - i++; - if (i == urls.length) { - i = 0; - } - }, 1000); - } + static async weatherToMap(newfiberMap) { + const { keys } = NewFiberMapUtils.defaultParams; + const urls = [ + '/images/weather/QPFRef_202406210650.png', + '/images/weather/QPFRef_202406210700.png', + '/images/weather/QPFRef_202406210710.png', + '/images/weather/QPFRef_202406210720.png', + '/images/weather/QPFRef_202406210730.png', + '/images/weather/QPFRef_202406210740.png', + '/images/weather/QPFRef_202406210750.png', + '/images/weather/QPFRef_202406210800.png', + '/images/weather/QPFRef_202406210810.png', + '/images/weather/QPFRef_202406210820.png', + '/images/weather/QPFRef_202406210830.png', + '/images/weather/QPFRef_202406210840.png', + '/images/weather/QPFRef_202406210850.png', + '/images/weather/QPFRef_202406210900.png', + '/images/weather/QPFRef_202406210910.png', + '/images/weather/QPFRef_202406210920.png', + '/images/weather/QPFRef_202406210930.png', + '/images/weather/QPFRef_202406210940.png', + '/images/weather/QPFRef_202406210950.png', + '/images/weather/QPFRef_202406211000.png', + '/images/weather/QPFRef_202406211010.png', + '/images/weather/QPFRef_202406211020.png', + '/images/weather/QPFRef_202406211030.png', + '/images/weather/QPFRef_202406211040.png', + '/images/weather/QPFRef_202406211050.png', + '/images/weather/QPFRef_202406211100.png', + '/images/weather/QPFRef_202406211110.png', + '/images/weather/QPFRef_202406211120.png', + '/images/weather/QPFRef_202406211130.png', + '/images/weather/QPFRef_202406211140.png', + '/images/weather/QPFRef_202406211150.png', + '/images/weather/QPFRef_202406211200.png', + '/images/weather/QPFRef_202406211210.png', + '/images/weather/QPFRef_202406211220.png', + '/images/weather/QPFRef_202406211230.png', + '/images/weather/QPFRef_202406211240.png', + '/images/weather/QPFRef_202406211250.png', + '/images/weather/QPFRef_202406211300.png', + '/images/weather/QPFRef_202406211310.png', + '/images/weather/QPFRef_202406211320.png', + '/images/weather/QPFRef_202406211330.png', + '/images/weather/QPFRef_202406211340.png', + ]; + const defaulGeoJSONParams = _.cloneDeep(mapParams.geojson); + const bbox = [73.49899858945263, 10.228437, 135.08738720258265, 53.56131497236056]; + let polygon = turf.bboxPolygon(bbox); + let i = 0; + polygon.properties.style_ = { + id: keys.weather_cloud, + ..._.cloneDeep(defaulGeoJSONParams.polygon), + options: Object.assign(defaulGeoJSONParams.polygon.options, { + show: false, + material: new Cesium.ImageMaterialProperty({ + transparent: true, + alpha: 0.5, + image: new Cesium.CallbackProperty(function () { + return urls[i]; + }), + }), + }), + }; + newfiberMap.geojsonToMap(turf.featureCollection([polygon])); + newfiberMap.weatherInterVal = setInterval(() => { + i++; + if (i == urls.length) { + i = 0; + } + }, 1000); + } - static removeByIds(ids) { - const {keys} = NewFiberMapUtils.defaultParams; - newfiberMap.removeByIds(ids); - if (ids.includes(keys.defaultPatrolDemo)) if (newfiberMap.patrolDemoTracks) newfiberMap.patrolDemoTracks.forEach(i => i.destroy()), newfiberMap.patrolDemoTracks = undefined; - } + static removeByIds(ids) { + const { keys } = NewFiberMapUtils.defaultParams; + newfiberMap.removeByIds(ids); + if (ids.includes(keys.defaultPatrolDemo)) + if (newfiberMap.patrolDemoTracks) newfiberMap.patrolDemoTracks.forEach(i => i.destroy()), (newfiberMap.patrolDemoTracks = undefined); + } } diff --git a/src/views/sponeScreen/HaiMianScreen/index.vue b/src/views/sponeScreen/HaiMianScreen/index.vue index d4bc553..73ca7d3 100644 --- a/src/views/sponeScreen/HaiMianScreen/index.vue +++ b/src/views/sponeScreen/HaiMianScreen/index.vue @@ -91,8 +91,38 @@ function menuClick(id) { menuIndex.value = id; showPanel.value = false; + bus.emit('setIniteLayer', [ + { + layername: 'YSBZ', + show: true, + }, + { + layername: 'WSBZ', + show: true, + }, + { + layername: 'rainLine', + show: true, + }, + ]); NewFiberMapUtils.removeByIds(Object.values(NewFiberMapUtils.defaultParams.keys)); - if (id == 4) NewFiberMapUtils.defaultPreventWaterlogging(newfiberMap); + if (id == 4) { + bus.emit('setIniteLayer', [ + { + layername: 'YSBZ', + show: false, + }, + { + layername: 'WSBZ', + show: false, + }, + { + layername: 'rainLine', + show: false, + }, + ]); + NewFiberMapUtils.defaultPreventWaterlogging(newfiberMap); + } if (id == 5) NewFiberMapUtils.defaultPatrolDemo(newfiberMap); } // 图例控制 diff --git a/src/views/sponeScreen/cityGK/PhysicalGeography.vue b/src/views/sponeScreen/cityGK/PhysicalGeography.vue index 6a751d9..6d28612 100644 --- a/src/views/sponeScreen/cityGK/PhysicalGeography.vue +++ b/src/views/sponeScreen/cityGK/PhysicalGeography.vue @@ -97,6 +97,14 @@ show: true, }, ]); + newfiberMap.setCenter({ + lng: 114.312, + lat: 34.202, + heading: 2.281299097855777, + zoom: 35358.12942752382, + pitch: -25.2508969308367, + roll: 0.005453465256790101, + }); }; const showCenterCity = () => { newfiberMap.removeByIds(['oneCenter']); @@ -118,6 +126,14 @@ show: false, }, ]); + newfiberMap.setCenter({ + lng: 114.312, + lat: 34.212, + heading: 2.281299097855777, + zoom: 60358.12942752382, + pitch: -45.2508969308367, + roll: 0.005453465256790101, + }); }; const showBuiltCity = () => { newfiberMap.removeByIds(['oneCenter']); @@ -139,6 +155,14 @@ show: true, }, ]); + newfiberMap.setCenter({ + lng: 114.312, + lat: 34.262, + heading: 2.281299097855777, + zoom: 42358.12942752382, + pitch: -35.2508969308367, + roll: 0.005453465256790101, + }); }; const showOneCenterLayer = () => { bus.emit('setIniteLayer', [ diff --git a/src/views/sponeScreen/gisMF/cesiumMap.vue b/src/views/sponeScreen/gisMF/cesiumMap.vue index a93ce56..0af865f 100644 --- a/src/views/sponeScreen/gisMF/cesiumMap.vue +++ b/src/views/sponeScreen/gisMF/cesiumMap.vue @@ -40,7 +40,14 @@ roll: 0.005453465256790101, }); newfiberMap.registerLeftClickEvt(async (position, point, feature) => { - if (feature.key == 'YSBZ' || feature.key == 'WSBZ' || feature.key == 'combineBengZhan' || feature.key == 'sewageFactory') { + if (!feature) return; + if ( + feature.key == 'YSBZ' || + feature.key == 'WSBZ' || + feature.key == 'combineBengZhan' || + feature.key == 'sewageFactory' || + feature.key == 'waterLoging' + ) { let properties = feature.properties.getValue(); console.log('properties--', properties); dataList.value = properties; @@ -48,7 +55,7 @@ if (!!!window.PopupInfo) { window.PopupInfo = newfiberMap.createPopup({ id: 'cesiumPopupID', - position: [Number(properties.lon), Number(properties.lat), 0], + position: [...point].concat(0), map: newfiberMap.getMap(), maxHeight: 130000, }); diff --git a/src/utils/gis/NewFiberMapUtils.js b/src/utils/gis/NewFiberMapUtils.js index 6c7fcc6..9b11300 100644 --- a/src/utils/gis/NewFiberMapUtils.js +++ b/src/utils/gis/NewFiberMapUtils.js @@ -1,78 +1,77 @@ -import request from "../request"; +import request from '../request'; -import rainStation_icon from "@/assets/cesiumMap/legendIcon/rainStation_icon.png"; -import spongeFacility_icon from "@/assets/cesiumMap/legendIcon/spongeFacility_icon.png"; -import sewageBenZhan_icon from "@/assets/cesiumMap/legendIcon/sewageBenZhan_icon.png" -import rainBengZhan_icon from "@/assets/cesiumMap/legendIcon/rainBengZhan_icon.png" -import combineBengZhan_icon from "@/assets/cesiumMap/legendIcon/combineBengZhan_icon.png" +import rainStation_icon from '@/assets/cesiumMap/legendIcon/rainStation_icon.png'; +import spongeFacility_icon from '@/assets/cesiumMap/legendIcon/spongeFacility_icon.png'; +import sewageBenZhan_icon from '@/assets/cesiumMap/legendIcon/sewageBenZhan_icon.png'; +import rainBengZhan_icon from '@/assets/cesiumMap/legendIcon/rainBengZhan_icon.png'; +import combineBengZhan_icon from '@/assets/cesiumMap/legendIcon/combineBengZhan_icon.png'; -import riverFlow from "@/assets/geojson/kaifeng/riverFlow.json"; +import riverFlow from '@/assets/geojson/kaifeng/riverFlow.json'; import cesiumMapLegend from '@/views/sponeScreen/gisMF/cesiumMapLegend.js'; -import newfiberVectorLayer from "@/views/sponeScreen/gisMF/newfiberVectorLayer"; +import newfiberVectorLayer from '@/views/sponeScreen/gisMF/newfiberVectorLayer'; import { facilityPumpList } from '@/api/scada/pumpStationInformation'; -let mapParams={ - geojson:{ - point:{ - type: NewFiberMap.Enum.VectorType.ICON, - options: { - url: "/static/images/icon.png", - width: 20, - height: 20, - verticalOrigin: Cesium.HorizontalOrigin.RIGHT, - pixelOffset: [0, -10], - }, - labelOptions: { - font: "17px PingFang SC", - style: Cesium.LabelStyle.FILL_AND_OUTLINE, - outlineColor: "rgba(20,83,154,1)", - outline: true, - outlineWidth: 3, - color: "#ffffff", - pixelOffset: [0, 25], - distanceDisplayCondition: [0, 5100], - }, - }, - warning:{ - type: NewFiberMap.Enum.VectorType.SPECIAL_CIRCLE, - options: { - radius: 70, - material: new NewFiberMap.Material.CircleDiffuseMaterialProperty({ - color: Cesium.Color.fromCssColorString("rgba(255,0,0, .5)"), - speed: 50, - }), - }, - }, - polyline: { - type: NewFiberMap.Enum.VectorType.POLYLINE, - options: { - show: true, - width: 6, - material:new Cesium.Spriteline1MaterialProperty(3000,'/static/images/spriteline.png'), - clampToGround: true - } - }, - polygon:{ - type: NewFiberMap.Enum.VectorType.POLYGON, - options: { - width: 1, - material: "rgba(46,196,203,0.5)", - outlineColor: "rgba(0,244,255,1)", - }, - } - } +let mapParams = { + geojson: { + point: { + type: NewFiberMap.Enum.VectorType.ICON, + options: { + url: '/static/images/icon.png', + width: 20, + height: 20, + verticalOrigin: Cesium.HorizontalOrigin.RIGHT, + pixelOffset: [0, -10], + }, + labelOptions: { + font: '17px PingFang SC', + style: Cesium.LabelStyle.FILL_AND_OUTLINE, + outlineColor: 'rgba(20,83,154,1)', + outline: true, + outlineWidth: 3, + color: '#ffffff', + pixelOffset: [0, 25], + distanceDisplayCondition: [0, 5100], + }, + }, + warning: { + type: NewFiberMap.Enum.VectorType.SPECIAL_CIRCLE, + options: { + radius: 70, + material: new NewFiberMap.Material.CircleDiffuseMaterialProperty({ + color: Cesium.Color.fromCssColorString('rgba(255,0,0, .5)'), + speed: 50, + }), + }, + }, + polyline: { + type: NewFiberMap.Enum.VectorType.POLYLINE, + options: { + show: true, + width: 6, + material: new Cesium.Spriteline1MaterialProperty(3000, '/static/images/spriteline.png'), + clampToGround: true, + }, + }, + polygon: { + type: NewFiberMap.Enum.VectorType.POLYGON, + options: { + width: 1, + material: 'rgba(46,196,203,0.5)', + outlineColor: 'rgba(0,244,255,1)', + }, + }, + }, }; export default class NewFiberMapUtils { - - static defaultParams = { - keys:{ - //巡查默认专题图 - defaultPatrolDemo:'defaultPatrolDemo', - //排水防涝默认专题图 - defaultPreventWaterloggingDemo:'defaultPreventWaterloggingDemo', - weather_cloud:'weather_cloud' - }, - /* mapParams:{ + static defaultParams = { + keys: { + //巡查默认专题图 + defaultPatrolDemo: 'defaultPatrolDemo', + //排水防涝默认专题图 + defaultPreventWaterloggingDemo: 'defaultPreventWaterloggingDemo', + weather_cloud: 'weather_cloud', + }, + /* mapParams:{ geojson:{ point:{ type: NewFiberMap.Enum.VectorType.ICON, @@ -123,56 +122,88 @@ } } }*/ - } + }; + static async defaultPatrolDemo(newfiberMap) { + const { keys } = NewFiberMapUtils.defaultParams; + const defaulGeoJSONParams = _.cloneDeep(mapParams.geojson); + const icons = { ylz: rainStation_icon, hmss: spongeFacility_icon, car: '/images/car.png' }; + NewFiberMapUtils.removeByIds([keys.defaultPatrolDemo]); - static async defaultPatrolDemo(newfiberMap) { - const {keys} = NewFiberMapUtils.defaultParams; - const defaulGeoJSONParams = _.cloneDeep(mapParams.geojson); - const icons = {ylz:rainStation_icon, hmss:spongeFacility_icon, car:"/images/car.png"}; - NewFiberMapUtils.removeByIds([keys.defaultPatrolDemo]); + let results = await Promise.all(['/static/json/malfunction.json', '/static/json/track.json'].map(i => request(i))); + let warningData = _.cloneDeep(results[0]); + results[0].features.forEach( + i => + (i.properties.style_ = _.cloneDeep({ + id: keys.defaultPatrolDemo, + name: i.properties.name, + ...defaulGeoJSONParams.point, + options: Object.assign(defaulGeoJSONParams.point.options, { url: icons[i.properties.type] }), + })) + ); + warningData.features.forEach(i => (i.properties.style_ = { id: keys.defaultPatrolDemo, ...defaulGeoJSONParams.warning })); + let markers = warningData.features.concat(results[0].features); + newfiberMap.geojsonToMap(turf.featureCollection(markers)); - let results = await Promise.all(['/static/json/malfunction.json','/static/json/track.json'].map(i => request(i))); - let warningData = _.cloneDeep(results[0]); - results[0].features.forEach(i => (i.properties.style_ = _.cloneDeep({id:keys.defaultPatrolDemo,name:i.properties.name,...(defaulGeoJSONParams.point),options:Object.assign(defaulGeoJSONParams.point.options,{url:icons[i.properties.type]})}))); - warningData.features.forEach(i => (i.properties.style_ = {id:keys.defaultPatrolDemo,...(defaulGeoJSONParams.warning)})); - let markers = warningData.features.concat(results[0].features); - newfiberMap.geojsonToMap(turf.featureCollection(markers)); + newfiberMap.patrolDemoTracks = results[1].features.map(feature => { + let datas = turf.getCoords(feature.geometry).map(coords => ({ l: coords[0], a: coords[1], height: 10, time: 10 })); + return new NewFiberMap.Layer.RunningPath({ + paths: datas, + name, + newfiberMap, + options: { + style: { move: icons.car }, + perSec: 5, + speed: 10, + pathColor: [38, 178, 107, 1], + passPathColor: [89, 91, 93, 1], + isStart: false, + isEnd: false, + fields: { lng: 'l', lat: 'a', height: 'height', time: 'time' }, + }, + }); + }); - newfiberMap.patrolDemoTracks = results[1].features.map(feature => { - let datas = turf.getCoords(feature.geometry).map(coords => ({l:coords[0],a:coords[1],height:10,time:10})); - return new NewFiberMap.Layer.RunningPath({paths:datas,name, newfiberMap,options:{style:{move:icons.car},perSec:5,speed:10,pathColor:[38,178,107,1],passPathColor:[89,91,93,1], isStart:false, isEnd:false, fields:{lng:'l',lat:'a',height: 'height',time:'time'}}}); - }); + let timeout = setTimeout(() => { + newfiberMap.setView({ + lng: 114.332, + lat: 34.662, + heading: 2.281299097855777, + zoom: 6358.12942752382, + pitch: -25.2508969308367, + roll: 0.005453465256790101, + }); + clearTimeout(timeout); + }, 4000); + } - let timeout = setTimeout(() => { - newfiberMap.setView({ - lng: 114.312, - lat: 34.502, - heading: 2.281299097855777, - zoom: 16358.12942752382, - pitch: -25.2508969308367, - roll: 0.005453465256790101, - }); - clearTimeout(timeout); - }, 4000); - } - - static async defaultPreventWaterlogging(newfiberMap){ - const { keys} = NewFiberMapUtils.defaultParams; - NewFiberMapUtils.removeByIds([keys.defaultPreventWaterloggingDemo]); - const defaulGeoJSONParams = _.cloneDeep(mapParams.geojson); - const icons = { - "confluence":sewageBenZhan_icon, - "rain_water":rainBengZhan_icon, - "sewage_water":combineBengZhan_icon, - } - let result = await facilityPumpList(); - let pumpData = result.data.filter(i => i.lon && i.lat &&i.geometrys); - let points = pumpData.map(i => turf.point([i.lon,i.lat].map(Number),{style_:{id:keys.defaultPreventWaterloggingDemo,name:i.pumpName,...(defaulGeoJSONParams.point),options:{...defaulGeoJSONParams.point.options,url:icons[i.pumpType]}}})) - console.log('points',points); - let polygons = pumpData.map(i => turf.feature(Terraformer.WKT.parse(i.geometrys),{style_:{id:keys.defaultPatrolDemo,...defaulGeoJSONParams.polygon}})); - NewFiberMapUtils.weatherToMap(newfiberMap); - /* let modelLegends = cesiumMapLegend.map(i => i.children).flat(Infinity).filter(i => i.layername.includes('Line') && i.type == '3dModel'); + static async defaultPreventWaterlogging(newfiberMap) { + const { keys } = NewFiberMapUtils.defaultParams; + NewFiberMapUtils.removeByIds([keys.defaultPreventWaterloggingDemo]); + const defaulGeoJSONParams = _.cloneDeep(mapParams.geojson); + // const icons = { + // confluence: sewageBenZhan_icon, + // rain_water: rainBengZhan_icon, + // sewage_water: combineBengZhan_icon, + // }; + // let result = await facilityPumpList(); + // let pumpData = result.data.filter(i => i.lon && i.lat && i.geometrys); + // let points = pumpData.map(i => + // turf.point([i.lon, i.lat].map(Number), { + // style_: { + // id: keys.defaultPreventWaterloggingDemo, + // name: i.pumpName, + // ...defaulGeoJSONParams.point, + // options: { ...defaulGeoJSONParams.point.options, url: icons[i.pumpType] }, + // }, + // }) + // ); + // console.log('points', points); + // let polygons = pumpData.map(i => + // turf.feature(Terraformer.WKT.parse(i.geometrys), { style_: { id: keys.defaultPatrolDemo, ...defaulGeoJSONParams.polygon } }) + // ); + NewFiberMapUtils.weatherToMap(newfiberMap); + /* let modelLegends = cesiumMapLegend.map(i => i.children).flat(Infinity).filter(i => i.layername.includes('Line') && i.type == '3dModel'); let modelIds = modelLegends.map(i => i.layername); let models = newfiberMap.getMap().scene.primitives._primitives.filter(i => modelIds.includes(i.newfiberId)); if (models.length > 0) { @@ -180,87 +211,88 @@ } else { modelLegends.forEach(i => i.data.forEach(url => newfiberVectorLayer.add3DModelLayers(newfiberMap, url, i.layername))); }*/ - riverFlow.features.forEach(i => i.properties.style_ = {id: keys.defaultPreventWaterloggingDemo, ...(defaulGeoJSONParams.polyline)}); - newfiberMap.geojsonToMap(riverFlow); - newfiberMap.geojsonToMap(turf.featureCollection([...points,...polygons])); - } + riverFlow.features.forEach(i => (i.properties.style_ = { id: keys.defaultPreventWaterloggingDemo, ...defaulGeoJSONParams.polyline })); + newfiberMap.geojsonToMap(riverFlow); + //newfiberMap.geojsonToMap(turf.featureCollection([...points, ...polygons])); + } - static async weatherToMap(newfiberMap){ - const {keys} = NewFiberMapUtils.defaultParams; - const urls = [ - "/images/weather/QPFRef_202406210650.png", - "/images/weather/QPFRef_202406210700.png", - "/images/weather/QPFRef_202406210710.png", - "/images/weather/QPFRef_202406210720.png", - "/images/weather/QPFRef_202406210730.png", - "/images/weather/QPFRef_202406210740.png", - "/images/weather/QPFRef_202406210750.png", - "/images/weather/QPFRef_202406210800.png", - "/images/weather/QPFRef_202406210810.png", - "/images/weather/QPFRef_202406210820.png", - "/images/weather/QPFRef_202406210830.png", - "/images/weather/QPFRef_202406210840.png", - "/images/weather/QPFRef_202406210850.png", - "/images/weather/QPFRef_202406210900.png", - "/images/weather/QPFRef_202406210910.png", - "/images/weather/QPFRef_202406210920.png", - "/images/weather/QPFRef_202406210930.png", - "/images/weather/QPFRef_202406210940.png", - "/images/weather/QPFRef_202406210950.png", - "/images/weather/QPFRef_202406211000.png", - "/images/weather/QPFRef_202406211010.png", - "/images/weather/QPFRef_202406211020.png", - "/images/weather/QPFRef_202406211030.png", - "/images/weather/QPFRef_202406211040.png", - "/images/weather/QPFRef_202406211050.png", - "/images/weather/QPFRef_202406211100.png", - "/images/weather/QPFRef_202406211110.png", - "/images/weather/QPFRef_202406211120.png", - "/images/weather/QPFRef_202406211130.png", - "/images/weather/QPFRef_202406211140.png", - "/images/weather/QPFRef_202406211150.png", - "/images/weather/QPFRef_202406211200.png", - "/images/weather/QPFRef_202406211210.png", - "/images/weather/QPFRef_202406211220.png", - "/images/weather/QPFRef_202406211230.png", - "/images/weather/QPFRef_202406211240.png", - "/images/weather/QPFRef_202406211250.png", - "/images/weather/QPFRef_202406211300.png", - "/images/weather/QPFRef_202406211310.png", - "/images/weather/QPFRef_202406211320.png", - "/images/weather/QPFRef_202406211330.png", - "/images/weather/QPFRef_202406211340.png", - ]; - const defaulGeoJSONParams = _.cloneDeep(mapParams.geojson); - const bbox = [73.49899858945263, 10.228437, 135.08738720258265, 53.56131497236056]; - let polygon = turf.bboxPolygon(bbox); - let i = 0; - polygon.properties.style_ = { - id: keys.weather_cloud, - ...(_.cloneDeep((defaulGeoJSONParams.polygon))), - options: Object.assign(defaulGeoJSONParams.polygon.options, { - show:false, - material: new Cesium.ImageMaterialProperty({ - transparent: true, - alpha: 0.5, - image: new Cesium.CallbackProperty(function () { - return urls[i]; - }) - }) - }) - }; - newfiberMap.geojsonToMap(turf.featureCollection([polygon])); - newfiberMap.weatherInterVal = setInterval(() => { - i++; - if (i == urls.length) { - i = 0; - } - }, 1000); - } + static async weatherToMap(newfiberMap) { + const { keys } = NewFiberMapUtils.defaultParams; + const urls = [ + '/images/weather/QPFRef_202406210650.png', + '/images/weather/QPFRef_202406210700.png', + '/images/weather/QPFRef_202406210710.png', + '/images/weather/QPFRef_202406210720.png', + '/images/weather/QPFRef_202406210730.png', + '/images/weather/QPFRef_202406210740.png', + '/images/weather/QPFRef_202406210750.png', + '/images/weather/QPFRef_202406210800.png', + '/images/weather/QPFRef_202406210810.png', + '/images/weather/QPFRef_202406210820.png', + '/images/weather/QPFRef_202406210830.png', + '/images/weather/QPFRef_202406210840.png', + '/images/weather/QPFRef_202406210850.png', + '/images/weather/QPFRef_202406210900.png', + '/images/weather/QPFRef_202406210910.png', + '/images/weather/QPFRef_202406210920.png', + '/images/weather/QPFRef_202406210930.png', + '/images/weather/QPFRef_202406210940.png', + '/images/weather/QPFRef_202406210950.png', + '/images/weather/QPFRef_202406211000.png', + '/images/weather/QPFRef_202406211010.png', + '/images/weather/QPFRef_202406211020.png', + '/images/weather/QPFRef_202406211030.png', + '/images/weather/QPFRef_202406211040.png', + '/images/weather/QPFRef_202406211050.png', + '/images/weather/QPFRef_202406211100.png', + '/images/weather/QPFRef_202406211110.png', + '/images/weather/QPFRef_202406211120.png', + '/images/weather/QPFRef_202406211130.png', + '/images/weather/QPFRef_202406211140.png', + '/images/weather/QPFRef_202406211150.png', + '/images/weather/QPFRef_202406211200.png', + '/images/weather/QPFRef_202406211210.png', + '/images/weather/QPFRef_202406211220.png', + '/images/weather/QPFRef_202406211230.png', + '/images/weather/QPFRef_202406211240.png', + '/images/weather/QPFRef_202406211250.png', + '/images/weather/QPFRef_202406211300.png', + '/images/weather/QPFRef_202406211310.png', + '/images/weather/QPFRef_202406211320.png', + '/images/weather/QPFRef_202406211330.png', + '/images/weather/QPFRef_202406211340.png', + ]; + const defaulGeoJSONParams = _.cloneDeep(mapParams.geojson); + const bbox = [73.49899858945263, 10.228437, 135.08738720258265, 53.56131497236056]; + let polygon = turf.bboxPolygon(bbox); + let i = 0; + polygon.properties.style_ = { + id: keys.weather_cloud, + ..._.cloneDeep(defaulGeoJSONParams.polygon), + options: Object.assign(defaulGeoJSONParams.polygon.options, { + show: false, + material: new Cesium.ImageMaterialProperty({ + transparent: true, + alpha: 0.5, + image: new Cesium.CallbackProperty(function () { + return urls[i]; + }), + }), + }), + }; + newfiberMap.geojsonToMap(turf.featureCollection([polygon])); + newfiberMap.weatherInterVal = setInterval(() => { + i++; + if (i == urls.length) { + i = 0; + } + }, 1000); + } - static removeByIds(ids) { - const {keys} = NewFiberMapUtils.defaultParams; - newfiberMap.removeByIds(ids); - if (ids.includes(keys.defaultPatrolDemo)) if (newfiberMap.patrolDemoTracks) newfiberMap.patrolDemoTracks.forEach(i => i.destroy()), newfiberMap.patrolDemoTracks = undefined; - } + static removeByIds(ids) { + const { keys } = NewFiberMapUtils.defaultParams; + newfiberMap.removeByIds(ids); + if (ids.includes(keys.defaultPatrolDemo)) + if (newfiberMap.patrolDemoTracks) newfiberMap.patrolDemoTracks.forEach(i => i.destroy()), (newfiberMap.patrolDemoTracks = undefined); + } } diff --git a/src/views/sponeScreen/HaiMianScreen/index.vue b/src/views/sponeScreen/HaiMianScreen/index.vue index d4bc553..73ca7d3 100644 --- a/src/views/sponeScreen/HaiMianScreen/index.vue +++ b/src/views/sponeScreen/HaiMianScreen/index.vue @@ -91,8 +91,38 @@ function menuClick(id) { menuIndex.value = id; showPanel.value = false; + bus.emit('setIniteLayer', [ + { + layername: 'YSBZ', + show: true, + }, + { + layername: 'WSBZ', + show: true, + }, + { + layername: 'rainLine', + show: true, + }, + ]); NewFiberMapUtils.removeByIds(Object.values(NewFiberMapUtils.defaultParams.keys)); - if (id == 4) NewFiberMapUtils.defaultPreventWaterlogging(newfiberMap); + if (id == 4) { + bus.emit('setIniteLayer', [ + { + layername: 'YSBZ', + show: false, + }, + { + layername: 'WSBZ', + show: false, + }, + { + layername: 'rainLine', + show: false, + }, + ]); + NewFiberMapUtils.defaultPreventWaterlogging(newfiberMap); + } if (id == 5) NewFiberMapUtils.defaultPatrolDemo(newfiberMap); } // 图例控制 diff --git a/src/views/sponeScreen/cityGK/PhysicalGeography.vue b/src/views/sponeScreen/cityGK/PhysicalGeography.vue index 6a751d9..6d28612 100644 --- a/src/views/sponeScreen/cityGK/PhysicalGeography.vue +++ b/src/views/sponeScreen/cityGK/PhysicalGeography.vue @@ -97,6 +97,14 @@ show: true, }, ]); + newfiberMap.setCenter({ + lng: 114.312, + lat: 34.202, + heading: 2.281299097855777, + zoom: 35358.12942752382, + pitch: -25.2508969308367, + roll: 0.005453465256790101, + }); }; const showCenterCity = () => { newfiberMap.removeByIds(['oneCenter']); @@ -118,6 +126,14 @@ show: false, }, ]); + newfiberMap.setCenter({ + lng: 114.312, + lat: 34.212, + heading: 2.281299097855777, + zoom: 60358.12942752382, + pitch: -45.2508969308367, + roll: 0.005453465256790101, + }); }; const showBuiltCity = () => { newfiberMap.removeByIds(['oneCenter']); @@ -139,6 +155,14 @@ show: true, }, ]); + newfiberMap.setCenter({ + lng: 114.312, + lat: 34.262, + heading: 2.281299097855777, + zoom: 42358.12942752382, + pitch: -35.2508969308367, + roll: 0.005453465256790101, + }); }; const showOneCenterLayer = () => { bus.emit('setIniteLayer', [ diff --git a/src/views/sponeScreen/gisMF/cesiumMap.vue b/src/views/sponeScreen/gisMF/cesiumMap.vue index a93ce56..0af865f 100644 --- a/src/views/sponeScreen/gisMF/cesiumMap.vue +++ b/src/views/sponeScreen/gisMF/cesiumMap.vue @@ -40,7 +40,14 @@ roll: 0.005453465256790101, }); newfiberMap.registerLeftClickEvt(async (position, point, feature) => { - if (feature.key == 'YSBZ' || feature.key == 'WSBZ' || feature.key == 'combineBengZhan' || feature.key == 'sewageFactory') { + if (!feature) return; + if ( + feature.key == 'YSBZ' || + feature.key == 'WSBZ' || + feature.key == 'combineBengZhan' || + feature.key == 'sewageFactory' || + feature.key == 'waterLoging' + ) { let properties = feature.properties.getValue(); console.log('properties--', properties); dataList.value = properties; @@ -48,7 +55,7 @@ if (!!!window.PopupInfo) { window.PopupInfo = newfiberMap.createPopup({ id: 'cesiumPopupID', - position: [Number(properties.lon), Number(properties.lat), 0], + position: [...point].concat(0), map: newfiberMap.getMap(), maxHeight: 130000, }); diff --git a/src/views/sponeScreen/gisMF/cesiumPopup.vue b/src/views/sponeScreen/gisMF/cesiumPopup.vue index e872d56..4057645 100644 --- a/src/views/sponeScreen/gisMF/cesiumPopup.vue +++ b/src/views/sponeScreen/gisMF/cesiumPopup.vue @@ -125,6 +125,34 @@ +