mirror of
https://github.com/30hours/3lips.git
synced 2024-11-18 12:33:58 +00:00
Don't duplicate radar names for entity
This commit is contained in:
parent
d933ffecb5
commit
33ceedf6dc
1 changed files with 37 additions and 22 deletions
|
@ -149,6 +149,7 @@ var viewer = new Cesium.Viewer("cesiumContainer", {
|
||||||
|
|
||||||
// Create a point entity
|
// Create a point entity
|
||||||
const pointEntity = viewer.entities.add({
|
const pointEntity = viewer.entities.add({
|
||||||
|
name: pointName,
|
||||||
position,
|
position,
|
||||||
point: {
|
point: {
|
||||||
color: Cesium.Color.fromCssColorString(pointColor),
|
color: Cesium.Color.fromCssColorString(pointColor),
|
||||||
|
@ -187,7 +188,6 @@ window.addEventListener('load', function () {
|
||||||
style_radar.type = "radar";
|
style_radar.type = "radar";
|
||||||
style_radar.timestamp = Date.now();
|
style_radar.timestamp = Date.now();
|
||||||
radar_config_url.forEach(url => {
|
radar_config_url.forEach(url => {
|
||||||
console.log(url);
|
|
||||||
fetch(url)
|
fetch(url)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
|
@ -197,27 +197,30 @@ window.addEventListener('load', function () {
|
||||||
})
|
})
|
||||||
.then(data => {
|
.then(data => {
|
||||||
// add radar rx and tx
|
// add radar rx and tx
|
||||||
// todo: check not duplicating points
|
if (!doesEntityNameExist(data.location.rx.name)) {
|
||||||
addPoint(
|
addPoint(
|
||||||
data.location.rx.latitude,
|
data.location.rx.latitude,
|
||||||
data.location.rx.longitude,
|
data.location.rx.longitude,
|
||||||
data.location.rx.altitude,
|
data.location.rx.altitude,
|
||||||
data.location.rx.name,
|
data.location.rx.name,
|
||||||
style_radar.color,
|
style_radar.color,
|
||||||
style_radar.pointSize,
|
style_radar.pointSize,
|
||||||
style_radar.type,
|
style_radar.type,
|
||||||
style_radar.timestamp
|
style_radar.timestamp
|
||||||
);
|
);
|
||||||
addPoint(
|
}
|
||||||
data.location.tx.latitude,
|
if (!doesEntityNameExist(data.location.tx.name)) {
|
||||||
data.location.tx.longitude,
|
addPoint(
|
||||||
data.location.tx.altitude,
|
data.location.tx.latitude,
|
||||||
data.location.tx.name,
|
data.location.tx.longitude,
|
||||||
style_radar.color,
|
data.location.tx.altitude,
|
||||||
style_radar.pointSize,
|
data.location.tx.name,
|
||||||
style_radar.type,
|
style_radar.color,
|
||||||
style_radar.timestamp
|
style_radar.pointSize,
|
||||||
);
|
style_radar.type,
|
||||||
|
style_radar.timestamp
|
||||||
|
);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
// Handle errors during fetch
|
// Handle errors during fetch
|
||||||
|
@ -240,4 +243,16 @@ function event_loop() {
|
||||||
|
|
||||||
setTimeout(event_loop, 1000);
|
setTimeout(event_loop, 1000);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function doesEntityNameExist(name) {
|
||||||
|
|
||||||
|
// loop over all entities in the viewer
|
||||||
|
viewer.entities.values.forEach((entity) => {
|
||||||
|
if (entity.name === name) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
Loading…
Reference in a new issue