added a large map view
This commit is contained in:
@@ -686,6 +686,7 @@ def interactive_histoall(theworkouts):
|
|||||||
script, div = components(plot)
|
script, div = components(plot)
|
||||||
return [script,div]
|
return [script,div]
|
||||||
|
|
||||||
|
|
||||||
def leaflet_chart(lat,lon,name=""):
|
def leaflet_chart(lat,lon,name=""):
|
||||||
if lat.empty or lon.empty:
|
if lat.empty or lon.empty:
|
||||||
return [0,"invalid coordinate data"]
|
return [0,"invalid coordinate data"]
|
||||||
@@ -737,6 +738,14 @@ def leaflet_chart(lat,lon,name=""):
|
|||||||
layers: [streets, satellite]
|
layers: [streets, satellite]
|
||||||
}}).setView([{latmean},{lonmean}], 13);
|
}}).setView([{latmean},{lonmean}], 13);
|
||||||
|
|
||||||
|
var navionics = new JNC.Leaflet.NavionicsOverlay({{
|
||||||
|
navKey: 'Navionics_webapi_03205',
|
||||||
|
chartType: JNC.NAVIONICS_CHARTS.NAUTICAL,
|
||||||
|
isTransparent: true,
|
||||||
|
zIndex: 1
|
||||||
|
}});
|
||||||
|
|
||||||
|
|
||||||
var osmUrl2='http://tiles.openseamap.org/seamark/{{z}}/{{x}}/{{y}}.png';
|
var osmUrl2='http://tiles.openseamap.org/seamark/{{z}}/{{x}}/{{y}}.png';
|
||||||
var osmUrl='http://{{s}}.tile.openstreetmap.org/{{z}}/{{x}}/{{y}}.png';
|
var osmUrl='http://{{s}}.tile.openstreetmap.org/{{z}}/{{x}}/{{y}}.png';
|
||||||
|
|
||||||
@@ -751,6 +760,8 @@ def leaflet_chart(lat,lon,name=""):
|
|||||||
"Satellite": satellite,
|
"Satellite": satellite,
|
||||||
"Outdoors": outdoors,
|
"Outdoors": outdoors,
|
||||||
"Nautical": nautical,
|
"Nautical": nautical,
|
||||||
|
}},{{
|
||||||
|
"Navionics":navionics,
|
||||||
}}).addTo(mymap);
|
}}).addTo(mymap);
|
||||||
|
|
||||||
var marker = L.marker([{latbegin}, {longbegin}]).addTo(mymap);
|
var marker = L.marker([{latbegin}, {longbegin}]).addTo(mymap);
|
||||||
|
|||||||
@@ -6,57 +6,55 @@
|
|||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
<script type="text/javascript" src="/static/js/bokeh-0.12.3.min.js"></script>
|
<script type="text/javascript" src="/static/js/bokeh-0.12.3.min.js"></script>
|
||||||
<script async="true" type="text/javascript">
|
<script async="true" type="text/javascript">
|
||||||
Bokeh.set_log_level("info");
|
Bokeh.set_log_level("info");
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{{ interactiveplot |safe }}
|
{{ interactiveplot |safe }}
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
// Set things up to resize the plot on a window resize. You can play with
|
// Set things up to resize the plot on a window resize. You can play with
|
||||||
// the arguments of resize_width_height() to change the plot's behavior.
|
// the arguments of resize_width_height() to change the plot's behavior.
|
||||||
var plot_resize_setup = function () {
|
var plot_resize_setup = function () {
|
||||||
var plotid = Object.keys(Bokeh.index)[0]; // assume we have just one plot
|
var plotid = Object.keys(Bokeh.index)[0]; // assume we have just one plot
|
||||||
var plot = Bokeh.index[plotid];
|
var plot = Bokeh.index[plotid];
|
||||||
var plotresizer = function() {
|
var plotresizer = function() {
|
||||||
// arguments: use width, use height, maintain aspect ratio
|
// arguments: use width, use height, maintain aspect ratio
|
||||||
plot.resize_width_height(true, false, false);
|
plot.resize_width_height(true, false, false);
|
||||||
};
|
};
|
||||||
window.addEventListener('resize', plotresizer);
|
window.addEventListener('resize', plotresizer);
|
||||||
plotresizer();
|
plotresizer();
|
||||||
};
|
};
|
||||||
window.addEventListener('load', plot_resize_setup);
|
window.addEventListener('load', plot_resize_setup);
|
||||||
</script>
|
</script>
|
||||||
<style>
|
<style>
|
||||||
/* Need this to get the page in "desktop mode"; not having an infinite height.*/
|
/* Need this to get the page in "desktop mode"; not having an infinite height.*/
|
||||||
html, body {height: 100%; margin:5px;}
|
html, body {height: 100%; margin:5px;}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
||||||
<div id="workouts" class="grid_12 alpha">
|
<div id="workouts" class="grid_12 alpha">
|
||||||
|
|
||||||
|
|
||||||
<h1>Interactive Plot</h1>
|
<h1>Interactive Plot</h1>
|
||||||
|
|
||||||
{% if user.is_authenticated and mayedit %}
|
{% if user.is_authenticated and mayedit %}
|
||||||
<div class="grid_2 alpha">
|
<div class="grid_2 alpha">
|
||||||
<p>
|
<p>
|
||||||
<a class="button gray small" href="/rowers/workout/{{ workout.id }}/edit">Edit Workout</a>
|
<a class="button gray small" href="/rowers/workout/{{ workout.id }}/edit">Edit Workout</a>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid_2 suffix_2 omega">
|
<div class="grid_2 suffix_2 omega">
|
||||||
<p>
|
<p>
|
||||||
<a class="button gray small" href="/rowers/workout/{{ workout.id }}/advanced">Advanced Edit</a>
|
<a class="button gray small" href="/rowers/workout/{{ workout.id }}/advanced">Advanced Edit</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<div id="theplot" class="grid_12 alpha flexplot">
|
|
||||||
{{ the_div|safe }}
|
{{ the_div|safe }}
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
64
rowers/templates/map_view.html
Normal file
64
rowers/templates/map_view.html
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
{% load staticfiles %}
|
||||||
|
{% load rowerfilters %}
|
||||||
|
|
||||||
|
{% block title %}View Workout {% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<script type="text/javascript" src="/static/js/bokeh-0.12.3.min.js"></script>
|
||||||
|
<script async="true" type="text/javascript">
|
||||||
|
Bokeh.set_log_level("info");
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
<script>
|
||||||
|
// Set things up to resize the plot on a window resize. You can play with
|
||||||
|
// the arguments of resize_width_height() to change the plot's behavior.
|
||||||
|
var plot_resize_setup = function () {
|
||||||
|
var plotid = Object.keys(Bokeh.index)[0]; // assume we have just one plot
|
||||||
|
var plot = Bokeh.index[plotid];
|
||||||
|
var plotresizer = function() {
|
||||||
|
// arguments: use width, use height, maintain aspect ratio
|
||||||
|
plot.resize_width_height(true, false, false);
|
||||||
|
};
|
||||||
|
window.addEventListener('resize', plotresizer);
|
||||||
|
plotresizer();
|
||||||
|
};
|
||||||
|
window.addEventListener('load', plot_resize_setup);
|
||||||
|
</script>
|
||||||
|
<style>
|
||||||
|
/* Need this to get the page in "desktop mode"; not having an infinite height.*/
|
||||||
|
html, body {height: 100%; margin:5px;}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
|
||||||
|
<div id="workouts" class="grid_12 alpha">
|
||||||
|
|
||||||
|
|
||||||
|
<h1>Map View</h1>
|
||||||
|
|
||||||
|
{% if user.is_authenticated and mayedit %}
|
||||||
|
<div class="grid_2 alpha">
|
||||||
|
<p>
|
||||||
|
<a class="button gray small" href="/rowers/workout/{{ workout.id }}/edit">Edit Workout</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="grid_2 suffix_2 omega">
|
||||||
|
<p>
|
||||||
|
<a class="button gray small" href="/rowers/workout/{{ workout.id }}/advanced">Advanced Edit</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
<div id="theplot" class="grid_12 alpha flexplot">
|
||||||
|
{{ mapdiv|safe }}
|
||||||
|
|
||||||
|
|
||||||
|
{{ mapscript|safe }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
@@ -37,7 +37,12 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid_6 alpha">
|
<div class="grid_6 alpha">
|
||||||
<div class="grid_2 prefix_4 alpha">
|
<div class="grid_2 prefix_2 alpha">
|
||||||
|
<p>
|
||||||
|
<a class="button gray small" href="/rowers/workout/{{ workout.id }}/map">Map View</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="grid_2 omega">
|
||||||
<p>
|
<p>
|
||||||
<a class="button gray small" href="/rowers/workout/{{ workout.id }}/stats">Statistics</a>
|
<a class="button gray small" href="/rowers/workout/{{ workout.id }}/stats">Statistics</a>
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
@@ -188,6 +188,7 @@ urlpatterns = [
|
|||||||
url(r'^workout/compare/(?P<id>\d+)/(?P<startdatestring>\d+-\d+-\d+)/(?P<enddatestring>\w+.*)$',views.workout_comparison_list),
|
url(r'^workout/compare/(?P<id>\d+)/(?P<startdatestring>\d+-\d+-\d+)/(?P<enddatestring>\w+.*)$',views.workout_comparison_list),
|
||||||
url(r'^workout/(?P<id>\d+)/edit$',views.workout_edit_view),
|
url(r'^workout/(?P<id>\d+)/edit$',views.workout_edit_view),
|
||||||
url(r'^workout/(?P<id>\d+)/navionics$',views.workout_edit_view_navionics),
|
url(r'^workout/(?P<id>\d+)/navionics$',views.workout_edit_view_navionics),
|
||||||
|
url(r'^workout/(?P<id>\d+)/map$',views.workout_map_view),
|
||||||
url(r'^workout/(?P<id>\d+)/setprivate$',views.workout_setprivate_view),
|
url(r'^workout/(?P<id>\d+)/setprivate$',views.workout_setprivate_view),
|
||||||
url(r'^workout/(?P<id>\d+)/updatecp$',views.workout_update_cp_view),
|
url(r'^workout/(?P<id>\d+)/updatecp$',views.workout_update_cp_view),
|
||||||
url(r'^workout/(?P<id>\d+)/makepublic$',views.workout_makepublic_view),
|
url(r'^workout/(?P<id>\d+)/makepublic$',views.workout_makepublic_view),
|
||||||
|
|||||||
@@ -6405,6 +6405,56 @@ def workout_edit_view(request,id=0,message="",successmessage=""):
|
|||||||
|
|
||||||
return HttpResponseRedirect(url)
|
return HttpResponseRedirect(url)
|
||||||
|
|
||||||
|
@login_required()
|
||||||
|
def workout_map_view(request,id=0):
|
||||||
|
request.session[translation.LANGUAGE_SESSION_KEY] = USER_LANGUAGE
|
||||||
|
request.session['referer'] = absolute(request)['PATH']
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
# check if valid ID exists (workout exists)
|
||||||
|
row = Workout.objects.get(id=id)
|
||||||
|
except Workout.DoesNotExist:
|
||||||
|
raise Http404("Workout doesn't exist")
|
||||||
|
|
||||||
|
# create interactive plot
|
||||||
|
f1 = row.csvfilename
|
||||||
|
u = row.user.user
|
||||||
|
r = getrower(u)
|
||||||
|
rowdata = rdata(f1)
|
||||||
|
hascoordinates = 1
|
||||||
|
if rowdata != 0:
|
||||||
|
try:
|
||||||
|
latitude = rowdata.df[' latitude']
|
||||||
|
if not latitude.std():
|
||||||
|
hascoordinates = 0
|
||||||
|
except KeyError,AttributeError:
|
||||||
|
hascoordinates = 0
|
||||||
|
|
||||||
|
else:
|
||||||
|
hascoordinates = 0
|
||||||
|
|
||||||
|
|
||||||
|
if hascoordinates:
|
||||||
|
mapscript,mapdiv = leaflet_chart2(rowdata.df[' latitude'],
|
||||||
|
rowdata.df[' longitude'],
|
||||||
|
row.name)
|
||||||
|
mayedit=0
|
||||||
|
if not request.user.is_anonymous():
|
||||||
|
r = getrower(request.user)
|
||||||
|
result = request.user.is_authenticated() and ispromember(request.user)
|
||||||
|
if result:
|
||||||
|
promember=1
|
||||||
|
if request.user == row.user.user:
|
||||||
|
mayedit=1
|
||||||
|
|
||||||
|
return render(request, 'map_view.html',
|
||||||
|
{'mapscript':mapscript,
|
||||||
|
'workout':row,
|
||||||
|
'mapdiv':mapdiv,
|
||||||
|
'mayedit':mayedit,
|
||||||
|
})
|
||||||
|
|
||||||
# The basic edit page
|
# The basic edit page
|
||||||
@login_required()
|
@login_required()
|
||||||
def workout_edit_view_navionics(request,id=0,message="",successmessage=""):
|
def workout_edit_view_navionics(request,id=0,message="",successmessage=""):
|
||||||
|
|||||||
Reference in New Issue
Block a user