From 9b14982abe0ef1aee16c6870ae206de2c05ce499 Mon Sep 17 00:00:00 2001 From: KF7EEL Date: Fri, 26 Feb 2021 23:30:49 -0800 Subject: [PATCH] improve map and dashboard --- scripts/dashboard/dashboard.py | 19 ++++++++++++++----- scripts/dashboard/templates/map.html | 3 ++- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/scripts/dashboard/dashboard.py b/scripts/dashboard/dashboard.py index e01df20..39f7a67 100644 --- a/scripts/dashboard/dashboard.py +++ b/scripts/dashboard/dashboard.py @@ -58,19 +58,24 @@ def get_loc_data(): ''' + last_known_loc_list = [] display_number = 15 for e in dash_loc: if display_number == 0: break else: - display_number = display_number - 1 - tmp_loc = tmp_loc + ''' + if e['call'] in last_known_loc_list: + pass + if e['call'] not in last_known_loc_list: + last_known_loc_list.append(e['call']) + display_number = display_number - 1 + tmp_loc = tmp_loc + ''' ''' + e['call'] + '''  ''' + str(e['lat']) + '''   ''' + str(e['lon']) + '''   ''' + e['time'] + '''  ''' - return str(str('

Positions Received

') + tbl_hdr + loc_hdr + tmp_loc + tbl_ftr) + return str(str('

Last Known Location

') + tbl_hdr + loc_hdr + tmp_loc + tbl_ftr) except: return str('

No data

') @@ -139,7 +144,7 @@ def about(): @app.route('/view_map/') def view_map(): user_loc = ast.literal_eval(os.popen('cat /tmp/gps_data_user_loc.txt').read()) - #map_center = (47.9540700, -120.7360300) + last_known_list = [] folium_map = folium.Map(location=map_center, zoom_start=int(zoom_level)) for user_coord in user_loc: user_lat = aprs_to_latlon(float(re.sub('[A-Za-z]','', user_coord['lat']))) @@ -148,7 +153,11 @@ def view_map(): user_lat = -user_lat if 'W' in user_coord['lon']: user_lon = -user_lon - folium.Marker([user_lat, user_lon], popup="" + '' + str(user_coord['call']) + '' + '\n' + user_coord['time'] + "", tooltip=str(user_coord['call'])).add_to(folium_map) + if user_coord['call'] not in last_known_list: + folium.Marker([user_lat, user_lon], popup="" + 'Last Location: \n' + str(user_coord['call']) + '' + '\n' + user_coord['time'] + "", icon=folium.Icon(color="red", icon="info-sign"), tooltip=str(user_coord['call'])).add_to(folium_map) + last_known_list.append(user_coord['call']) + if user_coord['call'] in last_known_list: + folium.Marker([user_lat, user_lon], popup="" + '' + str(user_coord['call']) + '' + '\n' + user_coord['time'] + "", tooltip=str(user_coord['call'])).add_to(folium_map) return folium_map._repr_html_() @app.route('/map/') def map(): diff --git a/scripts/dashboard/templates/map.html b/scripts/dashboard/templates/map.html index 0c5bdae..f733bd9 100644 --- a/scripts/dashboard/templates/map.html +++ b/scripts/dashboard/templates/map.html @@ -1,6 +1,7 @@ {% include 'page.html' %} {% include 'header.html' %} -{{description}} +

Red: Last location received. Blue: Location history.

+

 

 

{% include 'footer.html' %}