From 82a019a6ad8492be83956d1cdc44492f90b9bdb3 Mon Sep 17 00:00:00 2001 From: 30hours Date: Mon, 4 Mar 2024 11:10:50 +0000 Subject: [PATCH] Changed ellipsoid algorithm to use a master ellipsoid --- api/map/event/ellipsoid.js | 12 ++--- api/map/event/radar.js | 9 +++- .../algorithm/coordreg/EllipsoidParametric.py | 48 +++++++++---------- event/event.py | 2 +- 4 files changed, 38 insertions(+), 33 deletions(-) diff --git a/api/map/event/ellipsoid.js b/api/map/event/ellipsoid.js index 3d27480..77c2517 100644 --- a/api/map/event/ellipsoid.js +++ b/api/map/event/ellipsoid.js @@ -11,21 +11,21 @@ function event_ellipsoid() { return response.json(); }) .then(data => { + + if (!data["ellipsoids"]) { + return; + } + if (Object.keys(data["ellipsoids"]).length !== 0) { - console.log('remove'); removeEntitiesByType("ellipsoids"); } else { - removeEntitiesOlderThanAndFade("ellipsoids", 30, 0.2); - console.log('fade'); + removeEntitiesOlderThanAndFade("ellipsoids", 5, 0.5); } for (const key in data["ellipsoids"]) { if (data["ellipsoids"].hasOwnProperty(key)) { const points = data["ellipsoids"][key]; - console.log(key); - console.log(points); - for (const point in points) { addPoint( points[point][0], diff --git a/api/map/event/radar.js b/api/map/event/radar.js index bb23dc2..fde9312 100644 --- a/api/map/event/radar.js +++ b/api/map/event/radar.js @@ -11,13 +11,18 @@ function event_radar() { return response.json(); }) .then(data => { + + if (!data["detections_localised"]) { + return; + } + + removeEntitiesOlderThanAndFade("detection", 10, 0.5); + for (const key in data["detections_localised"]) { if (data["detections_localised"].hasOwnProperty(key)) { const target = data["detections_localised"][key]; const points = target["points"]; - removeEntitiesOlderThanAndFade("detection", 60, 0.5); - for (const point in points) { addPoint( points[point][0], diff --git a/event/algorithm/coordreg/EllipsoidParametric.py b/event/algorithm/coordreg/EllipsoidParametric.py index 2fe0052..299340e 100644 --- a/event/algorithm/coordreg/EllipsoidParametric.py +++ b/event/algorithm/coordreg/EllipsoidParametric.py @@ -75,39 +75,39 @@ class EllipsoidParametric: radar["radar"] ) - samples = self.sample(ellipsoid, radar["delay"]*1000, 20) + samples = self.sample(ellipsoid, radar["delay"]*1000, 120) target_samples[target][radar["radar"]] = samples - # find close points + # find close points - ellipsoid 1 = master radar_keys = list(target_samples[target].keys()) - samples_intersect = {key: [] for key in radar_keys} + samples_intersect = [] threshold = 200 - for i in range(0, len(target_samples[target])-1): - for j in range(i+1, len(target_samples[target])): - - for point1 in target_samples[target][radar_keys[i]]: - - for point2 in target_samples[target][radar_keys[j]]: - - if Geometry.distance_ecef(point1, point2) < threshold: - samples_intersect[radar_keys[i]].append(point1) - samples_intersect[radar_keys[j]].append(point2) + # loop points in master ellipsoid + for point1 in target_samples[target][radar_keys[0]]: + valid_point = True + # loop over each other list + for i in range(1, len(radar_keys)): + # loop points in other list + if not any(Geometry.distance_ecef(point1, point2) < threshold + for point2 in target_samples[target][radar_keys[i]]): + valid_point = False + break + if valid_point: + samples_intersect.append(point1) # remove duplicates and convert to LLA output[target] = {} output[target]["points"] = [] - for key in radar_keys: - samples_intersect[key] = [list(t) for t in {tuple(point) for point in samples_intersect[key]}] - for i in range(len(samples_intersect[key])): - samples_intersect[key][i] = Geometry.ecef2lla( - samples_intersect[key][i][0], - samples_intersect[key][i][1], - samples_intersect[key][i][2]) - output[target]["points"].append([ - round(samples_intersect[key][i][0], 3), - round(samples_intersect[key][i][1], 3), - round(samples_intersect[key][i][2])]) + for i in range(len(samples_intersect)): + samples_intersect[i] = Geometry.ecef2lla( + samples_intersect[i][0], + samples_intersect[i][1], + samples_intersect[i][2]) + output[target]["points"].append([ + round(samples_intersect[i][0], 3), + round(samples_intersect[i][1], 3), + round(samples_intersect[i][2])]) return output diff --git a/event/event.py b/event/event.py index 85fbd99..baf9b2e 100644 --- a/event/event.py +++ b/event/event.py @@ -131,7 +131,7 @@ async def event(): [x_rx, y_rx, z_rx], radar["radar"] ) - points = ellipsoidParametric.sample(ellipsoid, radar["delay"]*1000, 50) + points = ellipsoidParametric.sample(ellipsoid, radar["delay"]*1000, 30) 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)])