Target pos still in wrong place

This commit is contained in:
30hours 2024-03-03 08:29:02 +00:00
parent 561baf5a35
commit 0b4a6a9695
5 changed files with 90 additions and 27 deletions

View file

@ -0,0 +1,52 @@
function event_ellipsoid() {
var radar_url = window.location.origin +
'/api' + window.location.search;
fetch(radar_url)
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then(data => {
for (const key in data["ellipsoids"]) {
if (data["ellipsoids"].hasOwnProperty(key)) {
const points = data["ellipsoids"][key];
console.log(points);
removeEntitiesOlderThanAndFade("ellipsoids", 30, 0.5);
for (const point in points) {
addPoint(
points[point][0],
points[point][1],
points[point][2],
"ellipsoids",
style_ellipsoid.color,
style_ellipsoid.pointSize,
style_ellipsoid.type,
Date.now()
);
}
}
}
})
.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);
});
}
var style_ellipsoid = {};
style_ellipsoid.color = 'rgba(0, 0, 255, 1.0)';
style_ellipsoid.pointSize = 16;
style_ellipsoid.type = "ellipsoids";
style_ellipsoid.timestamp = Date.now();

View file

@ -16,8 +16,8 @@ function event_radar() {
const target = data["detections_localised"][key];
const points = target["points"];
console.log(target);
console.log(points);
// console.log(target);
// console.log(points);
removeEntitiesOlderThanAndFade("detection", 60, 0.5);

View file

@ -27,6 +27,7 @@
<script src="lib/jquery-3.6.0.min.js"></script>
<script src="event/adsb.js"></script>
<script src="event/radar.js"></script>
<script src="event/ellipsoid.js"></script>
<script src="main.js"></script>
</body>
</html>

View file

@ -254,6 +254,7 @@ window.addEventListener('load', function () {
// call event loops
event_adsb();
event_radar();
event_ellipsoid();
})

View file

@ -108,37 +108,46 @@ async def event():
if associated_dets:
print(associated_dets, flush=True)
#if localised_dets:
if localised_dets:
print(localised_dets, flush=True)
# tmp test
# localised_dets = {}
# localised_dets["test"] = {}
# x_tx, y_tx, z_tx = Geometry.lla2ecef(
# radar_dict_item['radar4.30hours.dev']["config"]['location']['tx']['latitude'],
# radar_dict_item['radar4.30hours.dev']["config"]['location']['tx']['longitude'],
# radar_dict_item['radar4.30hours.dev']["config"]['location']['tx']['altitude']
# )
# x_rx, y_rx, z_rx = Geometry.lla2ecef(
# radar_dict_item['radar4.30hours.dev']["config"]['location']['rx']['latitude'],
# radar_dict_item['radar4.30hours.dev']["config"]['location']['rx']['longitude'],
# radar_dict_item['radar4.30hours.dev']["config"]['location']['rx']['altitude']
# )
# ellipsoid = Ellipsoid(
# [x_tx, y_tx, z_tx],
# [x_rx, y_rx, z_rx],
# 'radar4.30hours.dev'
# )
# points = ellipsoidParametric.sample(ellipsoid, 2000, 25)
# pointsLla = []
# for point in points:
# lat, lon, alt = Geometry.ecef2lla(point[0], point[1], point[2])
# pointsLla.append([round(lat, 3), round(lon, 3), round(alt)])
# localised_dets["test"]["points"] = pointsLla
ellipsoids = {}
for radar in radar_dict.keys():
x_tx, y_tx, z_tx = Geometry.lla2ecef(
radar_dict_item[radar]["config"]['location']['tx']['latitude'],
radar_dict_item[radar]["config"]['location']['tx']['longitude'],
radar_dict_item[radar]["config"]['location']['tx']['altitude']
)
x_rx, y_rx, z_rx = Geometry.lla2ecef(
radar_dict_item[radar]["config"]['location']['rx']['latitude'],
radar_dict_item[radar]["config"]['location']['rx']['longitude'],
radar_dict_item[radar]["config"]['location']['rx']['altitude']
)
ellipsoid = Ellipsoid(
[x_tx, y_tx, z_tx],
[x_rx, y_rx, z_rx],
radar
)
bsr = 0
if radar == 'radar4.30hours.dev':
bsr = 12470
if radar == 'radar5.30hours.dev':
bsr = 1870
if radar == 'radar4.30hours.dev':
bsr = 5210
points = ellipsoidParametric.sample(ellipsoid, bsr, 10)
for i in range(len(points)):
lat, lon, alt = Geometry.ecef2lla(points[i][0], points[i][1], points[i][2])
points[i] = ([round(lat, 3), round(lon, 3), round(alt)])
ellipsoids[radar] = points
# output data to API
item["detections_associated"] = associated_dets
item["detections_localised"] = localised_dets
if ellipsoids:
item["ellipsoids"] = ellipsoids
# delete old API requests
api_event = [