detection of nearest METAR
This commit is contained in:
@@ -82,7 +82,7 @@ import mpld3
|
||||
from mpld3 import plugins
|
||||
import stravalib
|
||||
from stravalib.exc import ActivityUploadFailed,TimeoutExceeded
|
||||
from weather import get_wind_data
|
||||
from weather import get_wind_data,get_airport_code
|
||||
|
||||
from oauth2_provider.models import Application,Grant,AccessToken
|
||||
|
||||
@@ -2435,7 +2435,9 @@ def workout_crewnerd_summary_view(request,id=0,message="",successmessage=""):
|
||||
'id':row.id})
|
||||
|
||||
# Get weather for given location and date/time
|
||||
@user_passes_test(ispromember,login_url="/",redirect_field_name=None)
|
||||
@user_passes_test(ispromember,login_url="/",redirect_field_name=None)
|
||||
def workout_downloadwind_view(request,id=0,
|
||||
airportcode=None,
|
||||
message="",successmessage=""):
|
||||
try:
|
||||
row = Workout.objects.get(id=id)
|
||||
@@ -2536,7 +2538,16 @@ def workout_wind_view(request,id=0,message="",successmessage=""):
|
||||
rowdata.add_bearing()
|
||||
rowdata.write_csv(f1,gzip=True)
|
||||
|
||||
|
||||
|
||||
if hascoordinates:
|
||||
avglat = rowdata.df[' latitude'].mean()
|
||||
avglon = rowdata.df[' longitude'].mean()
|
||||
airportcode,newlat,newlon,airportdistance = get_airport_code(avglat,avglon)
|
||||
airportcode = airportcode.upper()
|
||||
airportdistance = airportdistance[0]
|
||||
else:
|
||||
airportcode = 'UNKNOWN'
|
||||
airportdistance = 0
|
||||
|
||||
|
||||
if request.method == 'POST':
|
||||
@@ -2593,6 +2604,8 @@ def workout_wind_view(request,id=0,message="",successmessage=""):
|
||||
'message': message,
|
||||
'successmessage': successmessage,
|
||||
'interactiveplot':script,
|
||||
'form':form,
|
||||
'airport':airportcode,
|
||||
'airportdistance':airportdistance,
|
||||
'the_div':div,
|
||||
'gmap':gmscript,
|
||||
|
||||
Reference in New Issue
Block a user