| | |
| | | // 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 = { |
| | |
| | | slopeArrow: null, |
| | | elevationTool: null, |
| | | rainEffect: null, |
| | | snowEffect: null, // 新增雪效果实例 |
| | | regionTerrain: null, |
| | | polygonPosition: [], |
| | | |
| | | init(earthCtrl) { |
| | | this.earthCtrl = earthCtrl; |
| | |
| | | const b = parseInt(hex.substring(4, 6), 16) / 255; |
| | | return new Cesium.Color(r, g, b, 1.0); |
| | | }, |
| | | // 天气 |
| | | // 清除天气特效 |
| | | 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') |
| | | // 先销毁旧实例 |
| | |
| | | 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), // 雪的颜色 |
| | | }); |
| | | |
| | | // 控制显示/隐藏 |
| | | if (this.snowEffect) { |
| | | this.snowEffect.show(show); |
| | | } |
| | | }, |
| | | // 区域划分工具 |
| | | hfqy() { |
| | | // 初始化区域地形 |
| | | this.regionTerrain = earthCtrl.factory.createRegionTerrain({}); |
| | | this.polygonPosition = []; |
| | | |
| | | // 创建绘制工具 |
| | | const drawTool = earthCtrl.shapeTool.createDrawShapeTool((e) => { |
| | | try { |
| | | if (!e || !e.result) { |
| | | throw new Error('Invalid drawing result'); |
| | | } |
| | | |
| | | // 转换坐标并存储 |
| | | const polygonI = []; |
| | | for (const point of e.result) { |
| | | const cartographic = earthCtrl.coreMap.scene.globe.ellipsoid.cartesianToCartographic(point); |
| | | const lon = Cesium.Math.toDegrees(cartographic.longitude); |
| | | const lat = Cesium.Math.toDegrees(cartographic.latitude); |
| | | |
| | | polygonI.push(lon, lat, 0); |
| | | this.polygonPosition.push(lon, lat); |
| | | } |
| | | |
| | | // 设置区域地形 |
| | | this.regionTerrain.setPositions(this.polygonPosition); |
| | | this.regionTerrain.setRegionEnabled(true); |
| | | |
| | | // 清除绘制工具 |
| | | drawTool.removeFromMap(); |
| | | } catch (error) { |
| | | console.error('Error during region drawing:', error); |
| | | drawTool.removeFromMap(); |
| | | } |
| | | }); |
| | | |
| | | return drawTool; |
| | | }, |
| | | // 坡向箭头 |
| | | pxjt(colors, angles) { |
| | | this.hfqy() |
| | | this.slopeArrow = earthCtrl.factory.createSlopeArrow({}); |
| | | this.slopeArrow.setColorsAndAngles(colors, angles); |
| | | this.regionTerrain.setPositions(this.polygonPosition); |
| | | this.regionTerrain.setRegionEnabled(true); |
| | | this.slopeArrow.setSlopeType(1); |
| | | }, |
| | | |
| | | // 坡度分析 |
| | | pdfx(option) { |
| | | this.hfqy() |
| | | this.elevationTool = new SmartEarth.ElevationTool(earthCtrl) |
| | | if (option.terrainRender == '1') { |
| | | this.elevationTool.type = 'slope' |
| | |
| | | this.elevationTool.setWidth(option.lineWidth) |
| | | this.elevationTool.setContourColor(option.color); |
| | | this.elevationTool.render(); |
| | | console.log(this.elevationTool, 'eleelelelelelelel') |
| | | }, |
| | | // 坡向箭头 |
| | | pxjt(colors, angles) { |
| | | this.slopeArrow = earthCtrl.factory.createSlopeArrow({}); |
| | | this.slopeArrow.setColorsAndAngles(colors, angles); |
| | | |
| | | // 创建绘制工具 |
| | | const drawTool = 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); // 纬度 |
| | | polygonI.push(lon, lat, 0); |
| | | polygonPosition.push(lon, lat); |
| | | } |
| | | const PolygonArr = []; |
| | | 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') |
| | | }); |
| | | }, |
| | | // 关闭坡向箭头 |
| | | gbpxjt() { |
| | | // 清理所有分析工具 |
| | | cleanupAnalysisTools() { |
| | | // 坡向箭头 |
| | | if (this.slopeArrow) { |
| | | this.slopeArrow.setSlopeType(0); |
| | | this.slopeArrow = 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); |
| | | // 选择区域 |
| | | if (this.regionTerrain) { |
| | | this.regionTerrain.setRegionEnabled(false); |
| | | this.regionTerrain = null; |
| | | } |
| | | this.polygonPosition = []; |
| | | }, |
| | | |
| | | // 标绘 |
| | | CreateLabel(pic, show) { |
| | | if (show) { |