基于北京SDK的方案预演功能
surprise
2024-04-24 2891e19c690853fa6542502bcd230b6130e95810
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
const configTool = {
  time: 5,
  setMapFly(res) {
    var that = this;
 
    //设置初始视图位置
    Viewer.camera.flyTo({
      // fromDegrees()方法,将经纬度和高程转换为世界坐标
      destination: Cesium.Cartesian3.fromDegrees(res.lon, res.lat, res.alt),
      orientation: {
        // 方向
        heading: res.heading,
        // 视角
        pitch: res.pitch,
        // 倾斜角度
        roll: res.roll,
        // 设置飞行持续时间,默认会根据距离来计算
        duration: that.time,
      },
    });
  },
  getNewDateTime() {
    return new Date().getTime();
  },
  getViewerCamera() {
    var position = Viewer.scene.camera.positionCartographic;
    return {
      lon: Cesium.Math.toDegrees(position.longitude).toFixed(6),
      lat: Cesium.Math.toDegrees(position.latitude).toFixed(6),
      alt: position.height,
      heading: Viewer.scene.camera.heading,
      pitch: Viewer.scene.camera.pitch,
      roll: Viewer.scene.camera.roll,
    };
  },
  getTreeDataCheck(res, std) {
    for (var i in res) {
      if (res[i].children) {
        this.getTreeDataCheck(res[i].children, std);
      } else {
        if (res[i].checked) {
          std.push(res[i].id);
        }
      }
    }
    return std;
  },
};
export default configTool;