| | |
| | | // 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' |
| | | import RainEffect from "./rain"; |
| | | import SnowEffect from "./snow"; |
| | | let layerIsOpen = false; |
| | | const Cesium = SmartEarth.Cesium; |
| | | const colorAll = { |
| | |
| | | return this; |
| | | }, |
| | | hexToColor(hexColor) { |
| | | const hex = hexColor.replace('#', ''); |
| | | 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; |
| | |
| | | // 清除天气特效 |
| | | delRain() { |
| | | if (this.rainEffect) { |
| | | this.rainEffect.destroy() |
| | | this.rainEffect = null |
| | | this.rainEffect.destroy(); |
| | | this.rainEffect = null; |
| | | } |
| | | }, |
| | | delSnow() { |
| | |
| | | }, |
| | | // 雨天模拟 |
| | | toggleRain(option, show) { |
| | | console.log(option, 'option') |
| | | console.log(option, "option"); |
| | | // 先销毁旧实例 |
| | | if (this.rainEffect) { |
| | | this.rainEffect.destroy() |
| | | this.rainEffect = null |
| | | this.rainEffect.destroy(); |
| | | this.rainEffect = null; |
| | | } |
| | | this.rainEffect = new RainEffect(earthCtrl.viewer, { |
| | | tiltAngle: -0.2, //倾斜角度 |
| | | rainSize: option.rainSize, // 雨的大小 |
| | | rainSpeed: option.rainSpeed, // 雨的速度 |
| | | color: this.hexToColor(option.rainColor) // 雨的颜色 |
| | | }) |
| | | rainDensity: option.rainDensity, // 雨的密度 |
| | | color: this.hexToColor(option.rainColor), // 雨的颜色 |
| | | }); |
| | | }, |
| | | // 雪天模拟 |
| | | toggleSnow(option = {}, show = true) { |
| | | console.log(option, 'option'); |
| | | console.log(option, "option"); |
| | | const defaultOption = { |
| | | snowSize: 0.02, // 默认雪的大小 |
| | | snowSpeed: 100.0, // 默认雪的速度 |
| | |
| | | this.regionTerrain = earthCtrl.factory.createRegionTerrain({}); |
| | | this.polygonPosition = []; |
| | | |
| | | const draw = earthCtrl.shapeTool.createDrawShapeTool((e) => { |
| | | const draw = earthCtrl.shapeTool.createDrawShapeTool(e => { |
| | | const polygonI = []; |
| | | for (const i of e.result) { |
| | | const ellipsoid = earthCtrl.coreMap.scene.globe.ellipsoid; |
| | | const cartographic = ellipsoid.cartesianToCartographic(i); |
| | | const lon = SmartEarth.Cesium.Math.toDegrees( |
| | | cartographic.longitude |
| | | ); // 经度 |
| | | const lon = SmartEarth.Cesium.Math.toDegrees(cartographic.longitude); // 经度 |
| | | const lat = SmartEarth.Cesium.Math.toDegrees(cartographic.latitude); // 纬度 |
| | | polygonI.push(lon, lat, 0); |
| | | this.polygonPosition.push(lon, lat); |
| | |
| | | // 坡度分析 |
| | | pdfx() { |
| | | if (this.regionTerrain) { |
| | | console.log('坡度分析'); |
| | | console.log("坡度分析"); |
| | | this.clearPreviousAnalysis(); // 先清除之前的分析 |
| | | this.regionTerrain.setType("slope"); |
| | | this.regionTerrain.update(); |
| | |
| | | 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, |
| | |
| | | |
| | | // 水平测量 |
| | | spjl() { |
| | | earthCtrl.measure.horizontalDistance(colorAll, (e) => { |
| | | earthCtrl.measure.horizontalDistance(colorAll, e => { |
| | | console.log(e); |
| | | }).onEnd = () => { |
| | | console.log("水平测距已完成"); |
| | |
| | | }, |
| | | //直线测量 |
| | | jl() { |
| | | earthCtrl.measure.lineDistance(colorAll, (e) => { |
| | | console.log(e) |
| | | earthCtrl.measure.lineDistance(colorAll, e => { |
| | | console.log(e); |
| | | }).onEnd = () => { |
| | | console.log("直线测量已完成"); |
| | | }; |
| | | }, |
| | | // 垂直测量 |
| | | czgd() { |
| | | earthCtrl.measure.height(colorAll, (e) => { |
| | | earthCtrl.measure.height(colorAll, 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({ |
| | |
| | | if (!this.viewShedTool) { |
| | | this.syfx(option); |
| | | } |
| | | this.viewShedTool.mouseCreate().then((res) => { |
| | | this.viewShedTool.mouseCreate().then(res => { |
| | | callback(res); |
| | | }); |
| | | }, |
| | |
| | | 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.earthCtrl.factory.createSimpleGraphic( |
| | | "polygon", |
| | | { showSize: false, removeEdit: true }, |
| | | (entity) => { |
| | | let postitions = entity.polygon.hierarchy |
| | | .getValue() |
| | | .positions.reduce((obj, cur) => { |
| | | let lonlat = this.cartesainToDegrees(cur); |
| | | obj.push([lonlat.lng, lonlat.lat]); |
| | | return obj; |
| | | }, []); |
| | | entity => { |
| | | let postitions = entity.polygon.hierarchy.getValue().positions.reduce((obj, cur) => { |
| | | let lonlat = this.cartesainToDegrees(cur); |
| | | obj.push([lonlat.lng, lonlat.lat]); |
| | | return obj; |
| | | }, []); |
| | | //多变形闭环 |
| | | postitions.push(postitions[0]); |
| | | let gridRadius = 0.05; |
| | |
| | | } |
| | | hexres.features.forEach((item, index) => { |
| | | if (turf.booleanContains(polygon, item)) { |
| | | let newArr = item.geometry.coordinates[0].map((el) => { |
| | | let newArr = item.geometry.coordinates[0].map(el => { |
| | | return Cesium.Cartesian3.fromDegrees(el[0], el[1]); |
| | | }); |
| | | //网格面 |
| | |
| | | this.RestrictTheHeight.removeFromMap(); |
| | | this.RestrictTheHeight = null; |
| | | } |
| | | earthCtrl.factory.createSimpleGraphic( |
| | | "polygon", |
| | | { showSize: false }, |
| | | (entity) => { |
| | | let arr = []; |
| | | entity.polygon.hierarchy.getValue().positions.forEach((position) => { |
| | | let cartographic = |
| | | SmartEarth.Cesium.Cartographic.fromCartesian(position); |
| | | let lat = SmartEarth.Cesium.Math.toDegrees(cartographic.latitude); |
| | | let lng = SmartEarth.Cesium.Math.toDegrees(cartographic.longitude); |
| | | arr.push(lng, lat); |
| | | }); |
| | | this.earthCtrl.viewer.entities.remove(entity); |
| | | if (viewer.terrainProvider) { |
| | | Cesium.sampleTerrainMostDetailed(viewer.terrainProvider, [ |
| | | Cesium.Cartographic.fromDegrees(arr[0], arr[1]), |
| | | ]).then((updatedPositions) => { |
| | | this.RestrictTheHeight = earthCtrl.analysis.createRestrictTheHeight( |
| | | { |
| | | positions: arr, |
| | | baseHeight: baseHeigh + updatedPositions[0].height, |
| | | // color: SmartEarth.Cesium.Color.GREEN.withAlpha(0.5), |
| | | color: |
| | | SmartEarth.Cesium.Color.fromCssColorString( |
| | | "#ff1515" |
| | | ).withAlpha(0.5), |
| | | } |
| | | ); |
| | | }); |
| | | } else { |
| | | earthCtrl.factory.createSimpleGraphic("polygon", { showSize: false }, entity => { |
| | | let arr = []; |
| | | entity.polygon.hierarchy.getValue().positions.forEach(position => { |
| | | let cartographic = SmartEarth.Cesium.Cartographic.fromCartesian(position); |
| | | let lat = SmartEarth.Cesium.Math.toDegrees(cartographic.latitude); |
| | | let lng = SmartEarth.Cesium.Math.toDegrees(cartographic.longitude); |
| | | arr.push(lng, lat); |
| | | }); |
| | | this.earthCtrl.viewer.entities.remove(entity); |
| | | if (viewer.terrainProvider) { |
| | | Cesium.sampleTerrainMostDetailed(viewer.terrainProvider, [ |
| | | Cesium.Cartographic.fromDegrees(arr[0], arr[1]), |
| | | ]).then(updatedPositions => { |
| | | this.RestrictTheHeight = earthCtrl.analysis.createRestrictTheHeight({ |
| | | positions: arr, |
| | | baseHeight: baseHeigh, |
| | | color: |
| | | SmartEarth.Cesium.Color.fromCssColorString("#ff1515").withAlpha( |
| | | 0.5 |
| | | ), |
| | | baseHeight: baseHeigh + updatedPositions[0].height, |
| | | // color: SmartEarth.Cesium.Color.GREEN.withAlpha(0.5), |
| | | color: SmartEarth.Cesium.Color.fromCssColorString("#ff1515").withAlpha(0.5), |
| | | }); |
| | | } |
| | | }); |
| | | } else { |
| | | this.RestrictTheHeight = earthCtrl.analysis.createRestrictTheHeight({ |
| | | positions: arr, |
| | | baseHeight: baseHeigh, |
| | | color: SmartEarth.Cesium.Color.fromCssColorString("#ff1515").withAlpha(0.5), |
| | | }); |
| | | } |
| | | ); |
| | | }); |
| | | }, |
| | | hcqfxPoint(width) { |
| | | const pointGraphic = earthCtrl.factory.createSimpleGraphic( |
| | | "point", |
| | | {}, |
| | | (entity) => { |
| | | const position = entity.position.getValue(); |
| | | const { lng, lat } = this.transformCartesianToCoord(position); |
| | | const pointBuffer = earthCtrl.analysis.createBufferAnalysis({ |
| | | position: [lng, lat], |
| | | color: SmartEarth.Cesium.Color.YELLOW.withAlpha(0.5), |
| | | radius: width / 1000, |
| | | }); |
| | | pointBuffer.initBuffer(); |
| | | this.Buffers.push(pointBuffer); |
| | | } |
| | | ); |
| | | const pointGraphic = earthCtrl.factory.createSimpleGraphic("point", {}, entity => { |
| | | const position = entity.position.getValue(); |
| | | const { lng, lat } = this.transformCartesianToCoord(position); |
| | | const pointBuffer = earthCtrl.analysis.createBufferAnalysis({ |
| | | position: [lng, lat], |
| | | color: SmartEarth.Cesium.Color.YELLOW.withAlpha(0.5), |
| | | radius: width / 1000, |
| | | }); |
| | | pointBuffer.initBuffer(); |
| | | this.Buffers.push(pointBuffer); |
| | | }); |
| | | }, |
| | | hcqfxLine(width) { |
| | | this.earthCtrl.factory.createSimpleGraphic( |
| | | "polyline", |
| | | { showSize: false }, |
| | | (entity) => { |
| | | const positions = entity.polyline.positions.getValue(); |
| | | let coordinates = []; |
| | | for (let i = 0; i < positions.length; i++) { |
| | | const { lng, lat } = this.transformCartesianToCoord(positions[i]); |
| | | coordinates.push(lng, lat); |
| | | } |
| | | const polulineBuffer = earthCtrl.analysis.createBufferAnalysis({ |
| | | position: coordinates, |
| | | color: SmartEarth.Cesium.Color.YELLOW.withAlpha(0.5), |
| | | radius: width / 1000, |
| | | }); |
| | | polulineBuffer.initPolylineBuffer(); |
| | | this.Buffers.push(polulineBuffer); |
| | | this.earthCtrl.factory.createSimpleGraphic("polyline", { showSize: false }, entity => { |
| | | const positions = entity.polyline.positions.getValue(); |
| | | let coordinates = []; |
| | | for (let i = 0; i < positions.length; i++) { |
| | | const { lng, lat } = this.transformCartesianToCoord(positions[i]); |
| | | coordinates.push(lng, lat); |
| | | } |
| | | ); |
| | | const polulineBuffer = earthCtrl.analysis.createBufferAnalysis({ |
| | | position: coordinates, |
| | | color: SmartEarth.Cesium.Color.YELLOW.withAlpha(0.5), |
| | | radius: width / 1000, |
| | | }); |
| | | polulineBuffer.initPolylineBuffer(); |
| | | this.Buffers.push(polulineBuffer); |
| | | }); |
| | | }, |
| | | hcqfxPolygon(width) { |
| | | this.earthCtrl.factory.createSimpleGraphic( |
| | | "polygon", |
| | | { showSize: false }, |
| | | (entity) => { |
| | | let positions = entity.polygon.hierarchy.getValue().positions; |
| | | let coordinates = []; |
| | | for (let i = 0; i < positions.length; i++) { |
| | | const { lng, lat } = this.transformCartesianToCoord(positions[i]); |
| | | coordinates.push(lng, lat); |
| | | } |
| | | const { lng, lat } = this.transformCartesianToCoord(positions[0]); |
| | | this.earthCtrl.factory.createSimpleGraphic("polygon", { showSize: false }, entity => { |
| | | let positions = entity.polygon.hierarchy.getValue().positions; |
| | | let coordinates = []; |
| | | for (let i = 0; i < positions.length; i++) { |
| | | const { lng, lat } = this.transformCartesianToCoord(positions[i]); |
| | | coordinates.push(lng, lat); |
| | | const polygonBuffer = earthCtrl.analysis.createBufferAnalysis({ |
| | | position: coordinates, |
| | | color: SmartEarth.Cesium.Color.YELLOW.withAlpha(0.5), |
| | | radius: width / 1000, |
| | | }); |
| | | polygonBuffer.initPolylineBuffer(); |
| | | this.Buffers.push(polygonBuffer); |
| | | } |
| | | ); |
| | | const { lng, lat } = this.transformCartesianToCoord(positions[0]); |
| | | coordinates.push(lng, lat); |
| | | const polygonBuffer = earthCtrl.analysis.createBufferAnalysis({ |
| | | position: coordinates, |
| | | color: SmartEarth.Cesium.Color.YELLOW.withAlpha(0.5), |
| | | radius: width / 1000, |
| | | }); |
| | | polygonBuffer.initPolylineBuffer(); |
| | | this.Buffers.push(polygonBuffer); |
| | | }); |
| | | }, |
| | | // 动态视域分析 |
| | | dtsyfxPoint(callback) { |
| | | earthCtrl.factory.createSimpleGraphic("point", {}, (entity) => { |
| | | earthCtrl.factory.createSimpleGraphic("point", {}, entity => { |
| | | let position = entity.position.getValue(); |
| | | let coord = this.transformCartesianToCoord(position); |
| | | this.earthCtrl.viewer.entities.remove(entity); |
| | |
| | | polygonArray: [], |
| | | selectedEntity: null, //选中的实体 |
| | | addPointToMap(row) { |
| | | const filteArr = this.pointsArray.filter((item) => item.type == row.type); |
| | | const filteArr = this.pointsArray.filter(item => item.type == row.type); |
| | | if (filteArr.length > 0) { |
| | | filteArr.forEach((item) => { |
| | | filteArr.forEach(item => { |
| | | item.entity.show = true; |
| | | }); |
| | | return; |
| | |
| | | }); |
| | | }, |
| | | hidePointByType(row) { |
| | | const filteArr = this.pointsArray.filter((item) => item.type == row.type); |
| | | const filteArr = this.pointsArray.filter(item => item.type == row.type); |
| | | if (filteArr.length > 0) { |
| | | filteArr.forEach((item) => { |
| | | filteArr.forEach(item => { |
| | | item.entity.show = false; |
| | | }); |
| | | } |
| | |
| | | callback(poiInfo); |
| | | }, |
| | | setSelectedEntity(entity) { |
| | | this.pointsArray.forEach((item) => { |
| | | this.pointsArray.forEach(item => { |
| | | if (item.id === entity.id) { |
| | | item.entity.billboard.image = cameraIconSel; |
| | | } |
| | | }); |
| | | }, |
| | | clearSelectedEntityStyle(entity) { |
| | | this.pointsArray.forEach((item) => { |
| | | this.pointsArray.forEach(item => { |
| | | if (item.id === entity.id) { |
| | | item.entity.billboard.image = cameraIcon; |
| | | } |
| | |
| | | } |
| | | }, |
| | | createPolygonArea(item) { |
| | | const findItem = this.polygonArray.find((row) => row.id === item.id); |
| | | const findItem = this.polygonArray.find(row => row.id === item.id); |
| | | if (findItem) { |
| | | earthCtrl.viewer.flyTo(findItem.polygon); |
| | | return; |
| | |
| | | heightReference: Cesium.HeightReference.CLAMP_TO_GROUND, |
| | | }, |
| | | }); |
| | | var polyPositions = curPolygon.polygon.hierarchy.getValue( |
| | | Cesium.JulianDate.now() |
| | | ).positions; |
| | | var polyPositions = curPolygon.polygon.hierarchy.getValue(Cesium.JulianDate.now()).positions; |
| | | var polyCenter = Cesium.BoundingSphere.fromPoints(polyPositions).center; //中心点 |
| | | polyCenter = Cesium.Ellipsoid.WGS84.scaleToGeodeticSurface(polyCenter); |
| | | curPolygon.position = polyCenter; |
| | |
| | | this.polygonArray.push(obj); |
| | | }, |
| | | clearPoygon() { |
| | | this.polygonArray.forEach((item) => { |
| | | this.polygonArray.forEach(item => { |
| | | earthCtrl.viewer.entities.remove(item.polygon); |
| | | earthCtrl.viewer.entities.remove(item.polyline); |
| | | }); |
| | |
| | | if (graphic) { |
| | | graphic.clear(); |
| | | } |
| | | this.Buffers.map((item) => { |
| | | this.Buffers.map(item => { |
| | | item.removeFromMap(); |
| | | }); |
| | | this.Buffers = []; |
| | |
| | | GroupID: 0, |
| | | url: SmartEarthRootUrl + "Workers/image/waterNormals.jpg", |
| | | }; |
| | | this.analysisFlood = earthCtrl.analysis.createSubmergence( |
| | | method, |
| | | (value) => { } |
| | | ); |
| | | this.analysisFlood = earthCtrl.analysis.createSubmergence(method, value => {}); |
| | | }, |
| | | clearFlood() { |
| | | this.analysisFlood && this.analysisFlood.endWater(); |