improve map and dashboard
This commit is contained in:
parent
61fd13514b
commit
9b14982abe
@ -58,11 +58,16 @@ def get_loc_data():
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
'''
|
'''
|
||||||
|
last_known_loc_list = []
|
||||||
display_number = 15
|
display_number = 15
|
||||||
for e in dash_loc:
|
for e in dash_loc:
|
||||||
if display_number == 0:
|
if display_number == 0:
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
|
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
|
display_number = display_number - 1
|
||||||
tmp_loc = tmp_loc + '''<tr>
|
tmp_loc = tmp_loc + '''<tr>
|
||||||
<td style="text-align: center;"><a href="https://aprs.fi/''' + e['call'] + '''"><strong>''' + e['call'] + '''</strong></a></td>
|
<td style="text-align: center;"><a href="https://aprs.fi/''' + e['call'] + '''"><strong>''' + e['call'] + '''</strong></a></td>
|
||||||
@ -70,7 +75,7 @@ def get_loc_data():
|
|||||||
<td style="text-align: center;"><strong> ''' + str(e['lon']) + ''' </strong></td>
|
<td style="text-align: center;"><strong> ''' + str(e['lon']) + ''' </strong></td>
|
||||||
<td style="text-align: center;"> ''' + e['time'] + ''' </td>
|
<td style="text-align: center;"> ''' + e['time'] + ''' </td>
|
||||||
</tr>'''
|
</tr>'''
|
||||||
return str(str('<h1 style="text-align: center;">Positions Received</h1>') + tbl_hdr + loc_hdr + tmp_loc + tbl_ftr)
|
return str(str('<h1 style="text-align: center;">Last Known Location</h1>') + tbl_hdr + loc_hdr + tmp_loc + tbl_ftr)
|
||||||
except:
|
except:
|
||||||
return str('<h1 style="text-align: center;">No data</h1>')
|
return str('<h1 style="text-align: center;">No data</h1>')
|
||||||
|
|
||||||
@ -139,7 +144,7 @@ def about():
|
|||||||
@app.route('/view_map/')
|
@app.route('/view_map/')
|
||||||
def view_map():
|
def view_map():
|
||||||
user_loc = ast.literal_eval(os.popen('cat /tmp/gps_data_user_loc.txt').read())
|
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))
|
folium_map = folium.Map(location=map_center, zoom_start=int(zoom_level))
|
||||||
for user_coord in user_loc:
|
for user_coord in user_loc:
|
||||||
user_lat = aprs_to_latlon(float(re.sub('[A-Za-z]','', user_coord['lat'])))
|
user_lat = aprs_to_latlon(float(re.sub('[A-Za-z]','', user_coord['lat'])))
|
||||||
@ -148,6 +153,10 @@ def view_map():
|
|||||||
user_lat = -user_lat
|
user_lat = -user_lat
|
||||||
if 'W' in user_coord['lon']:
|
if 'W' in user_coord['lon']:
|
||||||
user_lon = -user_lon
|
user_lon = -user_lon
|
||||||
|
if user_coord['call'] not in last_known_list:
|
||||||
|
folium.Marker([user_lat, user_lon], popup="<i>" + '<strong>Last Location: \n' + str(user_coord['call']) + '</strong>' + '\n' + user_coord['time'] + "</i>", 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="<i>" + '<strong>' + str(user_coord['call']) + '</strong>' + '\n' + user_coord['time'] + "</i>", tooltip=str(user_coord['call'])).add_to(folium_map)
|
folium.Marker([user_lat, user_lon], popup="<i>" + '<strong>' + str(user_coord['call']) + '</strong>' + '\n' + user_coord['time'] + "</i>", tooltip=str(user_coord['call'])).add_to(folium_map)
|
||||||
return folium_map._repr_html_()
|
return folium_map._repr_html_()
|
||||||
@app.route('/map/')
|
@app.route('/map/')
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
{% include 'page.html' %}
|
{% include 'page.html' %}
|
||||||
{% include 'header.html' %}
|
{% include 'header.html' %}
|
||||||
{{description}}
|
<p style="text-align: center;"><span style="color: #ff0000;"><strong>Red</strong></span>: Last location received. <span style="color: #0000ff;"><strong>Blue</strong></span>: Location history.</p>
|
||||||
|
<p style="text-align: center;"> </p>
|
||||||
<div><p align="center"><iframe style="border: none;" title="Map" src="../view_map" width="900" height="800"></iframe></p></div>
|
<div><p align="center"><iframe style="border: none;" title="Map" src="../view_map" width="900" height="800"></iframe></p></div>
|
||||||
<p> </p>
|
<p> </p>
|
||||||
{% include 'footer.html' %}
|
{% include 'footer.html' %}
|
||||||
|
Loading…
Reference in New Issue
Block a user