From e7be05464134cb01ee3a9da428cada4758acd227 Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Sat, 27 Sep 2025 15:53:54 +0800
Subject: [PATCH] feat:地形加载方式调整
---
.env.development | 4 ++--
.env.localhost | 2 +-
src/utils/cesium/publicCesium.js | 28 ++++++++++++++++++++++++----
.env.production | 2 +-
.env.test | 2 +-
5 files changed, 29 insertions(+), 9 deletions(-)
diff --git a/.env.development b/.env.development
index c64f0f1..b574a32 100644
--- a/.env.development
+++ b/.env.development
@@ -2,7 +2,7 @@
# @Author : yuan
# @Date : 2025-07-29 15:59:42
# @LastEditors : yuan
- # @LastEditTime : 2025-07-29 16:15:31
+ # @LastEditTime : 2025-09-27 15:47:12
# @FilePath : \.env.development
# @Description :
# Copyright 2025 OBKoro1, All Rights Reserved.
@@ -37,7 +37,7 @@
VITE_APP_AIRLINE_URL = https://wrj.shuixiongit.com/minio/cloud-bucket
# 图片存放地址
-VITE_APP_TERRAIN_URL = https://wrj.shuixiongit.com/aiskyminio/cloud-bucket/ztzf_terrain/all_terrain
+VITE_APP_TERRAIN_URL = https://wrj.shuixiongit.com/aiskyminio/cloud-bucket/ztzf_terrain/
# 行政区划存放地址
VITE_APP_REGION_URL = https://wrj.shuixiongit.com/aiskyminio/cloud-bucket/ztzf_region
# 算法仓库图片地址
diff --git a/.env.localhost b/.env.localhost
index 851dc67..f6ae055 100644
--- a/.env.localhost
+++ b/.env.localhost
@@ -26,7 +26,7 @@
VITE_APP_AIRLINE_URL = http://192.168.1.227:80/minio/cloud-bucket
# 图片存放地址
-VITE_APP_TERRAIN_URL = https://wrj.shuixiongit.com/aiskyminio/cloud-bucket/ztzf_terrain/all_terrain
+VITE_APP_TERRAIN_URL = https://wrj.shuixiongit.com/aiskyminio/cloud-bucket/ztzf_terrain/
# 行政区划存放地址
VITE_APP_REGION_URL = https://wrj.shuixiongit.com/aiskyminio/cloud-bucket/ztzf_region
diff --git a/.env.production b/.env.production
index 06cd550..957311b 100644
--- a/.env.production
+++ b/.env.production
@@ -28,7 +28,7 @@
VITE_APP_AIRLINE_URL = https://wrj.shuixiongit.com/aiskyminio/cloud-bucket
# 图片存放地址
-VITE_APP_TERRAIN_URL = https://wrj.shuixiongit.com/aiskyminio/cloud-bucket/ztzf_terrain/all_terrain
+VITE_APP_TERRAIN_URL = https://wrj.shuixiongit.com/aiskyminio/cloud-bucket/ztzf_terrain/
# 算法仓库图片地址
VITE_APP_PICTURE_URL = https://wrj.shuixiongit.com/aiskyminio/cloud-bucket
diff --git a/.env.test b/.env.test
index 6f03bb3..cd7bf26 100644
--- a/.env.test
+++ b/.env.test
@@ -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/ztzf_terrain/all_terrain
+VITE_APP_TERRAIN_URL = https://wrj.shuixiongit.com/aiskyminio/cloud-bucket/ztzf_terrain/
# 算法仓库图片地址
VITE_APP_PICTURE_URL = https://wrj.shuixiongit.com/aiskyminio/cloud-bucket
diff --git a/src/utils/cesium/publicCesium.js b/src/utils/cesium/publicCesium.js
index 97b0f8a..7af504f 100644
--- a/src/utils/cesium/publicCesium.js
+++ b/src/utils/cesium/publicCesium.js
@@ -143,8 +143,28 @@
this.viewer?.cesiumWidget.screenSpaceEventHandler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK) // 禁用双击
if (terrain) {
+ // 正则:第一位非0,第二位任意数字,后10位都是0
+ const re = /^[1-9]\d0{10}$/
+
+ let result = null
+
+ // 1️⃣先判断 areaCode
+ if (re.test(store.state.user.userInfo.detail.areaCode)) {
+ result = store.state.user.userInfo.detail.areaCode.slice(0, 6)
+ } else {
+ // 2️⃣如果不满足,从 ancestors 里找
+ const matchedItems = store.state.user.userInfo.detail.ancestors
+ .split(',')
+ .filter(item => re.test(item)) // 过滤出符合条件的
+
+ // 取第一个符合条件的前6位(可以改成 last one 看需求)
+ if (matchedItems.length > 0) {
+ result = matchedItems[0].slice(0, 6)
+ }
+ }
+
try {
- Cesium.CesiumTerrainProvider.fromUrl(`${import.meta.env.VITE_APP_TERRAIN_URL}`, {
+ Cesium.CesiumTerrainProvider.fromUrl(`${import.meta.env.VITE_APP_TERRAIN_URL}${result}`, {
requestVertexNormals: true, // 启用地形法线增强立体感
requestWaterMask: true, // 启用水体遮罩效果
}).then(terrainProvider => {
@@ -209,7 +229,7 @@
async switchContour (open) {
if (open) {
await this.boundary?.openContour()
-
+
} else {
this.boundary?.closeContour()
}
@@ -752,7 +772,7 @@
Cesium.Cartesian3.subtract(a, this.viewer?.camera.position, a),
Cesium.Cartesian3.normalize(r, r),
Cesium.Cartesian3.normalize(a, a)) : (r = c.direction,
- a = h.direction)
+ a = h.direction)
let d = Cesium.Cartesian3.dot(r, a)
, p = 0
return d < 1 && (p = Math.acos(d)),
@@ -781,7 +801,7 @@
, r = Cesium.Math.acosClamped(-e)
a > 0 && a > r && (a = r - Cesium.Math.EPSILON4),
r = Cesium.Math.acosClamped(e),
- a < 0 && -a > r && (a = -r + Cesium.Math.EPSILON4)
+ a < 0 && -a > r && (a = -r + Cesium.Math.EPSILON4)
}
return a
}
--
Gitblit v1.9.3