From 8696fefc9628f562ac61de64c5c793238b41ed86 Mon Sep 17 00:00:00 2001 From: guonan <guonan201020@163.com> Date: 星期一, 21 四月 2025 13:21:03 +0800 Subject: [PATCH] 修改流光线 --- src/store/simulation.js | 2 public/json/line.json | 50 ++++++++++ src/views/mnfz.vue | 202 +++++++++++++++++++--------------------- 3 files changed, 147 insertions(+), 107 deletions(-) diff --git a/public/json/line.json b/public/json/line.json new file mode 100644 index 0000000..e729851 --- /dev/null +++ b/public/json/line.json @@ -0,0 +1,50 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "geometry": { + "type": "LineString", + "coordinates": [ + [116.59760983462722, 40.55718061951575, 598.7727601629845], + [116.59760983462722, 40.55718061951575, 598.7727601629845], + [116.59644965700153, 40.559317401763465, 569.8277901304249], + [116.59740375239096, 40.560148143453276, 565.7157141156055], + [116.59870671532008, 40.56066772033189, 559.9818134466861], + [116.5989382913525, 40.561279499654816, 560.6004363337727], + [116.59861851530843, 40.56191986528282, 556.7244657770593], + [116.59863937279577, 40.562540361696044, 549.989046117256], + [116.59798186828961, 40.563844128117175, 542.9938582259548], + [116.59754420154454, 40.564258234641095, 540.1763729232823], + [116.5971651744301, 40.56431251805267, 542.1265936059641], + [116.59531329047178, 40.56704193949793, 523.9216605197581], + [116.59466519689155, 40.56774819682324, 520.854586137509], + [116.59371048844169, 40.568490515866735, 515.9891637325094], + [116.59357695557298, 40.56837940750097, 515.9897252144557], + [116.5936486797175, 40.56834910348064, 515.9898053186113] + ] + }, + "properties": {} + }, + { + "type": "Feature", + "geometry": { + "type": "LineString", + "coordinates": [ + [116.58968486232361, 40.57741443362995, 470.43196808102977], + [116.58979068033705, 40.5769004556742, 477.24145981798205], + [116.59043681293315, 40.576324193581456, 477.780635468482], + [116.59156016224689, 40.57434225036743, 486.1814940411667], + [116.59134241985157, 40.57310686967558, 485.9949599924823], + [116.5904829230302, 40.5725751143292, 488.97277966815074], + [116.59164316145382, 40.5706964031903, 497.0488991194549], + [116.59227985803987, 40.569716082751754, 504.36840726535365], + [116.59374203955004, 40.5684339509514, 515.9963172883579], + [116.59361619860711, 40.56835405566704, 515.9929502933207], + [116.59361619860711, 40.56835405566704, 515.9929502933207] + ] + }, + "properties": {} + } + ] +} diff --git a/src/store/simulation.js b/src/store/simulation.js index a873b34..35b8ab9 100644 --- a/src/store/simulation.js +++ b/src/store/simulation.js @@ -123,7 +123,7 @@ const startMNFZ = () => { init() leftShow.value = true - rightRiverShow.value = true + // rightRiverShow.value = true } const startMNPG = () => { diff --git a/src/views/mnfz.vue b/src/views/mnfz.vue index 12afddf..fade2a7 100644 --- a/src/views/mnfz.vue +++ b/src/views/mnfz.vue @@ -1,9 +1,23 @@ <template> <Left @start="startSimulate" @end="endSimulate" /> - <echartInfo :isDynamicMode="isDynamicMode" :isFinish="isFinish" v-if="loadingSim" /> - <TimeLine v-if="showWaterSimulate" @time-update="timeUpdate" @is-playing="isPlaying" - :waterSimulateParams="waterSimulateParams" @playbackFinished="playbackFinished" @end="endSimulate" /> - <DebuffDetail v-if="showDebuffDetail" @open="openDetail" @close="showDebuffDetail = false" /> + <echartInfo + :isDynamicMode="isDynamicMode" + :isFinish="isFinish" + v-if="rightRiverShow" + /> + <TimeLine + v-if="showWaterSimulate" + @time-update="timeUpdate" + @is-playing="isPlaying" + :waterSimulateParams="waterSimulateParams" + @playbackFinished="playbackFinished" + @end="endSimulate" + /> + <DebuffDetail + v-if="showDebuffDetail" + @open="openDetail" + @close="showDebuffDetail = false" + /> <DebuffTable v-if="showDebuffTable" @close="closeDebuffTable" /> </template> @@ -19,18 +33,27 @@ import { createPoint, geomToGeoJSON } from "@/utils/map.js"; import { loadAreaPolygon, clearAreaPolygon } from "@/utils/area"; -import colors from "@/assets/img/left/colors3.png"; import danger from "@/assets/img/left/danger.png"; import { checkedKeys } from "@/store/index"; + + +import { useSimStore } from "@/store/simulation"; +import { storeToRefs } from "pinia"; +const simStore = useSimStore(); +const { rightRiverShow } = storeToRefs(simStore); + + const waterSimulateParams = ref({}); const showWaterSimulate = ref(false); const showDebuffDetail = ref(false); const showDebuffTable = ref(false); const isDynamicMode = ref(false); const isFinish = ref(true); -const loadingSim = ref(false); const treeMap = new Map(); + + + // 鎻愪緵鏂规硶缁欐墍鏈夊瓙缁勪欢 provide("simulateActions", { @@ -41,14 +64,14 @@ function startSimulate(form) { // console.log("form", form); showWaterSimulate.value = true; - loadingSim.value = true + rightRiverShow.value = true; waterSimulateParams.value = form; } function endSimulate() { - loadingSim.value = false - showDebuffDetail.value = false + rightRiverShow.value = false; + showDebuffDetail.value = false; clearTrailLine(); - removeEmergencyPoints() + removeEmergencyPoints(); removeDataSources(); setTimeout(() => { showWaterSimulate.value = false; @@ -85,7 +108,10 @@ scale: 1.0, verticalOrigin: Cesium.VerticalOrigin.BOTTOM, heightReference: Cesium.HeightReference.CLAMP_TO_GROUND, - distanceDisplayCondition: new Cesium.DistanceDisplayCondition(0, 1500), + distanceDisplayCondition: new Cesium.DistanceDisplayCondition( + 0, + 1500 + ), }, }); dataSource.entities.add(billboardEntity); @@ -95,8 +121,7 @@ }); await Promise.all(loadPromises); setupRowClickListener(dataSources); - } catch (error) { - } + } catch (error) {} } // 娓呴櫎闅愭偅鐐� function removeDataSources() { @@ -143,11 +168,17 @@ ]; // 杩欓噷鏄坊鍔犻伩闄╃偣瀵屾枃鏈珮浜樉绀� list.forEach((item) => { - let point = earthCtrl.factory.createRichTextPoint("閬块櫓鐐�", [item.longitude, item.latitude, item.altitude - 10], { - distanceDisplayCondition: new SmartEarth.Cesium.DistanceDisplayCondition(0, 2000), - fontColor: "#ffffff", - fontSize: 20 - }, "0"); + let point = earthCtrl.factory.createRichTextPoint( + "閬块櫓鐐�", + [item.longitude, item.latitude, item.altitude - 10], + { + distanceDisplayCondition: + new SmartEarth.Cesium.DistanceDisplayCondition(0, 2000), + fontColor: "#ffffff", + fontSize: 20, + }, + "0" + ); console.log("point", point); emergencyAreaList.push(point); }); @@ -158,10 +189,10 @@ const emergencyAreaList = treeMap.get("閬块櫓鐐�"); // 鑾峰彇瀛樺偍鐨勯伩闄╃偣瀹炰綋鍒楄〃 if (emergencyAreaList && emergencyAreaList.length > 0) { emergencyAreaList.forEach((entity) => { - if (entity && typeof entity.deleteObject === 'function') { + if (entity && typeof entity.deleteObject === "function") { // 濡傛灉鏈� deleteObject 鏂规硶锛屼紭鍏堣皟鐢� entity.deleteObject(); - } else if (entity && typeof entity.clear === 'function') { + } else if (entity && typeof entity.clear === "function") { // 濡傛灉鏈� clear 鏂规硶锛岃皟鐢� clear entity.clear(); } else if (entity && earthCtrl && earthCtrl.coreMap) { @@ -173,92 +204,34 @@ } } -let TrailLine = []; -async function showLine() { - const position = [ - { - x: -2172540.8322597803, - y: 4339064.62665997, - z: 4126183.3895281963, - }, - { - x: -2172480.18394144, - y: 4339033.15167176, - z: 4126240.9529584926, - }, - { - x: -2172454.114348403, - y: 4339020.0398392705, - z: 4126261.946960697, - }, - { - x: -2172377.9670952093, - y: 4338976.609385458, - z: 4126333.862357211, - }, - { - x: -2172299.4142002705, - y: 4338951.971578909, - z: 4126397.5205803993, - }, - { - x: -2172245.1703274297, - y: 4338940.86037857, - z: 4126436.276389208, - }, - { - x: -2172176.7332184147, - y: 4338930.525741544, - z: 4126477.629952572, - }, - { - x: -2172173.8151051304, - y: 4338939.043883864, - z: 4126469.336927342, - }, - { - x: -2172173.7151194704, - y: 4338939.023235937, - z: 4126469.4107743693, - }, - ]; - let LineInterpolation = earthCtrl.core.LineInterpolation(earthCtrl.coreMap, { - positions: position, - num: 50, - getHeight: true, +// 閬块櫓璺嚎 +let pathLayer = null; // 瀛樺偍鍒涘缓鐨勫浘灞� +function showLine() { + // 鍒涘缓鏂板浘灞� + pathLayer = earthCtrl.factory.createPathLayer({ + url: "/json/line.json", + color: "#0033FF", + width: 15.0, + pointColor: "#FFFFFF", + speed: 2, + far: 50000, }); - // console.log(LineInterpolation.height, "A"); - - let min = LineInterpolation.height; - let max = min.map((item) => { - return item + 35; - }); - - console.log(min, max); - - let _TrailLine = earthCtrl.factory.createTrailLineWall( - LineInterpolation.positions, - { - maximumHeights: max, - minimumHeights: min, - color: "#ffffff", //绾块鑹诧紙鍙�夛級 - url: colors, - } - ); - TrailLine.push(_TrailLine); } -// 娓呴櫎杞ㄨ抗绾垮璞� + +// 娓呴櫎閬块櫓璺嚎 function clearTrailLine() { - TrailLine.forEach((item, index) => { - if (item && typeof item.deleteObject === 'function') { - item.deleteObject(); - } else if (item && typeof item.clear === 'function') { - item.clear(); - } else if (item && earthCtrl && earthCtrl.coreMap) { - earthCtrl.coreMap.entities.remove(item); - } - }); - TrailLine = []; + if (pathLayer) { + pathLayer.clear(); + } + // if (item && typeof item.deleteObject === "function") { + // item.deleteObject(); + // } else if (item && typeof item.clear === "function") { + // item.clear(); + // } else if (item && earthCtrl && earthCtrl.coreMap) { + // earthCtrl.coreMap.entities.remove(item); + // } + // }); + // pathLayer = []; } function timeUpdate(percentage) { if (percentage > 99) { @@ -345,7 +318,9 @@ // 鍒囨崲棰滆壊锛堜緥濡傜孩鑹插拰鍘熷棰滆壊浜ゆ浛锛� const currentTime = Date.now(); const flashColor = Cesium.Color.RED.withAlpha(1); // 闂姩棰滆壊 - return Math.floor(currentTime / 500) % 2 === 0 ? flashColor : originalColor; + return Math.floor(currentTime / 500) % 2 === 0 + ? flashColor + : originalColor; }, false) ); // 灏嗛棯鍔ㄧ姸鎬佷繚瀛樺埌瀹炰綋涓婏紝渚夸簬鍚庣画鎺у埗 @@ -356,18 +331,33 @@ function stopFlashing(polygonEntity) { // 鎭㈠鍘熷棰滆壊 const originalColor = polygonEntity._originalColor || Cesium.Color.WHITE; // 濡傛灉娌℃湁鍘熷棰滆壊锛岄粯璁や娇鐢ㄧ櫧鑹� - polygonEntity.polygon.material = new Cesium.ColorMaterialProperty(originalColor); + polygonEntity.polygon.material = new Cesium.ColorMaterialProperty( + originalColor + ); // 娓呯┖闂姩鐘舵�� polygonEntity._isFlashing = false; polygonEntity._originalColor = null; // 娓呴櫎淇濆瓨鐨勫師濮嬮鑹� } onMounted(() => { - setupRowClickListener() + setupRowClickListener(); getMaxInfluenceAreaData(); }); onUnmounted(() => { endSimulate(); }); +// // 杞崲鍧愭爣绯伙紝绗涘崱灏斿潗鏍囪浆涓篧GS48 +// const positions = [[-2171569.1995107993, 4338474.198855222, 4127198.938949332]]; +// const wgs84Positions = positions.map((xyz) => { +// const cartesian = Cesium.Cartesian3.fromArray(xyz); +// const cartographic = Cesium.Cartographic.fromCartesian(cartesian); + +// // 寮у害杞搴� +// const lon = Cesium.Math.toDegrees(cartographic.longitude); +// const lat = Cesium.Math.toDegrees(cartographic.latitude); +// const height = cartographic.height; // 鍗曚綅锛氱背 + +// return [lon, lat, height]; +// }); </script> <style lang="less" scoped> @import url("../assets/css/home.css"); -- Gitblit v1.9.3