北京经济技术开发区经开区虚拟城市项目-【前端】-Web
Jin Lei
2023-12-23 5df6240f6cd274e698d1e6358443364d543c126c
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
 
 
function createGrid(id) {
    let positions = signallingData.positions;
    let x = positions[id][0];
    let y = positions[id][1];
    let value = signallingData.values[signallingData.selectid][id];
    let color = signallingData.color.getColor(value);
    let entity = viewer.entities.add({
        id: "box_" + id,
        position: Cesium.Cartesian3.fromDegrees(x, y, value * 1.5),
        box: {
            dimensions: new Cesium.Cartesian3(100.0, 100.0, value * 3),
            outline: false,
            material: color,
        }
    });
    viewer.entities.add({
        id: "label_" + id,
        position: Cesium.Cartesian3.fromDegrees(x, y, value * 3),
        label: {
            text: value + "",
            verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
            font: "18px",
            distanceDisplayCondition: new Cesium.DistanceDisplayCondition(
                0, 10000
            ),
        },
 
    });
    return entity;
}
function createGridPanel(id) {
    let positions = signallingData.positions;
    let x = positions[id][0];
    let y = positions[id][1];
    let value = signallingData.values[signallingData.selectid][id];
    let color = signallingData.color.getColor(value);
    color.alpha = 0.3;
    let entity = signallingData.dataSource.entities.add({
        id: "box_" + id,
        position: Cesium.Cartesian3.fromDegrees(x, y, 0.1),
        box: {
            dimensions: new Cesium.Cartesian3(100.0, 100.0, 0),
            outline: true,
            outlineColor: Cesium.Color.WHITE,
            outlineWidth: 2,
            material: color,
        }
    });
    signallingData.dataSource.entities.add({
        id: "label_" + id,
        position: Cesium.Cartesian3.fromDegrees(x, y, 1),
        label: {
            text: value + "",
            verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
            font: "18px",
            distanceDisplayCondition: new Cesium.DistanceDisplayCondition(
                0, 10000
            ),
        },
 
    });
    return entity;
}
// new Cesium.CallbackProperty(function() {
//     let value = signallingData.values[signallingData.selectid][id];
//     let dim = new Cesium.Cartesian3(100.0, 100.0, value * 10);
//     return dim;
// }, false),
// new Cesium.CallbackProperty(function() {
//     let value = signallingData.values[signallingData.selectid][id];
//     let color = signallingData.color.getColor(value);
//     return color;
// }, false)
function dataGrid(type) {
    if (signallingData.dataSource == null) {
        signallingData.dataSource = new Cesium.CustomDataSource('signallingList');
 
        signallingData.color = new Color({
            max: 120,
            min: 0,
        });
        let positions = signallingData.positions;
        for (let i = 0; i < positions.length; i++) {
            if (type) {
                createGrid(i);
            } else {
                createGridPanel(i);
            }
        }
        viewer.dataSources.add(signallingData.dataSource);
    }
    return true;
}
function removeGrid() {
    try {
        viewer.dataSources.remove(signallingData.dataSource);
        signallingData.dataSource = null;
    } catch (e) { }
    return true;
}
function updateDataGrid(type) {
    let positions = signallingData.positions;
    for (let i = 0; i < positions.length; i++) {
        let x = positions[i][0];
        let y = positions[i][1];
        let value = signallingData.values[signallingData.selectid][i];
        let color = signallingData.color.getColor(value);
        let labelEntity = signallingData.dataSource.entities.getById("label_" + i);
        let boxEntity = signallingData.dataSource.entities.getById("box_" + i);
        labelEntity.label.text = value + "";
        if (type) {
            labelEntity.position.setValue(Cesium.Cartesian3.fromDegrees(x, y, value * 3));
            boxEntity.position.setValue(Cesium.Cartesian3.fromDegrees(x, y, value * 1.5));
 
            boxEntity.box.dimensions = new Cesium.Cartesian3(100.0, 100.0, value * 3);
        }
        boxEntity.box.material = color;
    }
    return true;
}