now working with json object - to prepare for future AJAX calls
This commit is contained in:
@@ -66,9 +66,10 @@
|
||||
// after the API code downloads.
|
||||
var player;
|
||||
var videotime = 0;
|
||||
var boatspeed = [{% for s in boatspeed %}{{ s|floatformat:4 }},{% endfor %}];
|
||||
var latitude = [{% for lat in latitude %}{{ lat }},{% endfor %}];
|
||||
var longitude = [{% for lon in longitude %}{{ lon }},{% endfor %}];
|
||||
var data = JSON.parse('{{ data|safe }}');
|
||||
var boatspeed = data["boatspeed"];
|
||||
var latitude = data["latitude"];
|
||||
var longitude = data["longitude"];
|
||||
|
||||
function onYouTubeIframeAPIReady() {
|
||||
player = new YT.Player('player', {
|
||||
|
||||
@@ -6,6 +6,12 @@ from __future__ import unicode_literals
|
||||
from rowers.views.statements import *
|
||||
import rowers.teams as teams
|
||||
|
||||
import numpy
|
||||
|
||||
def default(o):
|
||||
if isinstance(o, numpy.int64): return int(o)
|
||||
raise TypeError
|
||||
|
||||
# Show a video compared with data
|
||||
@user_passes_test(ispromember,login_url="/rowers/paidplans/",
|
||||
message="This functionality requires a Pro plan or higher",
|
||||
@@ -17,7 +23,7 @@ def workout_video_view(request,id=0):
|
||||
df.sort_values(by='time',inplace=True)
|
||||
df.set_index(pd.to_timedelta(df['time'],unit='s'),inplace=True)
|
||||
df2 = df.resample('1s').mean().interpolate()
|
||||
boatspeed = df2['velo']
|
||||
boatspeed = (100*df2['velo']).astype(int)/100.
|
||||
|
||||
coordinates = dataprep.get_latlon_time(w.id)
|
||||
coordinates.set_index(pd.to_timedelta(coordinates['time'],unit='s'),inplace=True)
|
||||
@@ -30,9 +36,9 @@ def workout_video_view(request,id=0):
|
||||
w.name)
|
||||
|
||||
# bundle data
|
||||
data = {'boatspeed':boatspeed.values,
|
||||
'latitude':latitude.values,
|
||||
'longitude':longitude.values}
|
||||
data = {'boatspeed':[ v for v in boatspeed.values],
|
||||
'latitude':[ l for l in latitude.values],
|
||||
'longitude':[ l for l in longitude.values]}
|
||||
|
||||
return render(request,
|
||||
'embedded_video.html',
|
||||
@@ -42,6 +48,7 @@ def workout_video_view(request,id=0):
|
||||
'boatspeed': boatspeed.values,
|
||||
'latitude': latitude.values,
|
||||
'longitude': longitude.values,
|
||||
'data': json.dumps(data,default=default),
|
||||
'mapscript': mapscript,
|
||||
'mapdiv': mapdiv,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user