/** * 工具栏-分析 */ import Bus from "@tools/Bus"; import axios from "axios"; var Cesium = window.Cesium; //卫星轨迹 var wxgjData = null; //热力图分析 var HeatMapData = null; //分析--雷达反射率 var ldfslData = null; //专题分析--人口迁徙可视化 var rkqxData = null; //通视 window.ts = []; //视域 var viewshed; //视域颜色 var SYFX_visible_color = { r: 0.0, g: 1.0, b: 0.0 }, SYFX_notVisible_color = { r: 1.0, g: 0.0, b: 0.0 }; //#endregion export default { methods: { addAnalyseToTree(data) { Bus.$emit("addOtherData", '分析', data); }, // 分析-卫星轨迹 SatelliteTrajectorie() { if (wxgjData) { wxgjData.clear(); wxgjData = undefined; } else { //获取卫星轨迹数据 axios .get(window.SmartEarthRootUrl + "Workers/json/wxgj.json") .then(function (data) { wxgjData = window.sgworld.Creator.createSatelliteTrail({ model: window.SmartEarthRootUrl + "Workers/Model/weixin.gltf", path: data.data.data, }); //定位 window.sgworld.Navigate.flyToPointsInterest({ destination: Cesium.Cartesian3.fromDegrees( 120.14827238383411, 30.269663961027284, 20000000 ), }); }); } }, // 获取数据 getData(bounds, length) { let data = []; let radio = (bounds.east - bounds.west) / 70; for (let i = 0; i < length; i++) { let x = Math.random() * (bounds.east - bounds.west + 1) + bounds.west; let y = Math.random() * (bounds.north - bounds.south + 1) + bounds.south; let value = Math.random() * 100; data.push({ x: x, y: y, value: value, radius: 100 * radio }); } return data; }, // 分析-热力图分析 HeatMap() { if (HeatMapData) { HeatMapData.deleteObject(); HeatMapData = undefined; } else { // 矩形坐标 let bounds = { west: 118.022502789, south: 29.045434061, east: 123.156157488, north: 32.582515322, // west: 70.0, // south: 10.0, // east: 140.0, // north: 50.0, }; let sourceData = this.getData(bounds, 100); HeatMapData = window.sgworld.Creator.addHeatMap("热力图", { sourceData: sourceData, }); //定位 window.sgworld.Navigate.flyToPointsInterest({ destination: Cesium.Rectangle.fromDegrees( bounds.west, bounds.south, bounds.east, bounds.north ), }); } }, // 分析-雷达反射率 RadarReflect() { if (ldfslData) { ldfslData.deleteObject(); ldfslData = undefined; } else { let bounds = { west: 73.16895, south: 12.2023, east: 134.86816, north: 54.11485, }; ldfslData = window.sgworld.Creator.createCloudMap( "雷达反射率", { minx: bounds.west, miny: bounds.south, maxx: bounds.east, maxy: bounds.north, }, [ window.SmartEarthRootUrl + "Workers/image/radar/201906211112.png", window.SmartEarthRootUrl + "Workers/image/radar/201906211124.png", window.SmartEarthRootUrl + "Workers/image/radar/201906211130.png", window.SmartEarthRootUrl + "Workers/image/radar/201906211136.png", window.SmartEarthRootUrl + "Workers/image/radar/201906211142.png", ], 1 ); //定位 window.sgworld.Navigate.flyToPointsInterest({ destination: Cesium.Rectangle.fromDegrees( bounds.west, bounds.south, bounds.east, bounds.north ), }); } }, convertData_rkqx(from, to) { let res = []; for (let i = 0; i < from.length; i++) { let dataItem = from[i]; let fromCoord = dataItem.position; let toCoord = to.position; if (fromCoord && toCoord) { res.push([{ coord: fromCoord, value: dataItem.value, }, { coord: toCoord, }, ]); } } return res; }, getSeries_rkqx(from, to) { let series = []; series.push({ type: "lines", coordinateSystem: "GLMap", zlevel: 2, effect: { show: true, period: 4, //箭头指向速度,值越小速度越快 trailLength: 0.02, //特效尾迹长度[0,1]值越大,尾迹越长重 symbol: "arrow", //箭头图标 symbolSize: 5, //图标大小 }, lineStyle: { normal: { width: 1, //尾迹线条宽度 opacity: 1, //尾迹线条透明度 color: "#00EAFF", //线的颜色 curveness: 0.3, //尾迹线条曲直度 }, }, data: this.convertData_rkqx(from, to), }, { type: "effectScatter", coordinateSystem: "GLMap", zlevel: 2, rippleEffect: { //涟漪特效 period: 4, //动画时间,值越小速度越快 brushType: "stroke", //波纹绘制方式 stroke, fill scale: 4, //波纹圆环最大限制,值越大波纹越大 }, label: { normal: { show: true, position: "right", //显示位置 offset: [5, 0], //偏移设置 formatter: function (params) { //圆环显示文字 return params.data.name; }, fontSize: 13, }, emphasis: { show: true, }, }, symbol: "circle", symbolSize: function (val) { return 5 + val[2] * 5; //圆环大小 }, itemStyle: { normal: { show: false, color: "#32ff9d", //颜色 }, }, data: from.map(function (dataItem) { return { name: dataItem.name, value: dataItem.position.concat([dataItem.value]), }; }), }, //被攻击点 { type: "scatter", coordinateSystem: "GLMap", zlevel: 2, rippleEffect: { period: 4, brushType: "stroke", scale: 4, }, itemStyle: { normal: { color: "#ff0617", //颜色 }, }, label: { normal: { show: true, position: "right", //offset:[5, 0], color: "#0f0", formatter: "{b}", textStyle: { color: "#0f0", }, }, emphasis: { show: true, color: "#f60", }, }, symbol: "pin", symbolSize: 50, data: [{ name: to.name, value: to.position.concat([10]), },], } ); return series; }, // 专题分析--人口迁徙可视化 migrate() { if (rkqxData) { rkqxData.clear(); rkqxData = undefined; } else { //获取人口迁徙数据 axios .get(window.SmartEarthRootUrl + "Workers/json/rkqx.json") .then((data) => { let fromData = data.data.from; let toData = data.data.to; //echarts参数 let option = { animation: !1, GLMap: {}, series: this.getSeries_rkqx(fromData, toData), }; rkqxData = window.sgworld.Core.CombineEcharts(window.Viewer, option, true); //定位 window.sgworld.Navigate.flyToPointsInterest({ destination: Cesium.Rectangle.fromDegrees( 70.0, 10.0, 140.0, 50.0 ), }); }); } }, // 分析-通视 - 下拉框点击事件 dropDownClick(type, parentName) { sgworld = window.sgworld; Viewer = window.Viewer; tooltip = window.tooltip; }, // 分析-视域 viewshed() { viewshed = window.sgworld.Analysis.create3DViewshed({ name: "Viewshed On Frederick", height: 1.8, color: { Back: SYFX_notVisible_color, Fore: SYFX_visible_color, }, isSpherical: false, }); }, // 分析-日照分析 sunshineAnalysis() { this.$refs.SunshineAnalysis.open(); }, //分析-阴影分析 shadowAnalysis() { this.$refs.ShadowAnalysis.open(); }, // 分析-天际线 skyline(btn) { btn.checked = !btn.checked; // 提示信息 if (this.message) { if (btn.checked) { this.message("success", "天际线已开启"); } else { this.message("info", "天际线已关闭"); } } this.isSkyLine = !this.isSkyLine; if (this.isSkyLine) { window.sgworld.Analysis.createSkylineAnalysis("#f00"); } else { window.sgworld.Analysis.clearSkylineAnalysis(); } }, // 关闭所有分析弹窗 everyPopupClose() { this.$refs.slope.close(); this.$refs.contour.close(); this.$refs.terrainOutline.close(); this.$refs.flood.close(); this.$refs.bufferArea.close(); this.$refs.terrainDig.close(); this.$refs.terrainPress.close(); this.$refs.modelPress.close(); this.$refs.SunshineAnalysis.close(); this.$refs.ShadowAnalysis.close(); }, // 等高线 openCountour() { this.everyPopupClose(); this.$refs.contour.open(); }, // 坡度图 slopeMap() { this.everyPopupClose(); this.$refs.slope.open(); }, // 地形轮廓 terrainOutline() { this.everyPopupClose(); this.$refs.terrainOutline.open(); }, // 分析-淹没分析 flood() { this.everyPopupClose(); this.$refs.flood.open(); }, // 分析-缓冲区分析 bufferArea() { this.everyPopupClose(); this.$refs.bufferArea.open(); }, // 分析-通视 lineSight(type) { let SightLine = sgworld.Analysis.createSightLine({ type: type, }); window.ts.push(SightLine); }, // 分析-地形开挖 terrainDig() { this.everyPopupClose(); this.$refs.terrainDig.open(); }, // 分析-地形压平 terrainPress() { this.everyPopupClose(); this.$refs.terrainPress.open(); }, // 分析-模型压平 modelPress() { this.everyPopupClose(); this.$refs.modelPress.open(); }, // 分析-清除 delete() { this.everyPopupClose(); Bus.$emit("clearFirstParentNode", "分析"); if (window.elevationTool.tf) { window.elevationTool.tf = false; //关闭等高线 } if ( window.elevationTool.type === "elevation" || window.elevationTool.type === "slope" ) { window.elevationTool.type = "none"; //关闭高程图与坡度图 } window.elevationTool.render(); // 关闭地形轮廓 if (window.AnalysisDXPM) { window.AnalysisDXPM && window.AnalysisDXPM.deleteObject(); layer.closeAll(); } // 关闭淹没 if (window.AnalysisFlood) { window.AnalysisFlood && window.AnalysisFlood.deleteObject(); } // 关闭缓冲区 if (window.buff) { window.buff.clearBuff(); } // 关闭地形开挖 if (window.Excavation) { window.Excavation.clear(); } // 关闭卫星轨迹 if (wxgjData) { wxgjData.clear(); wxgjData = undefined; } // 关闭热力图分析 if (HeatMapData) { HeatMapData.deleteObject(); HeatMapData = undefined; } // 关闭雷达反射率 if (ldfslData) { ldfslData.deleteObject(); ldfslData = undefined; } // 关闭人口迁徙可视化 if (rkqxData) { rkqxData.clear(); rkqxData = undefined; } // 关闭通视 if (window.ts) { window.ts.forEach(element => { element.deleteObject(); }); } // 关闭视域 if (viewshed) { viewshed.close(); viewshed = null; } // 关闭日照分析结果 window._AnalysisSunshine && window._AnalysisSunshine.remove(); window._AnalysisSunshine = undefined // 关闭阴影分析结果 window.Viewer.clockViewModel.currentTime = new Date().getTime(); window.Viewer.clock.multiplier = 1; this.$refs.ShadowAnalysis.form.isPlay = false; this.$refs.ShadowAnalysis.form.isStop = true; window.Viewer.shadows = false; // 关闭天际线 window.sgworld.Analysis.clearSkylineAnalysis(); this.$message.info("分析结果已全部清除"); }, } }