From ecc89fd2f61441ea03a264f6111a6089ce4ed2aa Mon Sep 17 00:00:00 2001 From: jihongshun <1151753686@qq.com> Date: 星期一, 28 七月 2025 10:58:53 +0800 Subject: [PATCH] 视锥体保存更新 --- src/views/system/shootPoint/components/shootPointDialog.vue | 182 ++++++++++++++++++++++++++++++++++++--------- 1 files changed, 145 insertions(+), 37 deletions(-) diff --git a/src/views/system/shootPoint/components/shootPointDialog.vue b/src/views/system/shootPoint/components/shootPointDialog.vue index 92d54c7..cf11a51 100644 --- a/src/views/system/shootPoint/components/shootPointDialog.vue +++ b/src/views/system/shootPoint/components/shootPointDialog.vue @@ -12,11 +12,16 @@ <div class="chooseModel"> <el-button type="primary" @click='chooseModel'>閫夋嫨妯″瀷</el-button> <div class="modelType"> - 妯″瀷鍚嶇О锛歿{ templateName }} + 妯″瀷鍚嶇О锛歿{ modelName }} </div> <div> 妯″瀷绫诲瀷锛歿{ templateType }} </div> + <el-form label-width="70px" :model="form"> + <el-form-item label="妯℃澘鍚嶇О"> + <el-input v-model="form.templateName"></el-input> + </el-form-item> + </el-form> </div> <div class="modelTree"> <div class='modelTreeTitle'>宸℃鐐圭洰褰�</div> @@ -46,21 +51,28 @@ </div> </template> <script> +import { compileToFunctions } from "vue-template-compiler"; import CesiumMap from "../../../../utils/components/cesium-map.vue"; import InitMap from "../../../../utils/components/init-map.vue"; import ChooseModelDialog from './chooseModelDialog.vue'; -import { addPoint} from "@/api/system/template" - let globalon = 0 +import { addPoint , getPointInfo} from "@/api/system/template" +let globalon = 0 let globalat = 0 -const centerCartesian = Cesium.Cartesian3.fromDegrees(globalon,globalat , 0) -let rotationAngle = Cesium.Math.toRadians(60) -let relativeData +let towerHeight = 47.47 +//濉旂殑鏈濆悜绠楁硶鎵�鐢ㄥ埌鐨� 鏃嬭浆搴︽暟 +let rotationAngle = Cesium.Math.toRadians(0) export default{ name:'shootPointDialog', components: { CesiumMap, ChooseModelDialog, InitMap + }, + props: { + templateId: { + type: String, + defaule: null + } }, data(){ return{ @@ -78,13 +90,92 @@ showMap:false, towerUrl:null, chooseModelId:null, - templateName:null, - templateType:null + modelName:null, + templateType:null, + form:{} } }, mounted(){ + console.log(this.templateId) + if(this.templateId) { + //棰勮閫昏緫 + getPointInfo(this.templateId).then(res=>{ + if(res.code == 200 ) { + console.log(res.data) + this.getRowData(res.data) + let drawArr = this.convertToTree(res.data.ardListWayPointsLS) + setTimeout(() => { + //娓叉煋鏃堕棿闂 鍔犱釜寤舵椂鍣� + this.drawLines(drawArr) + }, 500); + } + }) + } }, methods:{ + convertToTree(data) { + return data.map((item, index) => { + const parentId = 'air_' + index; + return { + id: parentId, + label: item.targetName, + longitude: item.longitude, + latitude: item.latitude, + height: item.altitude, + children: (item.ardGroundPoint || []).map((g, i) => { + return { + id: parentId + '_ground_' + i, + label: g.targetName, + longitude: g.longitude, + latitude: g.latitude, + height: g.height + } + }) + } + }); + }, + drawLines(treeData) { + console.log(treeData) + console.log(window) + console.log(window.viewerM) + let viewer = window.viewerM + + // 鏀堕泦绌轰腑鐐逛綅缃� + const airPositions = treeData.map(point => { + return Cesium.Cartesian3.fromDegrees( + point.longitude, + point.latitude, + point.height + ); + }); + + // 1. 绌轰腑鐐逛箣闂寸敤榛勮壊瀹炵嚎杩炴帴 + viewer.entities.add({ + polyline: { + positions: airPositions, + width: 2, + material: Cesium.Color.YELLOW + } + }); + + // 2. 姣忎釜绌轰腑鐐逛笌鍦伴潰鐐圭敤钃濊壊铏氱嚎杩炴帴 + treeData.forEach(point => { + const airPos = Cesium.Cartesian3.fromDegrees(point.longitude, point.latitude, point.height); + point.children.forEach(child => { + const groundPos = Cesium.Cartesian3.fromDegrees(child.longitude, child.latitude, child.height); + viewer.entities.add({ + polyline: { + positions: [airPos, groundPos], + width: 1, + material: new Cesium.PolylineDashMaterialProperty({ + color: Cesium.Color.BLUE, + dashLength: 8 + }) + } + }); + }); + }); + }, addPoint(viewer, position, color, label) { viewer.entities.add({ name: label, @@ -163,11 +254,12 @@ return newGround; }); }, + //鍚堝苟閫昏緫 灏嗛檮杩憂绫宠寖鍥村唴鐨勭偣鍚堝苟 骞朵笖澶勭悊鎴愭暟鎹� mergePoint(arr,mergeNumber,viewer){ this.treeData = arr const result = this.replaceCloseChildrenWithHighestPoint(this.treeData,mergeNumber); // const updated = this.insertRaisedPoints(result, 0,0, 236, 130); - const updated = this.insertRaisedPoints(result, globalon, globalat, 236, 130); + const updated = this.insertRaisedPoints(result, globalon, globalat, towerHeight); this.treeData = updated const airPoints = [] this.treeData.forEach(item => { @@ -204,7 +296,7 @@ console.log(this.treeData) }, //鏁扮粍 濉旂殑绮惧害 濉旂殑绾害 濉旂殑楂樺害 鍗婂緞 - insertRaisedPoints(data, centerLon, centerLat, centerHeight, radius = 130) { + insertRaisedPoints(data, centerLon, centerLat, centerHeight, radius = 10) { const center = Cesium.Cartesian3.fromDegrees(centerLon, centerLat, centerHeight); const result = JSON.parse(JSON.stringify(data)); // 娣辨嫹璐濋伩鍏嶆薄鏌撳師鏁版嵁 const inserts = []; // 鐢ㄤ簬瀛樺偍鎻掑叆椤瑰強鍏剁洰鏍囦綅缃� @@ -350,12 +442,22 @@ }, getRowData(row){ console.log(row) - this.templateName = row.modelName + this.modelName = row.modelName this.templateType = row.modelType + if(this.templateId){ + this.form.templateName = row.templateName || '' + } this.chooseModelId = row.id + towerHeight = row.towerHeight || 47.47 this.showMap =false this.$nextTick(()=>{ - this.towerUrl = row.modelRoute + // this.towerUrl = row.modelRoute + + if(this.templateId){ + this.towerUrl = row.ardTowerModel.modelRoute + }else { + this.towerUrl = row.modelRoute + } this.showMap = true }) }, @@ -392,34 +494,40 @@ console.log('鎷栨嫿瀹屾垚', { draggingNode, dropNode, dropType }) }, submit(){ + if(!this.form.templateName){ + return this.$message({ + message: '璇峰厛杈撳叆妯℃澘鍚嶇О鍐嶄繚瀛�', + type: 'warning' + }) + } // this.dialogVisible = false // const dealArr = this.submitDealData() - const transformed = this.treeData.map((groundPoint, index) => { - const pointNumber = index + 1; - const airPoints = groundPoint.children.map(child => ({ - altitude: child.height, - flightTemplateId: "", - latitude: child.latitude, - longitude: child.longitude, - pointNumber: 1, // 鍙牴鎹渶瑕佹敼涓� child 缂栧彿 - targetName:child.label - })); - return { - ardAirPointLs: airPoints, - ardGroundPoint: { - flightTemplateId: "", - height: groundPoint.height, - latitude: groundPoint.latitude, - longitude: groundPoint.longitude, - pointNumber: 1, - targetName: groundPoint.label - }, - pointNumber: pointNumber - }; - }); + const transformed = this.treeData.map((ground, index) => { + const pointNumber = index + 1; + const child = ground.children?.[0] || {}; + + return { + altitude: child.height, + ardGroundPoint: [ + { + height: ground.height, + latitude: ground.latitude, + longitude: ground.longitude, + pointNumber: 1, + targetName: ground.label + } + ], + latitude: child.latitude, + longitude: child.longitude, + pointNumber: pointNumber, + targetName: child.label + }; + }) + console.log(transformed) let parmas = { + templateName:this.form.templateName, modelId:this.chooseModelId, - ard3DCoordinateSystemLs:transformed + ardListWayPointsLS:transformed } addPoint(parmas).then(res=>{ console.log(res) @@ -466,7 +574,7 @@ text-align: center; } .chooseModel{ - height: 100px; + height: 120px; /* border: 1px solid #dddddd; */ } .cameraView{ -- Gitblit v1.9.3