diff --git a/api/map/event/ellipsoid.js b/api/map/event/ellipsoid.js new file mode 100644 index 0000000..74b88a5 --- /dev/null +++ b/api/map/event/ellipsoid.js @@ -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(); \ No newline at end of file diff --git a/api/map/event/radar.js b/api/map/event/radar.js index 01b2c1b..fe9f0ae 100644 --- a/api/map/event/radar.js +++ b/api/map/event/radar.js @@ -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); diff --git a/api/map/index.html b/api/map/index.html index d789605..1a8b493 100644 --- a/api/map/index.html +++ b/api/map/index.html @@ -27,6 +27,7 @@ + diff --git a/api/map/main.js b/api/map/main.js index 07b969c..ccca705 100644 --- a/api/map/main.js +++ b/api/map/main.js @@ -254,6 +254,7 @@ window.addEventListener('load', function () { // call event loops event_adsb(); event_radar(); + event_ellipsoid(); }) diff --git a/event/event.py b/event/event.py index 629b23a..d5182e5 100644 --- a/event/event.py +++ b/event/event.py @@ -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 = [