From a2f1ea1771cffe31b720dbb2161186f28b7cb977 Mon Sep 17 00:00:00 2001
From: 张含笑 <zhx18749296735@163.com>
Date: Mon, 16 Jun 2025 20:04:22 +0800
Subject: [PATCH] feat:正射
---
.env.development | 2
src/utils/util.js | 10 ++
src/views/dataCenter/dataCenter.vue | 199 ++++++++++++++++++++++++++++-----------
src/utils/cesium/publicCesium.js | 22 ++++
src/views/dataCenter/components/dataCenterMap.vue | 12 -
.env.production | 2
6 files changed, 180 insertions(+), 67 deletions(-)
diff --git a/.env.development b/.env.development
index 1bc6759..7354a18 100644
--- a/.env.development
+++ b/.env.development
@@ -26,7 +26,7 @@
VITE_APP_AIRLINE_URL = https://wrj.shuixiongit.com/minio/cloud-bucket
# 图片存放地址
-VITE_APP_TERRAIN_URL = https://wrj.shuixiongit.com/aiskyminio/cloud-bucket
+VITE_APP_TERRAIN_URL = https://wrj.shuixiongit.com/aiskyminio/cloud-bucket/all_terrain
# 是否在打包时开启压缩,支持 gzip 和 brotli
VITE_BUILD_COMPRESS = gzip
diff --git a/.env.production b/.env.production
index 2b96d91..dfa8030 100644
--- a/.env.production
+++ b/.env.production
@@ -27,7 +27,7 @@
VITE_APP_AIRLINE_URL = https://wrj.shuixiongit.com/aiskyminio/cloud-bucket
# 图片存放地址
-VITE_APP_TERRAIN_URL = https://wrj.shuixiongit.com/aiskyminio/cloud-bucket
+VITE_APP_TERRAIN_URL = https://wrj.shuixiongit.com/aiskyminio/cloud-bucket/all_terrain
# 是否在打包时开启压缩,支持 gzip 和 brotli
VITE_BUILD_COMPRESS = gzip
diff --git a/src/utils/cesium/publicCesium.js b/src/utils/cesium/publicCesium.js
index 7692243..d511963 100644
--- a/src/utils/cesium/publicCesium.js
+++ b/src/utils/cesium/publicCesium.js
@@ -84,7 +84,7 @@
if (terrain) {
try {
- Cesium.CesiumTerrainProvider.fromUrl(`${import.meta.env.VITE_APP_TERRAIN_URL}/ztzf_terrain/all_terrain`, {
+ Cesium.CesiumTerrainProvider.fromUrl(`${import.meta.env.VITE_APP_TERRAIN_URL}/all_terrain`, {
requestVertexNormals: true, // 启用地形法线增强立体感
requestWaterMask: true, // 启用水体遮罩效果
}).then(terrainProvider => {
@@ -471,4 +471,24 @@
}
return a
}
+
+ // 添加entity
+ addCustomImageryProviderDataSource (imageryLayers) {
+ console.log(imageryLayers, this.viewer, '---1-')
+
+ return this.viewer?.imageryLayers.addImageryProvider(imageryLayers)
+ }
+
+ showCustomImageryProviderDataSource (imageryLayers, show) {
+ if (imageryLayers) {
+ imageryLayers.show = show
+ }
+ }
+
+
+ removeAllCustomImageryProviderDataSource (imageryLayers) {
+ if (imageryLayers) {
+ this.viewer?.imageryLayers.remove(imageryLayers)
+ }
+ }
}
diff --git a/src/utils/util.js b/src/utils/util.js
index acf5472..f2b2e09 100644
--- a/src/utils/util.js
+++ b/src/utils/util.js
@@ -130,6 +130,16 @@
return `${url.substring(0, lastDotIndex)}_small${url.substring(lastDotIndex)}`
}
/**
+ * 获取正射路径
+ * @param url
+ * @returns {string}
+ */
+export const getzsSmallImg = url => {
+ if (!url) return ''
+ const lastDotIndex = url.lastIndexOf('.')
+ return `${url.substring(0, lastDotIndex)}_small.jpeg`
+}
+/**
* 浏览器判断是否全屏
*/
export const fullscreenEnable = () => {
diff --git a/src/views/dataCenter/components/dataCenterMap.vue b/src/views/dataCenter/components/dataCenterMap.vue
index 5bb09ed..11d87c6 100644
--- a/src/views/dataCenter/components/dataCenterMap.vue
+++ b/src/views/dataCenter/components/dataCenterMap.vue
@@ -89,9 +89,8 @@
const restoreAllIcons = () => {
dataPointEntities.value.forEach(entity => {
if (entity.billboard) {
- const status = entity?.properties?._customData?._value?.data.status
entity.billboard.image =
- status === 1 ? defaultIcon : getEventImage(item.status);
+ props.dotData.resultType === 2 ? getEventImage(entity.status) : defaultIcon;
}
});
activeEntity.value = null;
@@ -111,10 +110,8 @@
// 恢复所有点的默认图标
restoreAllIcons();
if (currentClickEntity.billboard) {
- const status = currentClickEntity?.properties?._customData?._value?.data.status
- console.log('stayus',status);
currentClickEntity.billboard.image =
- status === 1 ?activeIcon : getEventActiveImage(status);
+ props.dotData.resultType === 2 ? getEventImage(currentClickEntity.status) : activeIcon;
currentClickEntity.billboard.scale = 1; // 可选缩放效果
activeEntity.value = currentClickEntity;
}
@@ -171,7 +168,7 @@
pixelOffset: new Cesium.Cartesian2(0, 55),
},
billboard: {
- image: item.status === 1 ?defaultIcon : getEventImage(item.status), // 初始为默认图标
+ image: props.dotData.resultType === 2 ? getEventImage(item.status) : defaultIcon, // 初始为默认图标
width: 40,
height: 40,
pixelOffset: new Cesium.Cartesian2(0, -15),
@@ -255,14 +252,11 @@
}
};
const isViewerReady = ref(false);
-
/**
* 初始化标注添加
* @param data 数据
*/
const initEntityOrPopup = data => {
-console.log('data',data);
-
//地图点在范围内
watch(
() => isMapInitialized.value,
diff --git a/src/views/dataCenter/dataCenter.vue b/src/views/dataCenter/dataCenter.vue
index ece9562..50543cd 100644
--- a/src/views/dataCenter/dataCenter.vue
+++ b/src/views/dataCenter/dataCenter.vue
@@ -45,6 +45,13 @@
class="imageBox"
@click="enterFullScreen(scope.row)"
/>
+ <!-- 正射 -->
+ <img
+ v-else-if="scope.row?.resultType === 4"
+ :src="getzsSmallImg(scope.row?.link)"
+ alt=""
+ class="imageBox"
+ />
<el-image
v-else
:src="scope.row?.smallUrl"
@@ -71,10 +78,11 @@
<span class="delete" @click="deleteDetail(scope.row)" v-if="scope.row.resultType !== 2"
>删除</span
>
+ <!-- && !isTifFile(scope.row.nickName) -->
<span
class="location"
@click="positionDetail(scope.row)"
- v-if="scope.row.resultType !== 1 && !isTifFile(scope.row.nickName)"
+ v-if="scope.row.resultType !== 1"
>定位</span
>
</template>
@@ -109,6 +117,12 @@
alt=""
class="imageBox"
/>
+ <!-- 地图 -->
+ <div
+ v-if="dialogDetailList?.resultType === 4"
+ id="detaildataCenterMap"
+ class="ztzf-cesium"
+ ></div>
<img v-else :src="getSmallImg(dialogDetailList?.link)" alt="" />
</div>
<div class="rightDetail">
@@ -147,7 +161,7 @@
<div>拍摄时间:{{ dialogDetailList?.createTime }}</div>
<div>文件类型:{{ photoTypeMap[dialogDetailList?.photoType] }}</div>
<div>文件格式:{{ resultTypeMap[dialogDetailList?.resultType] }}</div>
- <div>照片文件大小:{{bytesToMB(dialogDetailList?.attachSize) }}</div>
+ <div>照片文件大小:{{ bytesToMB(dialogDetailList?.attachSize) }}</div>
<div>
<el-button
type="success"
@@ -199,6 +213,22 @@
</template>
<script setup>
+import { useStore } from 'vuex';
+import { PublicCesium } from '@/utils/cesium/publicCesium';
+import { Cartesian3 } from 'cesium';
+import * as Cesium from 'cesium';
+import EventPopUpBox from '@/hooks/components/EventPopUpBox.vue';
+import { render } from 'vue';
+import defaultIcon from '@/assets/images/dataCenter/datamap/eventCompleted.png';
+const isShow = defineModel('show');
+const viewerRef = shallowRef(null);
+let viewer = null;
+
+const viewInstance = shallowRef(null);
+const store = useStore();
+const currentAreaPosition = ref({ height: 1987280, latitude: 27.636112, longitude: 115.732975 });
+let handler = null;
+
import EventBus from '@/utils/eventBus';
import dataCenterMap from '@/views/dataCenter/components/dataCenterMap.vue';
import PanoramaPopup from '@/components/PanoramaPopup/PanoramaPopup.vue'; //全景
@@ -212,9 +242,9 @@
deleteFileMultipleApi,
downloadApi,
updataTitleApi,
- getOrthoimageInfo
+ getOrthoimageInfo,
} from '@/api/dataCenter/dataCenter';
-import { getShowImg, getSmallImg } from '@/utils/util';
+import { getShowImg, getSmallImg, getzsSmallImg } from '@/utils/util';
import { onMounted, watch } from 'vue';
import dayjs from 'dayjs';
function bytesToMB(bytes, decimalPlaces = 2) {
@@ -389,49 +419,33 @@
};
// 全部下载
const aLLDownloadFile = () => {
- loading = ElLoading.service({ background: 'rgba(0, 0, 0, 0.5)', text: '打包中,请稍等...' });
+ loading = ElLoading.service({ background: 'rgba(0, 0, 0, 0.5)', text: '打包中,请稍等...' });
const params = {
...jobListParams.searchParams,
};
downloadApi(params).then(res => {
aLinkDownload(res.data.data, `sjzx-file-pack-${dayjs().format('YYYYMMDDHHmmss')}.zip`);
- loading.close();
+ loading.close();
});
};
-// 查看弹框
-
-
-function isTifFile(filename) {
- const lastDot = filename.lastIndexOf('.');
- if (lastDot === -1) return false; // 无后缀
- return filename.slice(lastDot + 1).toLowerCase() === 'tif';
-}
-// 接口
-const getOrthoimageInfoFUN =()=>{
-
-}
-
-const dialogVisible = ref(false);
-const dialogDetailList = ref(null);
-const detailTitle = ref('');
-const lookDetail = val => {
-console.log('查看',val.resultType);
-// if(val.resultType === 4){ // 正射
-// getOrthoimageInfo(val.id).then(res=>{
-// console.log('正射',res.data.data);
-// dialogDetailList.value = res.data.data;
-// })
-// }else{
- getAttachInfoAPI(val.id).then(res => {
- detailTitle.value = res.data.data.nickName;
- dialogDetailList.value = res.data.data;
- dialogDetailList.value = { ...res.data.data, checkedinput: false };
- // console.log('detailTitle.value',dialogDetailList.value);
+// 地图弹框
+const mapComponent = ref(null); // 创建子组件引用
+const mapList = ref(null);
+const dataCenterMapVisible = ref(false);
+const jobId = ref('');
+const statusType = ref(null);
+const positionDetail = val => {
+ jobId.value = val.wayLineJobId;
+ mapList.value = val;
+ dataCenterMapVisible.value = true;
+ // 确保地图组件加载完成
+ nextTick(() => {
+ if (mapComponent.value) {
+ // 调用子组件方法并传递数据
+ mapComponent.value.initEntityOrPopup(val);
+ }
});
-// }
-
- dialogVisible.value = true;
};
const fileNameedit = ref('');
@@ -484,24 +498,93 @@
});
};
-// 地图弹框
-const mapComponent = ref(null); // 创建子组件引用
-const mapList = ref(null);
-const dataCenterMapVisible = ref(false);
-const jobId = ref('');
-const statusType = ref(null);
-const positionDetail = val => {
- jobId.value = val.wayLineJobId;
- mapList.value = val;
- dataCenterMapVisible.value = true;
- // 确保地图组件加载完成
- nextTick(() => {
- if (mapComponent.value) {
- // 调用子组件方法并传递数据
- mapComponent.value.initEntityOrPopup(val);
- }
- });
+// 查看弹框
+function isTifFile(filename) {
+ const lastDot = filename.lastIndexOf('.');
+ if (lastDot === -1) return false; // 无后缀
+ return filename.slice(lastDot + 1).toLowerCase() === 'tif';
+}
+const dialogVisible = ref(false);
+const dialogDetailList = ref(null);
+const detailTitle = ref('');
+let curCustomImageryProvider = null;
+const lookDetail = val => {
+ console.log('查看', val);
+ if (val.resultType === 4) {
+ // 正射
+ getOrthoimageInfo(val.wayLineJobId).then(res => {
+ console.log('正射', res.data.data);
+ detailTitle.value = val.nickName;
+ dialogDetailList.value = val;
+ if (res.data.data != null && isMapInitialized.value === true) {
+ console.log('viewer', viewer);
+
+ curCustomImageryProvider = viewInstance.value.addCustomImageryProviderDataSource(
+ new Cesium.UrlTemplateImageryProvider({
+ url: `${import.meta.env.VITE_APP_AREA_NAME}/webodm${res.data.data.orthoimageApi}?jwt=${
+ res.data.data.odmToken.split(' ')[1]
+ }`,
+
+ })
+ );
+
+ yxShowBox.value = true;
+ }
+ dialogVisible.value = true;
+ });
+ } else {
+ getAttachInfoAPI(val.id).then(res => {
+ detailTitle.value = res.data.data.nickName;
+ dialogDetailList.value = res.data.data;
+ dialogDetailList.value = { ...res.data.data, checkedinput: false };
+ // console.log('detailTitle.value',dialogDetailList.value);
+ dialogVisible.value = true;
+ });
+ }
};
+
+// 正射地图
+const yxShowBox = ref(false);
+
+const removeHandler = () => {
+ handler?.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK);
+ handler?.destroy();
+ handler = null;
+};
+const isMapInitialized = ref(false); //地图加载
+const initMap = () => {
+ if (viewer || isMapInitialized.value) return;
+
+ const container = document.getElementById('detaildataCenterMap');
+ if (!container) {
+ console.error('地图容器未找到');
+ return;
+ }
+ viewInstance.value = new PublicCesium({
+ dom: 'detaildataCenterMap',
+ flatMode: false,
+ terrain: false,
+ mapFilter: true,
+ });
+ viewer = viewInstance.value.getViewer();
+ viewerRef.value = viewer;
+ isMapInitialized.value = true;
+ console.log('地图初始化完成');
+};
+// 监听对话框状态
+watch(dialogVisible, newVal => {
+ if (newVal) {
+ nextTick(() => {
+ initMap();
+ });
+ } else {
+ // 对话框关闭时清理资源
+ viewInstance.value?.viewerDestroy();
+ viewer = null;
+ isMapInitialized.value = false;
+ // removeHandler();
+ }
+});
onMounted(() => {
getaiImagesPage();
@@ -514,6 +597,8 @@
onBeforeUnmount(() => {
// 组件卸载时移除事件监听,防止内存泄漏
EventBus.off('open-panorama');
+ viewInstance.value.removeAllCustomImageryProviderDataSource(curCustomImageryProvider);
+ viewInstance.value?.viewerDestroy();
});
</script>
@@ -582,6 +667,10 @@
width: 100%;
height: 100%;
}
+ #detaildataCenterMap {
+ width: 100%;
+ height: 100%;
+ }
}
.rightDetail {
width: 30%;
--
Gitblit v1.9.3