Commit e588e750 by zhangxw

轨迹回放速度 代码优化

1 parent 8492947a
......@@ -277,27 +277,36 @@ const replay = {
//mapService.setFitView(MAP);
},
speedEvent(idx, dis) {
let timeArr = [[40, 30, 16], [30, 20, 12], [20, 12, 8], [5, 3, 2]] // 慢 正常 快 很快
let speed
if (dis >= 100) { // 100公里以上
speed = Math.floor((dis / timeArr[idx][0]) * 3600)
} else if (dis > 10 && dis < 100) { // 10-100公里
speed = Math.floor((dis / timeArr[idx][1]) * 3600)
} else { // 10公里以内
speed = Math.floor((dis / timeArr[idx][2]) * 3600)
}
return speed
},
getSpeed(idx, dis){ // 根据路径距离和回放时间 算出回放的speed
let speed;
switch(idx){
case 1:
// let speed;
// switch(idx){
// case 1:
// speed = 2000
speed = dis >= 100 ? Math.floor((dis / 30) * 3600) : dis > 10 && dis < 100 ? Math.floor((dis / 20) * 3600) : Math.floor((dis / 12) * 3600);
break;
case 2:
// break;
// case 2:
// speed = 5000;
speed = dis >= 100 ? Math.floor((dis / 20) * 3600) : dis > 10 && dis < 100 ? Math.floor((dis / 12) * 3600) : Math.floor((dis / 8) * 3600);
break;
case 3:
// break;
// case 3:
// speed = 10000;
speed = dis >= 100 ? Math.floor((dis / 5) * 3600) : dis > 10 && dis < 100 ? Math.floor((dis / 3) * 3600) : Math.floor((dis / 2) * 3600);
break;
default:
// break;
// default:
// speed = 500;
speed = dis >= 100 ? Math.floor((dis / 40) * 3600) : dis > 10 && dis < 100 ? Math.floor((dis / 30) * 3600) : Math.floor((dis / 16) * 3600);
break;
}
return speed;
// break;
// }
// return speed;
return this.speedEvent(idx, dis)
},
clearTimeoutIds(){
replay.timeoutIds.forEach((item)=>{
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!