From 56439cbaf015de840ff4a424ea5cadb8966031e9 Mon Sep 17 00:00:00 2001 From: 30hours Date: Sun, 3 Mar 2024 13:22:49 +0000 Subject: [PATCH] Plot ellipsoids properly --- api/map/event/ellipsoid.js | 15 +++++-- .../algorithm/coordreg/EllipsoidParametric.py | 4 +- event/event.py | 41 ++++++++----------- 3 files changed, 31 insertions(+), 29 deletions(-) diff --git a/api/map/event/ellipsoid.js b/api/map/event/ellipsoid.js index f31a7ee..3d27480 100644 --- a/api/map/event/ellipsoid.js +++ b/api/map/event/ellipsoid.js @@ -11,11 +11,20 @@ function event_ellipsoid() { return response.json(); }) .then(data => { + if (Object.keys(data["ellipsoids"]).length !== 0) { + console.log('remove'); + removeEntitiesByType("ellipsoids"); + } + else { + removeEntitiesOlderThanAndFade("ellipsoids", 30, 0.2); + console.log('fade'); + } for (const key in data["ellipsoids"]) { if (data["ellipsoids"].hasOwnProperty(key)) { const points = data["ellipsoids"][key]; - removeEntitiesOlderThanAndFade("ellipsoids", 30, 0.2); + console.log(key); + console.log(points); for (const point in points) { addPoint( @@ -39,13 +48,13 @@ function event_ellipsoid() { }) .finally(() => { // Schedule the next fetch after a delay (e.g., 5 seconds) - setTimeout(event_radar, 1000); + setTimeout(event_ellipsoid, 1000); }); } var style_ellipsoid = {}; -style_ellipsoid.color = 'rgba(0, 0, 255, 0.2)'; +style_ellipsoid.color = 'rgba(0, 0, 255, 0.5)'; style_ellipsoid.pointSize = 16; style_ellipsoid.type = "ellipsoids"; style_ellipsoid.timestamp = Date.now(); \ No newline at end of file diff --git a/event/algorithm/coordreg/EllipsoidParametric.py b/event/algorithm/coordreg/EllipsoidParametric.py index aef4281..2fe0052 100644 --- a/event/algorithm/coordreg/EllipsoidParametric.py +++ b/event/algorithm/coordreg/EllipsoidParametric.py @@ -75,13 +75,13 @@ class EllipsoidParametric: radar["radar"] ) - samples = self.sample(ellipsoid, radar["delay"], 20) + samples = self.sample(ellipsoid, radar["delay"]*1000, 20) target_samples[target][radar["radar"]] = samples # find close points radar_keys = list(target_samples[target].keys()) samples_intersect = {key: [] for key in radar_keys} - threshold = 1500 + threshold = 200 for i in range(0, len(target_samples[target])-1): for j in range(i+1, len(target_samples[target])): diff --git a/event/event.py b/event/event.py index 8af3ec5..85fbd99 100644 --- a/event/event.py +++ b/event/event.py @@ -108,46 +108,39 @@ async def event(): if associated_dets: print(associated_dets, flush=True) - if localised_dets: - print(localised_dets, flush=True) - + # show ellipsoids of associated detections for 1 target ellipsoids = {} - for radar in radar_dict.keys(): + if associated_dets: + # get first target key + key = next(iter(associated_dets)) + ellipsoid_radars = [] + for radar in associated_dets[key]: + ellipsoid_radars.append(radar["radar"]) 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'] + radar_dict_item[radar["radar"]]["config"]['location']['tx']['latitude'], + radar_dict_item[radar["radar"]]["config"]['location']['tx']['longitude'], + radar_dict_item[radar["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'] + radar_dict_item[radar["radar"]]["config"]['location']['rx']['latitude'], + radar_dict_item[radar["radar"]]["config"]['location']['rx']['longitude'], + radar_dict_item[radar["radar"]]["config"]['location']['rx']['altitude'] ) ellipsoid = Ellipsoid( [x_tx, y_tx, z_tx], [x_rx, y_rx, z_rx], - radar + radar["radar"] ) - bsr = 0 - if radar == 'radar4.30hours.dev': - bsr = 12470 - if radar == 'radar5.30hours.dev': - bsr = 1870 - if radar == 'radar6.30hours.dev': - bsr = 5210 - points = ellipsoidParametric.sample(ellipsoid, bsr, 50) + points = ellipsoidParametric.sample(ellipsoid, radar["delay"]*1000, 50) 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 - + ellipsoids[radar["radar"]] = points # output data to API item["detections_associated"] = associated_dets item["detections_localised"] = localised_dets - - if ellipsoids: - item["ellipsoids"] = ellipsoids + item["ellipsoids"] = ellipsoids # delete old API requests api_event = [