| | |
| | | // import cameraIcon from "../assets/images/base/视频测点.png" |
| | | // import cameraIconSel from "../assets/images/base/视频测点sel.png" |
| | | import { ElLoading, ElMessage } from "element-plus"; |
| | | import RainEffect from "./rain"; |
| | | import SnowEffect from "./snow"; |
| | | let layerIsOpen = false; |
| | | const Cesium = SmartEarth.Cesium; |
| | | const colorAll = { |
| | |
| | | analysisDXPMRes: [], |
| | | slopeArrow: null, |
| | | elevationTool: null, |
| | | rainEffect: null, |
| | | snowEffect: null, // 新增雪效果实例 |
| | | regionTerrain: null, |
| | | polygonPosition: [], |
| | | PolygonArr: [], |
| | | |
| | | init(earthCtrl) { |
| | | this.earthCtrl = earthCtrl; |
| | | return this; |
| | | }, |
| | | // 坡度分析 |
| | | pdfx(option) { |
| | | this.elevationTool = new SmartEarth.ElevationTool(earthCtrl) |
| | | if (option.terrainRender == '1') { |
| | | this.elevationTool.type = 'slope' |
| | | } else { |
| | | this.elevationTool.type = 'none' |
| | | } |
| | | this.elevationTool.tf = option.contourLines |
| | | this.elevationTool.setSpacing(option.spacing) |
| | | this.elevationTool.setWidth(option.lineWidth) |
| | | this.elevationTool.setContourColor(option.color); |
| | | this.elevationTool.render(); |
| | | console.log(this.elevationTool, 'eleelelelelelelel') |
| | | hexToColor(hexColor) { |
| | | const hex = hexColor.replace("#", ""); |
| | | const r = parseInt(hex.substring(0, 2), 16) / 255; |
| | | const g = parseInt(hex.substring(2, 4), 16) / 255; |
| | | const b = parseInt(hex.substring(4, 6), 16) / 255; |
| | | return new Cesium.Color(r, g, b, 1.0); |
| | | }, |
| | | // 坡向箭头 |
| | | pxjt(colors, angles) { |
| | | this.slopeArrow = earthCtrl.factory.createSlopeArrow({}); |
| | | this.slopeArrow.setColorsAndAngles(colors, angles); |
| | | // 清除天气特效 |
| | | delRain() { |
| | | if (this.rainEffect) { |
| | | this.rainEffect.destroy(); |
| | | this.rainEffect = null; |
| | | } |
| | | }, |
| | | delSnow() { |
| | | if (this.snowEffect) { |
| | | this.snowEffect.destroy(); |
| | | this.snowEffect = null; |
| | | } |
| | | }, |
| | | // 雨天模拟 |
| | | toggleRain(option, show) { |
| | | // console.log(option, "option"); |
| | | // 先销毁旧实例 |
| | | if (this.rainEffect) { |
| | | this.rainEffect.destroy(); |
| | | this.rainEffect = null; |
| | | } |
| | | this.rainEffect = new RainEffect(earthCtrl.viewer, { |
| | | tiltAngle: -0.2, //倾斜角度 |
| | | rainSize: option.rainSize, // 雨的大小 |
| | | rainSpeed: option.rainSpeed, // 雨的速度 |
| | | rainDensity: option.rainDensity, // 雨的密度 |
| | | color: this.hexToColor(option.rainColor), // 雨的颜色 |
| | | }); |
| | | }, |
| | | // 雪天模拟 |
| | | toggleSnow(option = {}, show = true) { |
| | | console.log(option, "option"); |
| | | const defaultOption = { |
| | | snowSize: 0.02, // 默认雪的大小 |
| | | snowSpeed: 100.0, // 默认雪的速度 |
| | | snowColor: "#ffffff", // 默认颜色:白色 |
| | | }; |
| | | option = { ...defaultOption, ...option }; |
| | | if (this.snowEffect) { |
| | | this.snowEffect.destroy(); |
| | | this.snowEffect = null; |
| | | } |
| | | this.snowEffect = new SnowEffect(earthCtrl.viewer, { |
| | | snowSize: option.snowSize, // 雪的大小 |
| | | snowSpeed: option.snowSpeed, // 雪的速度 |
| | | snowColor: this.hexToColor(option.snowColor), // 雪的颜色 |
| | | }); |
| | | |
| | | // 创建绘制工具 |
| | | const drawTool = earthCtrl.shapeTool.createDrawShapeTool((e) => { |
| | | // 控制显示/隐藏 |
| | | if (this.snowEffect) { |
| | | this.snowEffect.show(show); |
| | | } |
| | | }, |
| | | // 区域划分工具 |
| | | hfqy() { |
| | | this.regionTerrain = earthCtrl.factory.createRegionTerrain({}); |
| | | this.polygonPosition = []; |
| | | |
| | | const draw = earthCtrl.shapeTool.createDrawShapeTool((e) => { |
| | | const polygonI = []; |
| | | const polygonPosition = []; |
| | | for (const i of e.result) { |
| | | const ellipsoid = earthCtrl.coreMap.scene.globe.ellipsoid; |
| | | const cartographic = ellipsoid.cartesianToCartographic(i); |
| | | |
| | | const lon = Cesium.Math.toDegrees(cartographic.longitude); |
| | | const lat = Cesium.Math.toDegrees(cartographic.latitude); // 纬度 |
| | | const lon = SmartEarth.Cesium.Math.toDegrees(cartographic.longitude); // 经度 |
| | | const lat = SmartEarth.Cesium.Math.toDegrees(cartographic.latitude); // 纬度 |
| | | polygonI.push(lon, lat, 0); |
| | | polygonPosition.push(lon, lat); |
| | | this.polygonPosition.push(lon, lat); |
| | | } |
| | | const PolygonArr = []; |
| | | PolygonArr.push({ |
| | | this.PolygonArr.push({ |
| | | id: earthCtrl.factory.createUUID(), |
| | | polygon: polygonI, |
| | | }); |
| | | |
| | | // 清除绘制工具 |
| | | drawTool.removeFromMap(); |
| | | // 设置坡度箭头的位置和类型 |
| | | this.slopeArrow.setPositions(polygonPosition); |
| | | this.slopeArrow.setSlopeType(1); |
| | | this.slopeArrow.setRegionEnabled(true); |
| | | console.log(this.slopeArrow,'slope') |
| | | draw.removeFromMap(); |
| | | this.regionTerrain.setPositions(this.polygonPosition); |
| | | this.regionTerrain.setRegionEnabled(true); |
| | | }); |
| | | }, |
| | | // 关闭坡向箭头 |
| | | gbpxjt() { |
| | | // 坡度分析 |
| | | pdfx() { |
| | | if (this.regionTerrain) { |
| | | console.log("坡度分析"); |
| | | this.clearPreviousAnalysis(); // 先清除之前的分析 |
| | | this.regionTerrain.setType("slope"); |
| | | this.regionTerrain.update(); |
| | | } |
| | | }, |
| | | |
| | | // 坡向箭头 |
| | | pxjt(colors, angles) { |
| | | if (this.regionTerrain) { |
| | | this.clearPreviousAnalysis(); // 先清除之前的分析 |
| | | this.regionTerrain.setType("aspect"); |
| | | this.regionTerrain.update(); |
| | | } |
| | | |
| | | this.slopeArrow = earthCtrl.factory.createSlopeArrow({}); |
| | | this.slopeArrow.setColorsAndAngles(colors, angles); |
| | | this.slopeArrow.setSlopeType(1); |
| | | }, |
| | | |
| | | // 等高线分析 |
| | | dgxfx(option) { |
| | | this.clearPreviousAnalysis(); // 先清除之前的分析 |
| | | this.hfqy(); |
| | | this.elevationTool = new SmartEarth.ElevationTool(earthCtrl); |
| | | this.elevationTool.tf = option.contourLines; |
| | | this.elevationTool.setSpacing(option.spacing); |
| | | this.elevationTool.setWidth(option.lineWidth); |
| | | this.elevationTool.setContourColor(option.color); |
| | | this.elevationTool.render(); |
| | | }, |
| | | |
| | | // 清除之前的分析(坡度、坡向、等高线) |
| | | clearPreviousAnalysis() { |
| | | if (this.regionTerrain) { |
| | | this.regionTerrain.setType(""); |
| | | this.regionTerrain.update(); |
| | | } |
| | | |
| | | if (this.slopeArrow) { |
| | | this.slopeArrow.setSlopeType(0); |
| | | // this.slopeArrow = null; |
| | | } |
| | | }, |
| | | |
| | | // 天气 |
| | | toggleRain(weather = "rain", show) { |
| | | if (show) { |
| | | earthCtrl.environment.showEffect(weather); |
| | | } else { |
| | | earthCtrl.environment.disableEffect(weather); |
| | | if (this.elevationTool) { |
| | | this.elevationTool = null; |
| | | } |
| | | }, |
| | | toggleSnow(weather = "snow", show) { |
| | | if (show) { |
| | | earthCtrl.environment.showEffect(weather); |
| | | } else { |
| | | let snowValue = { |
| | | test1: 2, |
| | | test2: 1.0, |
| | | test3: 0.5, |
| | | test4: 0.5, |
| | | }; |
| | | earthCtrl.environment.disableEffect(weather); |
| | | } |
| | | }, |
| | | |
| | | // 标绘 |
| | | CreateLabel(pic, show) { |
| | | if (show) { |
| | | earthCtrl.factory.createSimpleGraphic(pic, {}, function (entity) { |
| | | console.log(entity, "entity"); |
| | | window.Viewer = earthCtrl.viewer |
| | | window.Viewer = earthCtrl.viewer; |
| | | //开启编辑并启用属性弹窗 |
| | | earthCtrl.factory.SimpleGraphic.edit(true, { |
| | | editProp: true, |
| | |
| | | //直线测量 |
| | | jl() { |
| | | earthCtrl.measure.lineDistance(colorAll, (e) => { |
| | | console.log(e) |
| | | console.log(e); |
| | | }).onEnd = () => { |
| | | console.log("直线测量已完成"); |
| | | }; |
| | |
| | | }, |
| | | //面积测量 |
| | | mjcl() { |
| | | earthCtrl.measure.surfaceArea({ |
| | | ...colorAll, |
| | | tin: true, // 是否显示tin三角网 |
| | | onlyTerrain: false // 是否只测量精细地形 |
| | | }, (e) => { |
| | | console.log(e) |
| | | |
| | | }).onEnd = () => { |
| | | console.log('面积测量已完成') |
| | | } |
| | | earthCtrl.measure.surfaceArea( |
| | | { |
| | | ...colorAll, |
| | | tin: true, // 是否显示tin三角网 |
| | | onlyTerrain: false, // 是否只测量精细地形 |
| | | }, |
| | | (e) => { |
| | | console.log(e); |
| | | } |
| | | ).onEnd = () => { |
| | | console.log("面积测量已完成"); |
| | | }; |
| | | }, |
| | | // 清除测量 |
| | | clear() { |
| | | earthCtrl.measure.clearResult() |
| | | earthCtrl.measure.clearResult(); |
| | | }, |
| | | syfx(option) { |
| | | this.viewShedTool = earthCtrl.analysis.createViewShed({ |
| | |
| | | polyline: Cesium.Color.fromCssColorString("#ffff0050"), |
| | | polygon: Cesium.Color.fromCssColorString("#ffff0050"), |
| | | }, |
| | | (e) => { } |
| | | (e) => {} |
| | | ); |
| | | }, |
| | | qxcl() { |
| | |
| | | polyline: Cesium.Color.fromCssColorString("#ffff0050"), |
| | | polygon: Cesium.Color.fromCssColorString("#ffff0050"), |
| | | }, |
| | | (e) => { } |
| | | (e) => {} |
| | | ); |
| | | }, |
| | | fwjcl() { |
| | |
| | | polyline: Cesium.Color.fromCssColorString("#ffff0050"), |
| | | polygon: Cesium.Color.fromCssColorString("#ffff0050"), |
| | | }, |
| | | (e) => { } |
| | | (e) => {} |
| | | ); |
| | | }, |
| | | // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>场景截图<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
| | |
| | | this.movingCircleViewshed = null; |
| | | } |
| | | }, |
| | | |
| | | // 阴影分析 |
| | | AnalysisSunshine() { |
| | | if (!layerIsOpen) { |
| | |
| | | type: 2, |
| | | title: "阴影分析", |
| | | shade: false, |
| | | area: ["350px", "500px"], |
| | | offset: "l", |
| | | skin: "yyfxForm", |
| | | content: SmartEarthRootUrl + "Workers/analysis/AnalysisSunshine.html", |
| | | area: ["350px", "540px"], |
| | | offset: "r", |
| | | skin: "other-class", |
| | | content: SmartEarthRootUrl + "Workers/analysis/AnalysisShadow.html", |
| | | end: () => { |
| | | window._AnalysisSunshine && window._AnalysisSunshine.remove(); |
| | | window._AnalysisSunshine = undefined; |
| | | layerIsOpen = false; |
| | | }, |
| | | Viewer.clock.currentTime = currentTime; |
| | | Viewer.clock.startTime = startTime; |
| | | Viewer.clock.stopTime = stopTime; |
| | | Viewer.clock.multiplier = multiplier; |
| | | Viewer.shadows = false; |
| | | Viewer.shadowLayer = false; |
| | | } |
| | | }); |
| | | } |
| | | }, |
| | |
| | | }; |
| | | this.analysisFlood = earthCtrl.analysis.createSubmergence( |
| | | method, |
| | | (value) => { } |
| | | (value) => {} |
| | | ); |
| | | }, |
| | | clearFlood() { |
| | |
| | | this.contourLabel.showContourLabel(false); |
| | | } |
| | | }, |
| | | enableAtmosphere() { |
| | | earthCtrl.atmosphere.enable(); |
| | | }, |
| | | disableAtmosphere() { |
| | | earthCtrl.atmosphere.disable(); |
| | | }, |
| | | }; |
| | | |
| | | export default mapUtils; |