add map to dashboard

This commit is contained in:
KF7EEL 2021-02-26 21:17:06 -08:00
parent 72ed9f2d2b
commit db77a165b4
6 changed files with 39 additions and 3 deletions

View File

@ -15,8 +15,10 @@ Files modified from original master branch of HBLink3:
#### Optional Modules
* Flask - Required for dashboard
* smtplib - Required for sending email. If pip fails to install module, it may already be installed as most Linux distrobutions have this module by default.
* smtplib - Required for sending email. If pip fails to install module, it may already be installed as most Linux distributions have this module by default.
* traceback - If pip fails to install module, it may already be installed as most Linux distrobutions have this module by default.
* slixmpp - Required for upcoming XMPP gateway.
* folium - Required for mapping on dashboard.
This should work for DMR radios that send location data as a UTF-8 NMEA sentence. I am hopping to add support for more radios in the future.

View File

@ -4,8 +4,7 @@ Twisted>=16.3.0
dmr_utils3>=0.1.19
configparser>=3.0.0
aprslib>=0.6.42
traceback
pynmea2
maidenhead
flask
smtplib
folium

View File

@ -24,6 +24,8 @@ This is a web dashboard for the GPS/Data application.
from flask import Flask, render_template
import ast, os
from dashboard_settings import *
import folium
import re
app = Flask(__name__)
@ -101,6 +103,10 @@ def get_bb_data():
return str('<h1 style="text-align: center;">Bulletin Board</h1>' + tbl_hdr + bb_hdr + tmp_bb + tbl_ftr)
except:
return str('<h1 style="text-align: center;">No data</h1>')
def aprs_to_latlon(x):
degrees = int(x) // 100
minutes = x - 100*degrees
return degrees + minutes/60
@app.route('/')
def index():
@ -125,6 +131,23 @@ def help():
def about():
#return get_data()
return render_template('about.html', title = dashboard_title, logo = logo, contact_name = contact_name, contact_call = contact_call, contact_email = contact_email, contact_website = contact_website)
@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)
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'])))
user_lon = aprs_to_latlon(float(re.sub('[A-Za-z]','', user_coord['lon'])))
if 'S' in user_coord['lat']:
user_lat = -user_lat
if 'W' in user_coord['lon']:
user_lon = -user_lon
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_()
@app.route('/map/')
def map():
return render_template('map.html', title = dashboard_title, logo = logo)
if __name__ == '__main__':
app.run(debug = True, port=dash_port, host=dash_host)

View File

@ -47,3 +47,7 @@ contact_name = 'your name'
contact_call = 'N0CALL'
contact_email = 'email@example.org'
contact_website = 'https://hbl.ink'
# Center dashboard map over these coordinates
map_center = (47.00, -120.00)
zoom_level = 7

View File

@ -5,6 +5,7 @@
<tbody>
<tr>
<td style="text-align: center;"><button onclick="window.location.href='/';"> D-APRS Dashboard </button></td>
<td style="text-align: center;"><button onclick="window.location.href='/map';"> Station Map </button></td>
<td style="text-align: center;"><button onclick="window.location.href='/help';"> D-APRS Help </button></td>
<td style="text-align: center;"><button onclick="window.location.href='/about';"> Gateway Contact </button></td>
</tr>

View File

@ -0,0 +1,7 @@
{% include 'page.html' %}
{% include 'header.html' %}
{{description}}
<div><p align="center"><iframe style="border: none;" title="Map" src="../view_map" width="900" height="800"></iframe></p></div>
<p>&nbsp;</p>
{% include 'footer.html' %}