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