重构风险点隐患点显示逻辑

This commit is contained in:
wzy-warehouse
2026-04-11 18:58:43 +08:00
parent e17a73537c
commit 824c980dbc
15 changed files with 320 additions and 79 deletions
+8 -10
View File
@@ -2,7 +2,6 @@ import type { Point } from "@/types/base/Point";
import type { PrimitiveOptions } from "@/types/cesium/PrimitiveOptions";
import { CesiumUtilsSingleton } from "@/utils/cesium/CesiumUtils";
import { Cartesian3, HorizontalOrigin, NearFarScalar, VerticalOrigin } from "cesium";
import config from '@/config/config.json'
/**
* 公共批量处理点钩子函数
@@ -14,9 +13,10 @@ export const usePointsHandle = () => {
* 添加点
* @param points - 点数据
* @param getDisasterIcon - 获取灾害图标的函数
* @param prefix - 前缀
* @returns 点的ID列表
*/
function addPoints(points: Point[], getDisasterIcon: (disasterType: string) => string): string[] {
function addPoints(points: Point[], getDisasterIcon: (disasterType?: string) => string, prefix: string): string[] {
// 设置加载配置
const options: PrimitiveOptions[] = [];
@@ -26,15 +26,14 @@ export const usePointsHandle = () => {
points.forEach(point => {
try {
if (point.lon === undefined || point.lat === undefined || point.disasterType === undefined) {
throw new Error(`点位数据缺少经纬度或者灾害类型:${point.id}`);
if (point.lon === undefined || point.lat === undefined) {
throw new Error(`点位数据缺少经纬度:${point.id}`);
}
// 将经纬度转换为笛卡尔坐标
const position = Cartesian3.fromDegrees(point.lon, point.lat, 0);
// 将经纬度转换为笛卡尔坐标,太高一点高度,方便点击
const position = Cartesian3.fromDegrees(point.lon, point.lat, 10);
const id = `${config.prefix.hiddenDangerPointId}${point.id}`
const id = `${prefix}${point.id}`
ids.push(id)
options.push({
id: id,
type: 'billboard',
@@ -51,10 +50,9 @@ export const usePointsHandle = () => {
},
});
} catch (error) {
throw new Error(`处理点位失败:${point.id}`);
throw new Error(`处理点位失败:${error}`);
}
})
// 批量创建图层
CesiumUtilsSingleton.addPrimitivesBatch(options);