历史轨迹增加计算移动速度逻辑

pull/3/head
fangjiakai 2024-02-28 08:41:42 +08:00
parent 5122d11abb
commit e92fd99252
7 changed files with 52 additions and 27 deletions

View File

@ -697,7 +697,9 @@ var CustomCesium;
l = new S.Tween({x: a._value.x, y: a._value.y, z: a._value.z}); l = new S.Tween({x: a._value.x, y: a._value.y, z: a._value.z});
l.to({x: o.x, y: o.y, z: o.z}, n), l.onUpdate((({x: e, y: t, z: i}) => { l.to({x: o.x, y: o.y, z: o.z}, n), l.onUpdate((({x: e, y: t, z: i}) => {
let n = new Cesium.Cartesian3(e, t, i); let n = new Cesium.Cartesian3(e, t, i);
this.entity.position = n; if(this.entity){
this.entity.position = n;
}
let a = r.Cartesian3ToWGS84(this.icy.viewer, n); let a = r.Cartesian3ToWGS84(this.icy.viewer, n);
s(a) s(a)
})), l.start() })), l.start()
@ -1387,7 +1389,9 @@ var CustomCesium;
a = new S.Tween({x: n._value.x, y: n._value.y, z: n._value.z}); a = new S.Tween({x: n._value.x, y: n._value.y, z: n._value.z});
a.to({x: s.x, y: s.y, z: s.z}, r), a.onUpdate((({x: e, y: t, z: i}) => { a.to({x: s.x, y: s.y, z: s.z}, r), a.onUpdate((({x: e, y: t, z: i}) => {
let r = new Cesium.Cartesian3(e, t, i); let r = new Cesium.Cartesian3(e, t, i);
this.entity.position = r if(this.entity){
this.entity.position = r;
}
})), a.start() })), a.start()
} }

View File

@ -129,7 +129,8 @@ const {
currentData[0], currentData[0],
currentData[1] currentData[1]
) )
: undefined : undefined,
1000 / data.speed
); );
}, },
}); });
@ -156,10 +157,10 @@ const fnGetData = async () => {
ElMessage.warning("请选择时间"); ElMessage.warning("请选择时间");
return; return;
} }
hadleDestroy();
data.positions = []; data.positions = [];
pause(); pause();
reset(); reset();
hadleDestroy();
await getTrajectoriesData( await getTrajectoriesData(
data.searchForm.personnel, data.searchForm.personnel,
data.searchForm.dates[0], data.searchForm.dates[0],
@ -210,6 +211,7 @@ const fnPause = () => {
onBeforeUnmount(() => { onBeforeUnmount(() => {
console.log("onBeforeUnmount"); console.log("onBeforeUnmount");
pause();
hadleDestroy(); hadleDestroy();
}); });
</script> </script>

View File

@ -16,7 +16,7 @@
</template> </template>
<script setup> <script setup>
import { reactive } from "vue"; import { reactive } from "vue";
import { reduction } from "../js/map"; import { flyTo, reduction } from "../js/map";
import { useFullscreen } from "@vueuse/core"; import { useFullscreen } from "@vueuse/core";
const { isFullscreen, toggle } = useFullscreen(); const { isFullscreen, toggle } = useFullscreen();
@ -44,6 +44,7 @@ const data = reactive({
.href, .href,
check: false, check: false,
label: "返回中心点", label: "返回中心点",
action: flyTo,
}, },
{ {
img: new URL("/src/assets/images/map/rico3.png", import.meta.url).href, img: new URL("/src/assets/images/map/rico3.png", import.meta.url).href,

View File

@ -100,16 +100,16 @@ export const showLine = (positions) => {
* entityArr 接收人物模型分组 * entityArr 接收人物模型分组
* billboardArr 接收人物铭牌分组 * billboardArr 接收人物铭牌分组
*/ */
export const peoMovement = (id, lon, lat, height, alt) => { export const peoMovement = (id, lon, lat, height, alt,speed) => {
entityArr.children.forEach((b, m) => { entityArr.children.forEach((b, m) => {
if (b.entity._id === id) { if (b.entity._id === id) {
b.updateAngle([alt, 0, 0]); // 改变人物朝向 b.updateAngle([alt, 0, 0]); // 改变人物朝向
b.animationMove(lon, lat, height, 1000, () => {}); // 人物平滑移动 b.animationMove(lon, lat, height, speed, () => {}); // 人物平滑移动
billboardArr.children[m].animationMove( billboardArr.children[m].animationMove(
lon, lon,
lat, lat,
Number(Number(height) + 2.05), Number(Number(height) + 2.05),
1000 speed
); // 人物铭牌平滑移动 ); // 人物铭牌平滑移动
} else { } else {
console.log(`人物移动数据错误`); console.log(`人物移动数据错误`);

View File

@ -18,6 +18,8 @@ import { getVideoManagerView } from "@/request/video_manager.js";
const loadMap = 3; const loadMap = 3;
let $entityTransparent = []; let $entityTransparent = [];
const clickModel = new Map(); const clickModel = new Map();
let centerLon = 0;
let centerLat = 0;
export const initMap = (corp) => { export const initMap = (corp) => {
window.$scene = new window.CustomCesium.Scene( window.$scene = new window.CustomCesium.Scene(
"map", "map",
@ -36,7 +38,9 @@ export const initMap = (corp) => {
), ),
}); });
const [wgsLat, wgsLon] = bd09ToWgs84(corp.LATITUDE, corp.LONGITUDE); const [wgsLat, wgsLon] = bd09ToWgs84(corp.LATITUDE, corp.LONGITUDE);
flyTo(wgsLon, wgsLat); centerLon = wgsLon;
centerLat = wgsLat;
flyTo();
// 亮度设置 // 亮度设置
const stages = window.$icy.viewer.scene.postProcessStages; const stages = window.$icy.viewer.scene.postProcessStages;
window.$icy.viewer.scene.brightness = window.$icy.viewer.scene.brightness =
@ -127,13 +131,12 @@ const transformlng = (lng, lat) => {
return ret; return ret;
}; };
// eslint-disable-next-line no-unused-vars export const flyTo = () => {
const flyTo = (lng, lat) => {
window.$carmer.flyTo({ window.$carmer.flyTo({
// 视角飞入 // 视角飞入
maxHeight: 1500, maxHeight: 1500,
time: 1, time: 1,
position: [lng, lat, 200], position: [centerLon, centerLat, 200],
angle: [0, -60, 0], angle: [0, -60, 0],
}); });
}; };

View File

@ -25,6 +25,11 @@ const { open, close } = useWebSocket(
const msg = unzip(event.data); const msg = unzip(event.data);
const decodedMsg = JSON.parse(decodeURIComponent(msg)); const decodedMsg = JSON.parse(decodeURIComponent(msg));
if (decodedMsg.msg === "000") { if (decodedMsg.msg === "000") {
console.log(decodedMsg.data);
// decodedMsg.data = [
// "8379,119.447708695738,39.918422294137,-232.39015608699566,0.12000000000000001,,1,0,大大",
// "9979,119.447611105937,39.918443403627,-343.76932562302534,0.12000000000000001,9979,1,0,测试一",
// ];
peoMovement(decodedMsg.data); peoMovement(decodedMsg.data);
} }
if (decodedMsg.msg === "006") { if (decodedMsg.msg === "006") {
@ -32,7 +37,7 @@ const { open, close } = useWebSocket(
} }
}, },
onDisconnected: () => { onDisconnected: () => {
if (entityArr) { if (entityArr && entityArr.children) {
entityArr.children.forEach((e) => { entityArr.children.forEach((e) => {
e.destroy(); e.destroy();
}); });
@ -159,25 +164,32 @@ const unzip = (b64Data) => {
function peoMovement(moveData) { function peoMovement(moveData) {
const map = new Map(); const map = new Map();
moveData.forEach((i, n) => { moveData.forEach((i, n) => {
let addFlag = false;
map.set(i.split(",")[0], n); map.set(i.split(",")[0], n);
if (!entityArr || !entityArr.children) { if (!entityArr || !entityArr.children) {
addFlag = true;
entityArr = new window.CustomCesium.GroupModel("人物模型"); entityArr = new window.CustomCesium.GroupModel("人物模型");
billboardArr = new window.CustomCesium.GroupModel("人物姓名"); billboardArr = new window.CustomCesium.GroupModel("人物姓名");
const entity = i.split(","); const entity = i.split(",");
console.log(entity[0], 111111);
addEntity(entity[0], entity[8], entity[1], entity[2], entity[4]); addEntity(entity[0], entity[8], entity[1], entity[2], entity[4]);
addBillboard(entity[0], entity[8], entity[1], entity[2], entity[4]); addBillboard(entity[0], entity[8], entity[1], entity[2], entity[4]);
} }
entityArr.children.forEach((b, m) => { entityArr.children.forEach((b, m) => {
if (!b.entity) { if (!b.entity) {
addFlag = true;
const entity = i.split(","); const entity = i.split(",");
console.log(entity[0], 2222222);
addEntity(entity[0], entity[8], entity[1], entity[2], entity[4]); addEntity(entity[0], entity[8], entity[1], entity[2], entity[4]);
addBillboard(entity[0], entity[8], entity[1], entity[2], entity[4]); addBillboard(entity[0], entity[8], entity[1], entity[2], entity[4]);
return; return;
} }
const index = map.get(b.entity._id); const index = map.get(b.entity._id);
const item = moveData[index]; const item = moveData[index];
if (index !== undefined) { const entity = i.split(",");
if (index !== undefined && entity[0] === b.entity._id) {
addFlag = true;
const itData = item.split(","); // itData下标0=【卡号】1,24=【lonlatalt】3=【人物朝向角度】5=【工号】6=【当前楼层】 const itData = item.split(","); // itData下标0=【卡号】1,24=【lonlatalt】3=【人物朝向角度】5=【工号】6=【当前楼层】
if (itData[4] != null && itData.length >= 6) { if (itData[4] != null && itData.length >= 6) {
b.updateAngle([itData[3], 0, 0]); // 改变人物朝向 b.updateAngle([itData[3], 0, 0]); // 改变人物朝向
@ -185,24 +197,27 @@ function peoMovement(moveData) {
itData[1], itData[1],
itData[2], itData[2],
Number(itData[4]), Number(itData[4]),
2000, 1000,
() => {} () => {}
); // 人物平滑移动 ); // 人物平滑移动
billboardArr.children[m].animationMove( billboardArr.children[m].animationMove(
itData[1], itData[1],
itData[2], itData[2],
Number(Number(itData[4]) + 2.05), Number(Number(itData[4]) + 2.05),
2000 1000
); // 人物铭牌平滑移动 ); // 人物铭牌平滑移动
} else { } else {
console.log(`人物移动数据错误,错误参数:'${item}'`); console.log(`人物移动数据错误,错误参数:'${item}'`);
} }
} else {
const entity = i.split(",");
addEntity(entity[0], entity[8], entity[1], entity[2], entity[4]);
addBillboard(entity[0], entity[8], entity[1], entity[2], entity[4]);
} }
}); });
if (!addFlag) {
const entity = i.split(",");
console.log(entity[0], 333333);
addEntity(entity[0], entity[8], entity[1], entity[2], entity[4]);
addBillboard(entity[0], entity[8], entity[1], entity[2], entity[4]);
}
}); });
} }

View File

@ -234,13 +234,13 @@
<el-radio v-model="data.form.FOURTYPE" :label="1"> <el-radio v-model="data.form.FOURTYPE" :label="1">
平面四色图 平面四色图
</el-radio> </el-radio>
<el-radio <!-- <el-radio-->
v-model="data.form.FOURTYPE" <!-- v-model="data.form.FOURTYPE"-->
:label="2" <!-- :label="2"-->
@change="fnProhibitSelect" <!-- @change="fnProhibitSelect"-->
> <!-- >-->
3D图 <!-- 3D图-->
</el-radio> <!-- </el-radio>-->
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col v-if="data.form.FOURTYPE === 1" :span="24"> <el-col v-if="data.form.FOURTYPE === 1" :span="24">