2024-02-14 12:42:23 +00:00
|
|
|
function event_radar() {
|
|
|
|
|
2024-02-27 01:49:10 +00:00
|
|
|
var radar_url = window.location.origin +
|
|
|
|
'/api' + window.location.search;
|
2024-02-25 13:08:26 +00:00
|
|
|
|
|
|
|
fetch(radar_url)
|
|
|
|
.then(response => {
|
|
|
|
if (!response.ok) {
|
|
|
|
throw new Error('Network response was not ok');
|
|
|
|
}
|
|
|
|
return response.json();
|
|
|
|
})
|
|
|
|
.then(data => {
|
2024-03-04 11:10:50 +00:00
|
|
|
|
|
|
|
if (!data["detections_localised"]) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
removeEntitiesOlderThanAndFade("detection", 10, 0.5);
|
|
|
|
|
2024-02-27 01:49:10 +00:00
|
|
|
for (const key in data["detections_localised"]) {
|
|
|
|
if (data["detections_localised"].hasOwnProperty(key)) {
|
|
|
|
const target = data["detections_localised"][key];
|
|
|
|
const points = target["points"];
|
2024-02-27 02:41:18 +00:00
|
|
|
|
|
|
|
for (const point in points) {
|
2024-02-29 15:28:03 +00:00
|
|
|
addPoint(
|
|
|
|
points[point][0],
|
|
|
|
points[point][1],
|
|
|
|
points[point][2],
|
2024-03-03 06:47:38 +00:00
|
|
|
"detection",
|
2024-02-29 15:28:03 +00:00
|
|
|
style_point.color,
|
|
|
|
style_point.pointSize,
|
|
|
|
style_point.type,
|
|
|
|
Date.now()
|
|
|
|
);
|
2024-02-27 02:41:18 +00:00
|
|
|
}
|
2024-02-27 01:49:10 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2024-02-25 13:08:26 +00:00
|
|
|
})
|
|
|
|
.catch(error => {
|
|
|
|
// Handle errors during fetch
|
|
|
|
console.error('Error during fetch:', error);
|
|
|
|
})
|
|
|
|
.finally(() => {
|
|
|
|
// Schedule the next fetch after a delay (e.g., 5 seconds)
|
|
|
|
setTimeout(event_radar, 1000);
|
|
|
|
});
|
|
|
|
|
2024-02-29 15:28:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var style_point = {};
|
2024-03-03 06:47:38 +00:00
|
|
|
style_point.color = 'rgba(0, 255, 0, 1.0)';
|
|
|
|
style_point.pointSize = 16;
|
|
|
|
style_point.type = "detection";
|
2024-02-29 15:28:03 +00:00
|
|
|
style_point.timestamp = Date.now();
|