From 8b44975cb1d7abd35e0ecfd289bd37596ab28302 Mon Sep 17 00:00:00 2001 From: wxs <211789910@qq.com> Date: Sat, 28 Feb 2026 15:21:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=8D=A2=E6=88=90=E7=94=A8=E5=9B=BE?= =?UTF-8?q?=E5=B1=82=E6=8E=A7=E5=88=B6=EF=BC=8C=E5=A6=82=E6=9E=9C=E5=AE=9E?= =?UTF-8?q?=E6=B5=8B=E4=B8=8D=E5=A5=BD=E4=BD=BF=E8=BF=98=E5=8F=AF=E4=BB=A5?= =?UTF-8?q?=E6=94=B9=E6=88=90=E5=8E=9F=E6=9D=A5=E7=9A=84=E6=96=B9=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../twin-situation/OrthoImageryManager.js | 139 ++++++++++++++++++ .../home/components/twin-situation/index.js | 14 +- 2 files changed, 149 insertions(+), 4 deletions(-) create mode 100644 frontend/Skyeye-sys-ui/src/views/home/components/twin-situation/OrthoImageryManager.js diff --git a/frontend/Skyeye-sys-ui/src/views/home/components/twin-situation/OrthoImageryManager.js b/frontend/Skyeye-sys-ui/src/views/home/components/twin-situation/OrthoImageryManager.js new file mode 100644 index 0000000..7d3620b --- /dev/null +++ b/frontend/Skyeye-sys-ui/src/views/home/components/twin-situation/OrthoImageryManager.js @@ -0,0 +1,139 @@ +// /src/utils/OrthoImageryManager.js +export default class OrthoImageryManager { + + constructor(viewer, Cesium, options = {}) { + this.viewer = viewer; + this.Cesium = Cesium; + + this.layerMap = new Map(); // key -> layer + this.layerQueue = []; // 先进先出控制数量 + + this.maxLayers = options.maxLayers || 400; + + // 全局亮度与透明度 + this.globalBrightness = options.brightness ?? 1.0; + this.globalAlpha = options.alpha ?? 1.0; + } + + /** + * 添加或更新新推送的图片 + */ + add(data) { + const key = `${data.jobId}-${data.uavId}~${data.fileId}`; + + // 已存在则跳过 + if (this.layerMap.has(key)) return; + + const rectangle = this.Cesium.Rectangle.fromDegrees( + Math.min(data.left1Lon, data.right2Lon), + Math.min(data.left1Lat, data.right2Lat), + Math.max(data.left1Lon, data.right2Lon), + Math.max(data.left1Lat, data.right2Lat) + ); + + const provider = new this.Cesium.SingleTileImageryProvider({ + url: window.config.imagePath + data.relativePath, + rectangle + }); + + const layer = this.viewer.cesiumViewer.imageryLayers.addImageryProvider(provider); + + // ✅ 使用全局亮度和透明度,保证新图生效 + layer.brightness = this.globalBrightness; + layer.alpha = this.globalAlpha; + + this.layerMap.set(key, layer); + this.layerQueue.push(key); + + this._checkLimit(); + } + + /** + * 设置全局亮度,影响所有已有图片和未来新推送的图片 + */ + setBrightness(value) { + this.globalBrightness = value; + this.layerMap.forEach(layer => { + layer.brightness = value; + }); + } + + /** + * 设置全局透明度 + */ + setAlphaAll(value) { + this.globalAlpha = value; + this.layerMap.forEach(layer => { + layer.alpha = value; + }); + } + + /** + * 对单张图片单独设置亮度(不影响全局) + */ + setBrightnessForFile(fileId, value) { + const key = [...this.layerMap.keys()].find(k => k.includes(fileId)); + if (!key) return; + + const layer = this.layerMap.get(key); + if (layer) { + layer.brightness = value; + } + } + + /** + * 对单张图片单独设置透明度 + */ + setAlphaForFile(fileId, value) { + const key = [...this.layerMap.keys()].find(k => k.includes(fileId)); + if (!key) return; + + const layer = this.layerMap.get(key); + if (layer) { + layer.alpha = value; + } + } + + /** + * 清理超过最大图层数 + */ + _checkLimit() { + while (this.layerQueue.length > this.maxLayers) { + const oldestKey = this.layerQueue.shift(); + const layer = this.layerMap.get(oldestKey); + if (layer) { + this.viewer.imageryLayers.remove(layer); + this.layerMap.delete(oldestKey); + } + } + } + + /** + * 删除单张图片 + */ + remove(fileId) { + const key = [...this.layerMap.keys()].find(k => k.includes(fileId)); + if (!key) return; + + const layer = this.layerMap.get(key); + if (layer) { + this.viewer.imageryLayers.remove(layer); + this.layerMap.delete(key); + + // 也从队列里移除 + const index = this.layerQueue.indexOf(key); + if (index > -1) this.layerQueue.splice(index, 1); + } + } + + /** + * 清空所有图片 + */ + clearAll() { + this.layerMap.forEach(layer => { + this.viewer.cesiumViewer.imageryLayers.remove(layer); + }); + this.layerMap.clear(); + this.layerQueue = []; + } +} diff --git a/frontend/Skyeye-sys-ui/src/views/home/components/twin-situation/index.js b/frontend/Skyeye-sys-ui/src/views/home/components/twin-situation/index.js index 6a4dd6f..0389b92 100644 --- a/frontend/Skyeye-sys-ui/src/views/home/components/twin-situation/index.js +++ b/frontend/Skyeye-sys-ui/src/views/home/components/twin-situation/index.js @@ -1,4 +1,5 @@ import { lodLayer, viewer } from '@/components/dt-scene/index.vue' +import OrthoImageryManager from './OrthoImageryManager' import OrthoManager from './OrthoManager' // 新增空间态势统计 @@ -509,10 +510,15 @@ export default { // this.resourceClick(this.resourceList.data[0]) this.handleSceneComplete() this.getTaskList() - orthoManager = new OrthoManager( - viewer, - DT.Cesium - ) + // orthoManager = new OrthoManager( + // viewer, + // DT.Cesium + // ) + orthoManager = new OrthoImageryManager(viewer, DT.Cesium, { + maxLayers: 400, + brightness: 1.2, // 默认亮度 + alpha: 1.0 // 默认透明度 + }) // this.startTest() }, beforeDestroy() {