Commit 3a3d83c5 authored by xinzhedeai's avatar xinzhedeai

add:100米内测试

parent 7b2b66c8
...@@ -72,6 +72,12 @@ export default { ...@@ -72,6 +72,12 @@ export default {
trailEntities: {}, // 轨迹实体 trailEntities: {}, // 轨迹实体
isTracking: false, // 是否正在实时追踪 isTracking: false, // 是否正在实时追踪
currentTimeDisplay: "", // 当前显示时间 currentTimeDisplay: "", // 当前显示时间
// 添加轨迹相关配置
trajectoryConfig: {
pointCount: 10, // 每个人员的轨迹点数量
maxRange: 0.001, // 约100米范围(1度约等于111公里,0.001度约等于111米)
heightOffset: 5, // 轨迹点高度偏移
},
}; };
}, },
mounted() { mounted() {
...@@ -108,9 +114,9 @@ export default { ...@@ -108,9 +114,9 @@ export default {
const now = new Date(); const now = new Date();
const points = []; const points = [];
// 生成过去1小时的时间点,每5分钟一个 // 只生成10个时间点,用于显示10个轨迹点
for (let i = 60; i >= 0; i -= 5) { for (let i = 9; i >= 0; i--) {
const time = new Date(now.getTime() - i * 60 * 1000); const time = new Date(now.getTime() - i * 5 * 60 * 1000); // 每5分钟一个点
points.push(time); points.push(time);
} }
...@@ -137,21 +143,32 @@ export default { ...@@ -137,21 +143,32 @@ export default {
// 为每个人生成轨迹数据 // 为每个人生成轨迹数据
this.personnelList.forEach((person) => { this.personnelList.forEach((person) => {
const trajectories = []; const trajectories = [];
let currentLng = baseLongitude + (Math.random() - 0.5) * 0.0001;
let currentLat = baseLatitude + (Math.random() - 0.5) * 0.0001;
this.timePoints.forEach((time) => { // 为每个人生成一个随机的起始位置,在基准点附近
// 生成平滑的移动路径 const personBaseLng =
currentLng += (Math.random() - 0.5) * 0.00002; baseLongitude +
currentLat += (Math.random() - 0.5) * 0.00002; (Math.random() - 0.5) * this.trajectoryConfig.maxRange * 0.5;
const personBaseLat =
baseLatitude +
(Math.random() - 0.5) * this.trajectoryConfig.maxRange * 0.5;
// 生成10个轨迹点,形成一个合理的移动路径
for (let i = 0; i < this.trajectoryConfig.pointCount; i++) {
// 在人员基准位置附近生成轨迹点,确保在100米范围内
const lngOffset =
(Math.random() - 0.5) * this.trajectoryConfig.maxRange;
const latOffset =
(Math.random() - 0.5) * this.trajectoryConfig.maxRange;
trajectories.push({ trajectories.push({
time, time: this.timePoints[i],
lng: currentLng, lng: personBaseLng + lngOffset,
lat: currentLat, lat: personBaseLat + latOffset,
height: baseHeight, height:
baseHeight +
(Math.random() - 0.5) * this.trajectoryConfig.heightOffset,
}); });
}); }
this.personTrajectories[person.perName] = trajectories; this.personTrajectories[person.perName] = trajectories;
}); });
...@@ -306,53 +323,47 @@ export default { ...@@ -306,53 +323,47 @@ export default {
); );
}); });
// 创建轨迹线 // 创建轨迹线,使用更明显的样式
const trailEntity = this.viewer.entities.add({ const trailEntity = this.viewer.entities.add({
polyline: { polyline: {
positions: positions, positions: positions,
width: 3, width: 4,
material: new Cesium.PolylineGlowMaterialProperty({ material: new Cesium.PolylineGlowMaterialProperty({
glowPower: 0.5, glowPower: 0.6,
color: Cesium.Color.YELLOW, color: Cesium.Color.YELLOW,
}), }),
clampToGround: false, clampToGround: false,
// 确保轨迹线在倾斜摄影上显示
heightReference: Cesium.HeightReference.CLAMP_TO_3D_TILE,
}, },
}); });
this.trailEntities[this.selectedPerson] = trailEntity; this.trailEntities[this.selectedPerson] = trailEntity;
// 添加轨迹点标记 // 添加所有轨迹点标记,因为只有10个点
trajectories.forEach((point, index) => { trajectories.forEach((point, index) => {
// 只显示部分点,避免过多标记影响性能 const pointEntity = this.viewer.entities.add({
if ( position: Cesium.Cartesian3.fromDegrees(
index % Math.ceil(trajectories.length / 10) === 0 || point.lng,
index === trajectories.length - 1 point.lat,
) { point.height + 5
const pointEntity = this.viewer.entities.add({ ),
position: Cesium.Cartesian3.fromDegrees( point: {
point.lng, pixelSize: 6,
point.lat, color:
point.height + 5 index === trajectories.length - 1
), ? Cesium.Color.RED
point: { : Cesium.Color.GREEN,
pixelSize: 5, outlineColor: Cesium.Color.WHITE,
color: outlineWidth: 2,
index === trajectories.length - 1 // 确保点在倾斜摄影上显示
? Cesium.Color.RED heightReference: Cesium.HeightReference.CLAMP_TO_3D_TILE,
: Cesium.Color.GREEN, },
outlineColor: Cesium.Color.WHITE, description: `<div><p>时间: ${this.formatTime(point.time)}</p></div>`,
outlineWidth: 2, });
},
description: `<div><p>时间: ${this.formatTime(
point.time
)}</p></div>`,
});
if (!this.trailEntities[`${this.selectedPerson}_point_${index}`]) { this.trailEntities[`${this.selectedPerson}_point_${index}`] =
this.trailEntities[`${this.selectedPerson}_point_${index}`] = pointEntity;
pointEntity;
}
}
}); });
}, },
...@@ -398,7 +409,11 @@ export default { ...@@ -398,7 +409,11 @@ export default {
heightReference: Cesium.HeightReference.CLAMP_TO_3D_TILE, heightReference: Cesium.HeightReference.CLAMP_TO_3D_TILE,
}, },
description: `<div><h4>${item[idField]}${item.status}</h4></div>`, description: `<div><h4>${item[idField]}${item.status}</h4></div>`,
fixedFrame: Cesium.Transforms.eastNorthUpToFixedFrame(position), // 确保实体固定在正确位置
position: new Cesium.CallbackProperty(() => {
return Cesium.Cartesian3.fromDegrees(lng, lat, height);
}, false),
// 为了在3D Tiles上正确显示,不使用fixedFrame
}); });
entity.info = item; entity.info = item;
...@@ -573,28 +588,26 @@ export default { ...@@ -573,28 +588,26 @@ export default {
// 清除现有的人员列表 // 清除现有的人员列表
this.personnelList = []; this.personnelList = [];
// 生成10个不同的经纬度坐标 // 生成10个不同的经纬度坐标,范围在100米内
const maxOffset = 0.00005;
for (let index = 0; index < 10; index++) { for (let index = 0; index < 10; index++) {
// 生成随机偏移量 // 生成随机偏移量,确保在100米范围内
const lngOffset = (Math.random() - 0.5) * 2 * maxOffset; const lngOffset =
const latOffset = (Math.random() - 0.5) * 2 * maxOffset; (Math.random() - 0.5) * this.trajectoryConfig.maxRange;
const latOffset =
(Math.random() - 0.5) * this.trajectoryConfig.maxRange;
this.personnelList.push({ this.personnelList.push({
lng: baseLongitude + lngOffset, lng: baseLongitude + lngOffset,
lat: baseLatitude + latOffset, lat: baseLatitude + latOffset,
height: baseHeight, height: baseHeight,
perName: "张三" + index, perName: "人员" + (index + 1), // 修改名称格式
status: "online", // 在线 status: "online", // 在线
avatar: "/static/images/avatars/zhangsan.png", // 头像 avatar: "/static/images/avatars/zhangsan.png", // 头像
}); });
} }
// 初始化轨迹数据(如果尚未初始化) // 重新初始化轨迹数据
if (Object.keys(this.personTrajectories).length === 0) { this.initPersonTrajectories();
this.initPersonTrajectories();
}
fn(this.personnelList); fn(this.personnelList);
}, },
...@@ -731,6 +744,8 @@ export default { ...@@ -731,6 +744,8 @@ export default {
duration: 2, // 过渡时间2秒 duration: 2, // 过渡时间2秒
complete: () => { complete: () => {
console.log("相机已成功定位到模型上方"); console.log("相机已成功定位到模型上方");
// 先初始化时间点数据,再创建人员模型
this.initTimePoints();
this.createPersonModel(); // 定位后创建人员模型 this.createPersonModel(); // 定位后创建人员模型
}, },
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment