更换成用图层控制,如果实测不好使还可以改成原来的方案
This commit is contained in:
parent
4f7496a240
commit
8b44975cb1
@ -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 = [];
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,4 +1,5 @@
|
|||||||
import { lodLayer, viewer } from '@/components/dt-scene/index.vue'
|
import { lodLayer, viewer } from '@/components/dt-scene/index.vue'
|
||||||
|
import OrthoImageryManager from './OrthoImageryManager'
|
||||||
import OrthoManager from './OrthoManager'
|
import OrthoManager from './OrthoManager'
|
||||||
// 新增空间态势统计
|
// 新增空间态势统计
|
||||||
|
|
||||||
@ -509,10 +510,15 @@ export default {
|
|||||||
// this.resourceClick(this.resourceList.data[0])
|
// this.resourceClick(this.resourceList.data[0])
|
||||||
this.handleSceneComplete()
|
this.handleSceneComplete()
|
||||||
this.getTaskList()
|
this.getTaskList()
|
||||||
orthoManager = new OrthoManager(
|
// orthoManager = new OrthoManager(
|
||||||
viewer,
|
// viewer,
|
||||||
DT.Cesium
|
// DT.Cesium
|
||||||
)
|
// )
|
||||||
|
orthoManager = new OrthoImageryManager(viewer, DT.Cesium, {
|
||||||
|
maxLayers: 400,
|
||||||
|
brightness: 1.2, // 默认亮度
|
||||||
|
alpha: 1.0 // 默认透明度
|
||||||
|
})
|
||||||
// this.startTest()
|
// this.startTest()
|
||||||
},
|
},
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user