diff --git a/rowers/dataprep.py b/rowers/dataprep.py index c9a8fd80..91d5ab86 100644 --- a/rowers/dataprep.py +++ b/rowers/dataprep.py @@ -153,7 +153,15 @@ def get_video_data(w,groups=['basic']): boatspeed = (100*df2['velo']).astype(int)/100. - coordinates = get_latlon_time(w.id) + try: + coordinates = get_latlon_time(w.id) + except KeyError: + nulseries = df['time']*0 + coordinates = pd.DataFrame({ + 'time': df['time'], + 'latitude': nulseries, + 'longitude': nulseries, + }) coordinates.set_index(pd.to_timedelta(coordinates['time'],unit='s'),inplace=True) coordinates = coordinates.resample('1s').mean().interpolate() diff --git a/rowers/templates/embedded_video.html b/rowers/templates/embedded_video.html index 19164b1b..7e172740 100644 --- a/rowers/templates/embedded_video.html +++ b/rowers/templates/embedded_video.html @@ -85,6 +85,7 @@ // 1. Code for the map {{ mapscript | safe }} + // 2. This code loads the IFrame Player API code asynchronously. var tag = document.createElement('script'); diff --git a/rowers/templates/embedded_video_ote.html b/rowers/templates/embedded_video_ote.html new file mode 100644 index 00000000..30925742 --- /dev/null +++ b/rowers/templates/embedded_video_ote.html @@ -0,0 +1,335 @@ +{% extends "newbase.html" %} +{% load staticfiles %} +{% load rowerfilters %} +{% load i18n %} +{% load leaflet_tags %} + + + +{% block title %}Workout Video{% endblock %} + +{% block meta %} +{% leaflet_js %} +{% leaflet_css %} +{% endblock %} + +{% block main %} + + + +{% language 'en' %} +
Paste link to you tube video below
+Use the slider to locate start point for video on workout map
+Playing the video will advance the data in synchonization. Use the regular youtube controls + to move around in the video and play it.
+You can make manual adjustments to the delay to fine tune the alignment. + Once you are finished, check "Lock Video and Data" to lock the video and the data.
+Once you are happy with the alignment, you can save the analysis, and share with other people.
++ + +{% endlanguage %} + +{% endblock %} + +{% block sidebar %} +{% include 'menu_workout.html' %} +{% endblock %} diff --git a/rowers/views/workoutviews.py b/rowers/views/workoutviews.py index 032f4564..ca7db320 100644 --- a/rowers/views/workoutviews.py +++ b/rowers/views/workoutviews.py @@ -196,9 +196,14 @@ def workout_video_create_view(request,id=0): # get data data, metrics, maxtime = dataprep.get_video_data(w,groups=metricsgroups) + hascoordinates = pd.Series(data['latitude']).std() > 0 + # create map - mapscript, mapdiv = leaflet_chart_video(data['latitude'],data['longitude'], + if hascoordinates: + mapscript, mapdiv = leaflet_chart_video(data['latitude'],data['longitude'], w.name) + else: + mapscript, mapdiv = interactive_chart(w.id,promember=1) breadcrumbs = [ { @@ -218,8 +223,13 @@ def workout_video_create_view(request,id=0): analysis = {'delay':delay} + if hascoordinates: + template = 'embedded_video.html' + else: + template = 'embedded_video_ote.html' + return render(request, - 'embedded_video.html', + template, { 'workout':w, 'rower':request.user.rower,