From 5b1e250d573b380753435227fb0d0aad4250ffe1 Mon Sep 17 00:00:00 2001 From: KF7EEL Date: Tue, 2 Mar 2021 12:56:24 -0800 Subject: [PATCH] fix exception in map view --- scripts/dashboard/dashboard.py | 177 ++++++++++++++++----------------- 1 file changed, 88 insertions(+), 89 deletions(-) diff --git a/scripts/dashboard/dashboard.py b/scripts/dashboard/dashboard.py index cfb2db3..2bdaca4 100644 --- a/scripts/dashboard/dashboard.py +++ b/scripts/dashboard/dashboard.py @@ -202,105 +202,104 @@ def view_map(): map_size = request.args.get('map_size') user_loc = ast.literal_eval(os.popen('cat /tmp/gps_data_user_loc.txt').read()) last_known_list = [] - #try: - if track_call: - #folium_map = folium.Map(location=map_center, zoom_start=int(zoom_level)) - #marker_cluster = MarkerCluster().add_to(folium_map) - for user_coord in user_loc: - user_lat = aprs_to_latlon(float(re.sub('[A-Za-z]','', user_coord['lat']))) - user_lon = aprs_to_latlon(float(re.sub('[A-Za-z]','', user_coord['lon']))) - if type(user_coord['time']) == str: - loc_time = str(user_coord['time']) - if type(user_coord['time']) == int or type(user_coord['time']) == float: - loc_time = datetime.fromtimestamp(user_coord['time']).strftime(time_format) - if 'S' in user_coord['lat']: - user_lat = -user_lat - if 'W' in user_coord['lon']: - user_lon = -user_lon - loc_comment = '' - if 'comment' in user_coord: - loc_comment = """ - - Comment: - - - """+ str(user_coord['comment']) +""" - """ - if user_coord['call'] not in last_known_list and user_coord['call'] == track_call: - folium_map = folium.Map(location=[user_lat, user_lon], tiles=map_theme, zoom_start=15) - marker_cluster = MarkerCluster().add_to(folium_map) - folium.Marker([user_lat, user_lon], popup=""" - - + try: + if track_call: + #folium_map = folium.Map(location=map_center, zoom_start=int(zoom_level)) + #marker_cluster = MarkerCluster().add_to(folium_map) + for user_coord in user_loc: + user_lat = aprs_to_latlon(float(re.sub('[A-Za-z]','', user_coord['lat']))) + user_lon = aprs_to_latlon(float(re.sub('[A-Za-z]','', user_coord['lon']))) + if type(user_coord['time']) == str: + loc_time = str(user_coord['time']) + if type(user_coord['time']) == int or type(user_coord['time']) == float: + loc_time = datetime.fromtimestamp(user_coord['time']).strftime(time_format) + if 'S' in user_coord['lat']: + user_lat = -user_lat + if 'W' in user_coord['lon']: + user_lon = -user_lon + loc_comment = '' + if 'comment' in user_coord: + loc_comment = """ - + - - - - - """ + loc_comment + """ - - -
Last Location:Comment:
"""+ str(user_coord['call']) +"""
"""+ loc_time +"""
-
- """, icon=folium.Icon(color="red", icon="record"), tooltip=str(user_coord['call'])).add_to(folium_map) - last_known_list.append(user_coord['call']) - if user_coord['call'] in last_known_list and user_coord['call'] == track_call: - folium.CircleMarker([user_lat, user_lon], popup=""" - - - - - - - - - -
""" + user_coord['call'] + """
""" + loc_time + """
- """, tooltip=str(user_coord['call']), fill=True, fill_color="#3186cc", radius=4).add_to(marker_cluster) - #return folium_map._repr_html_() - if not reload_time: - reload_time = 120 - if not map_size: - map_view = ''' + + """ + if user_coord['call'] not in last_known_list and user_coord['call'] == track_call: + folium_map = folium.Map(location=[user_lat, user_lon], tiles=map_theme, zoom_start=15) + marker_cluster = MarkerCluster().add_to(folium_map) + folium.Marker([user_lat, user_lon], popup=""" +
"""+ str(user_coord['comment']) +"""
- + + + + + + + + """ + loc_comment + """ -
- ''' + folium_map._repr_html_() + '''Last Location:
"""+ str(user_coord['call']) +"""
"""+ loc_time +"""
''' - if map_size == 'full': - map_view = folium_map._repr_html_() + + + """, icon=folium.Icon(color="red", icon="record"), tooltip=str(user_coord['call'])).add_to(folium_map) + last_known_list.append(user_coord['call']) + if user_coord['call'] in last_known_list and user_coord['call'] == track_call: + folium.CircleMarker([user_lat, user_lon], popup=""" + + + + + + + + + +
""" + user_coord['call'] + """
""" + loc_time + """
+ """, tooltip=str(user_coord['call']), fill=True, fill_color="#3186cc", radius=4).add_to(marker_cluster) + #return folium_map._repr_html_() + if not reload_time: + reload_time = 120 + if not map_size: + map_view = ''' + + + + + +
+ ''' + folium_map._repr_html_() + '''
''' + if map_size == 'full': + map_view = folium_map._repr_html_() - content = ''' - - - - """ + dashboard_title + """ - Tracking """+ track_call + """ - -

""" + dashboard_title + """ - Tracking """ + track_call + """

-

Page automatically reloads every """ + str(reload_time) + """ seconds.

-

- -

-

- """ + map_view - return render_template('generic.html', title = dashboard_title, logo = logo, content = Markup(content)) - #except Exception as e: - #content = """

Station not found.

+ content = ''' + + + + """ + dashboard_title + """ - Tracking """+ track_call + """ + +

""" + dashboard_title + """ - Tracking """ + track_call + """

+

Page automatically reloads every """ + str(reload_time) + """ seconds.

+

+ +

+

+ """ + map_view + return render_template('generic.html', title = dashboard_title, logo = logo, content = Markup(content)) + except Exception as e: + content = """

Station not found.

#

#

""" - #content = str(e) - #return render_template('generic.html', title = dashboard_title, logo = logo, content = Markup(content)) + return render_template('generic.html', title = dashboard_title, logo = logo, content = Markup(content)) if not track_call: folium_map = folium.Map(location=map_center, tiles=map_theme, zoom_start=int(zoom_level))