From 2bc28f18cf933425b6af948535cc3a3a10752698 Mon Sep 17 00:00:00 2001 From: 30hours Date: Mon, 19 Feb 2024 05:19:23 +0000 Subject: [PATCH] Associator adsb working --- api/map/main.js | 11 ++++------ api/public/js/index.js | 2 +- event/algorithm/associator/AdsbAssociator.py | 20 ++++++++++++++----- event/algorithm/coordreg/EllipseParametric.py | 6 +++++- event/event.py | 9 ++++++--- 5 files changed, 31 insertions(+), 17 deletions(-) diff --git a/api/map/main.js b/api/map/main.js index 374d6ba..981a54a 100644 --- a/api/map/main.js +++ b/api/map/main.js @@ -184,7 +184,8 @@ window.addEventListener('load', function () { // add radar points const radar_names = new URLSearchParams( - window.location.search).get('url').split('&'); + window.location.search).getAll('url'); + console.log(radar_names); var radar_config_url = radar_names.map( url => `http://${url}/api/config`); if (this.window.location.protocol === "https:") { @@ -249,7 +250,6 @@ window.addEventListener('load', function () { url => url.replace(/^http:/, 'https:')); } adsb_url = adsb_url[0]; - console.log(adsb_url); // call event loops event_adsb(); @@ -306,13 +306,10 @@ function removeEntitiesByType(entityType) { } function doesEntityNameExist(name) { - - // loop over all entities in the viewer - viewer.entities.values.forEach((entity) => { + for (const entity of viewer.entities.values) { if (entity.name === name) { return true; } - }); - + } return false; } \ No newline at end of file diff --git a/api/public/js/index.js b/api/public/js/index.js index 22d3f07..87005f6 100644 --- a/api/public/js/index.js +++ b/api/public/js/index.js @@ -45,7 +45,7 @@ document.getElementById('buttonMap').addEventListener('click', function() { var adsb = document.querySelector('[name="adsb"]').value; // Construct the URL with the form values - var apiUrl = '?url=' + Array.from(servers).map(server => server.value).join('&'); + var apiUrl = '?url=' + Array.from(servers).map(server => server.value).join('&url='); var mapUrl = '/map/index.html' + apiUrl + '&associator=' + associator + '&coordreg=' + coordreg + '&adsb=' + adsb; // Redirect to the constructed URL diff --git a/event/algorithm/associator/AdsbAssociator.py b/event/algorithm/associator/AdsbAssociator.py index d6d65be..65ac0cc 100644 --- a/event/algorithm/associator/AdsbAssociator.py +++ b/event/algorithm/associator/AdsbAssociator.py @@ -59,11 +59,17 @@ class AdsbAssociator: assoc_detections_radar.append(self.process_1_radar( radar, radar_data[radar]["detection"], adsb_detections)) - # associate detections between radars - - print(assoc_detections_radar, flush=True) - + # associate detections between radars + output = {} + for entry in assoc_detections_radar: + for key, value in entry.items(): + if key not in output: + output[key] = [value] + else: + output[key].append(value) + output = {key: values for key, values in output.items() if len(values) > 1} + return output def process_1_radar(self, radar, radar_detections, adsb_detections): @@ -120,7 +126,11 @@ class AdsbAssociator: tx_lon = radar_data['config']['location']['tx']['longitude'] tx_alt = radar_data['config']['location']['tx']['altitude'] fc = radar_data['config']['capture']['fc'] - adsb = radar_data['config']['truth']['adsb']['ip'] + + if (radar == "radar5.30hours.dev"): + adsb = radar_data['config']['truth']['adsb']['ip'] + else: + adsb = radar_data['config']['truth']['adsb']['tar1090'] api_url = "http://adsb2dd.30hours.dev/api/dd" diff --git a/event/algorithm/coordreg/EllipseParametric.py b/event/algorithm/coordreg/EllipseParametric.py index 8b30d29..daf1f18 100644 --- a/event/algorithm/coordreg/EllipseParametric.py +++ b/event/algorithm/coordreg/EllipseParametric.py @@ -18,7 +18,7 @@ class EllipseParametric: @brief Constructor for the EllipseParametric class. """ - def process(self, assoc_detections): + def process(self, assoc_detections, radar_data): """ @brief Perform coord registration using the ellipse parametric method. @@ -29,4 +29,8 @@ class EllipseParametric: @return str: JSON of associated detections. """ + output = {} + + return output + \ No newline at end of file diff --git a/event/event.py b/event/event.py index f12bcfe..2495da8 100644 --- a/event/event.py +++ b/event/event.py @@ -29,8 +29,6 @@ async def event(): global api timestamp = int(time.time()*1000) - - # main event loop api_event = copy.copy(api) # list all blah2 radars @@ -80,7 +78,6 @@ async def event(): for item in api_event: # extract dict for item - #radar_dict_item = {key: None for key in item["server"]} radar_dict_item = { key: radar_dict[key] for key in item["server"] @@ -101,7 +98,13 @@ async def event(): print("Error: Coord reg invalid.") return + # processing associated_dets = associator.process(item["server"], radar_dict_item) + localised_dets = coordreg.process(associated_dets, radar_dict_item) + + # output data to API + item["detections_associated"] = associated_dets + item["detections_localised"] = localised_dets # delete old API requests api_event = [