| | |
| | | import chooseDeviceDialog from './chooseDeviceDialog.vue'; |
| | | import chooseModelDialog from './chooseModelDialog.vue'; |
| | | import { obtainRealData ,buildKmz} from "@/api/system/template" |
| | | |
| | | let rotationAngle = Cesium.Math.toRadians(0) |
| | | export default{ |
| | | components: { |
| | | CesiumMap, |
| | |
| | | this.$emit('close') |
| | | }, |
| | | flyToLocal(row){ |
| | | console.log(row) |
| | | const position = Cesium.Cartesian3.fromDegrees(row.longitude,row.latitude, row.deviceHeight); |
| | | |
| | | // rotationAngle = Cesium.Math.toRadians(row.face) || Cesium.Math.toRadians(0) |
| | | rotationAngle = Cesium.Math.toRadians(row.face) || Cesium.Math.toRadians(0) |
| | | // 设置模型方向(可选) |
| | | const heading = Cesium.Math.toRadians(row.face); // 朝东南方向 |
| | | const pitch = 0; |
| | |
| | | }, |
| | | receiveModel(obj){ |
| | | //deal逻辑 |
| | | console.log(obj) |
| | | let flightTemplateId =obj.modelObj.id |
| | | let deviceId = obj.deviceId |
| | | this.dealTableTemplate(obj) |
| | |
| | | obtainRealData(flightTemplateId,deviceId).then(res=>{ |
| | | console.log(res) |
| | | let treeDealData = this.transformFlightData(res.data?.coordinateSystemVoS || []) |
| | | console.log(treeDealData) |
| | | this.dealTreeMerge(obj,treeDealData) |
| | | // const aaa = this.rotateAllPoints(this.treeData || [],res.data.longitude,res.data.latitude,res.data.height) |
| | | this.drawConnectionsWithLabels(this.treeData) |
| | | this.rotateAllPoints(this.treeData || [],res.data.longitude,res.data.latitude,res.data.height) |
| | | this.drawConnectionsWithLabels(this.treeData) |
| | | }) |
| | | // this.dealTreeMerge(obj) |
| | | }, |
| | |
| | | }, |
| | | drawConnectionsWithLabels(devices) { |
| | | const airPoints = []; |
| | | |
| | | devices.forEach(device => { |
| | | if (!Array.isArray(device.children)) return; |
| | | |
| | | device.children.forEach(airPoint => { |
| | | // 空中点位置 |
| | | const airPos = Cesium.Cartesian3.fromDegrees( |
| | |
| | | }, |
| | | rotateAllPoints(dataList,towerLongitude,towerLatitude,towerhHight) { |
| | | return dataList.map(item => { |
| | | console.log(item) |
| | | console.log(towerLongitude) |
| | | console.log(towerLatitude) |
| | | console.log(towerhHight) |
| | | const groundPoint = Cesium.Cartesian3.fromDegrees(item.longitude, item.latitude, item.height); |
| | | const towerPoint = Cesium.Cartesian3.fromDegrees(towerLongitude, towerLatitude, towerhHight); |
| | | let rotationAngle = Cesium.Math.toRadians(135) |
| | | // 旋转地面点本身(会变,但绕自身旋转不会移动) |
| | | const newGroundPoint = this.rotateAroundPoint( groundPoint,towerPoint, rotationAngle); |
| | | const newGroundCarto = Cesium.Cartographic.fromCartesian(newGroundPoint); |
| | | const newGround = { |
| | | ...item, |
| | | longitude: Cesium.Math.toDegrees(newGroundCarto.longitude), |
| | | latitude: Cesium.Math.toDegrees(newGroundCarto.latitude), |
| | | height: newGroundCarto.height |
| | | }; |
| | | console.log(newGround) |
| | | // 处理子空中点 |
| | |
| | | const airPoint = Cesium.Cartesian3.fromDegrees(child.longitude, child.latitude, child.height); |
| | | const rotatedAirPoint = this.rotateAroundPoint( airPoint,towerPoint, rotationAngle); |
| | | const rotatedAirCarto = Cesium.Cartographic.fromCartesian(rotatedAirPoint); |
| | | |
| | | return { |
| | | ...child, |
| | | longitude: Cesium.Math.toDegrees(rotatedAirCarto.longitude), |
| | | latitude: Cesium.Math.toDegrees(rotatedAirCarto.latitude), |
| | | height: rotatedAirCarto.height |
| | | }; |
| | | child.longitude = Cesium.Math.toDegrees(rotatedAirCarto.longitude) |
| | | child.latitude = Cesium.Math.toDegrees(rotatedAirCarto.latitude) |
| | | child.height = rotatedAirCarto.height |
| | | child.children = child.children.map(sonChild => { |
| | | const groundPoint = Cesium.Cartesian3.fromDegrees(sonChild.longitude, sonChild.latitude, sonChild.height); |
| | | const newGroundPoint = this.rotateAroundPoint( groundPoint,towerPoint, rotationAngle); |
| | | const newGroundCarto = Cesium.Cartographic.fromCartesian(newGroundPoint); |
| | | return { |
| | | ...sonChild, |
| | | longitude: Cesium.Math.toDegrees(newGroundCarto.longitude), |
| | | latitude: Cesium.Math.toDegrees(newGroundCarto.latitude), |
| | | height: newGroundCarto.height |
| | | }; |
| | | }); |
| | | }); |
| | | |
| | | return newGround; |
| | |
| | | // 计算点A绕点B逆时针旋转指定角度后的新位置 |
| | | // 空中点或者地面点笛卡尔坐标 塔的笛卡尔坐标 塔的朝向值 |
| | | rotateAroundPoint(startPoint,pivotPoint,rotationAngle) { |
| | | console.log(rotationAngle) |
| | | // 创建一个从B点到本地坐标系的转换矩阵(东方向为X轴,北方向为Y轴,垂直方向为Z轴) |
| | | const transformationMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(pivotPoint); |
| | | // 获取世界坐标系到本地坐标系的转换矩阵 |