|
|
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;
|
}
|