adding video charts
This commit is contained in:
@@ -2211,8 +2211,13 @@ def course_map(course):
|
|||||||
|
|
||||||
|
|
||||||
def leaflet_chart(lat, lon, name="", raceresult=0):
|
def leaflet_chart(lat, lon, name="", raceresult=0):
|
||||||
if lat.empty or lon.empty: # pragma: no cover
|
try:
|
||||||
return [0, "invalid coordinate data"]
|
if lat.empty or lon.empty: # pragma: no cover
|
||||||
|
return [0, "invalid coordinate data"]
|
||||||
|
except AttributeError:
|
||||||
|
if not len(lat) or not len(lon): # pragma: no cover
|
||||||
|
return [0, "invalid coordinate data"]
|
||||||
|
|
||||||
|
|
||||||
# Throw out 0,0
|
# Throw out 0,0
|
||||||
df = pd.DataFrame({
|
df = pd.DataFrame({
|
||||||
@@ -2286,56 +2291,9 @@ def leaflet_chart_compare(course, workoutids, labeldict={}, startenddict={}):
|
|||||||
except ValueError: # pragma: no cover
|
except ValueError: # pragma: no cover
|
||||||
df = pd.DataFrame()
|
df = pd.DataFrame()
|
||||||
|
|
||||||
mapdata = {
|
|
||||||
'trajectories': df.reset_index().to_json()
|
|
||||||
}
|
|
||||||
|
|
||||||
latmean, lonmean, coordinates = course_coord_center(course)
|
latmean, lonmean, coordinates = course_coord_center(course)
|
||||||
lat_min, lat_max, long_min, long_max = course_coord_maxmin(course)
|
|
||||||
|
|
||||||
coordinates = course_spline(coordinates)
|
course_dict = GeoCourseSerializer(course).data
|
||||||
|
|
||||||
polygons = GeoPolygon.objects.filter(
|
|
||||||
course=course).order_by("order_in_course")
|
|
||||||
|
|
||||||
plabels = ''
|
|
||||||
|
|
||||||
for p in polygons:
|
|
||||||
coords = polygon_coord_center(p)
|
|
||||||
|
|
||||||
plabels += """
|
|
||||||
var marker = L.marker([{latbegin}, {longbegin}]).addTo(mymap);
|
|
||||||
marker.bindPopup("<b>{name}</b>");
|
|
||||||
|
|
||||||
""".format(
|
|
||||||
latbegin=coords[0],
|
|
||||||
longbegin=coords[1],
|
|
||||||
name=p.name
|
|
||||||
)
|
|
||||||
|
|
||||||
pcoordinates = """[
|
|
||||||
"""
|
|
||||||
|
|
||||||
for p in polygons:
|
|
||||||
pcoordinates += """[
|
|
||||||
["""
|
|
||||||
|
|
||||||
points = GeoPoint.objects.filter(polygon=p).order_by("order_in_poly")
|
|
||||||
|
|
||||||
for pt in points:
|
|
||||||
pcoordinates += "[{x},{y}],".format(
|
|
||||||
x=pt.latitude,
|
|
||||||
y=pt.longitude
|
|
||||||
)
|
|
||||||
|
|
||||||
# remove last comma
|
|
||||||
pcoordinates = pcoordinates[:-1]
|
|
||||||
pcoordinates += """]
|
|
||||||
],
|
|
||||||
"""
|
|
||||||
|
|
||||||
pcoordinates += """
|
|
||||||
]"""
|
|
||||||
|
|
||||||
# Throw out 0,0
|
# Throw out 0,0
|
||||||
df = df.replace(0, np.nan)
|
df = df.replace(0, np.nan)
|
||||||
@@ -2357,89 +2315,7 @@ def leaflet_chart_compare(course, workoutids, labeldict={}, startenddict={}):
|
|||||||
except AttributeError:
|
except AttributeError:
|
||||||
items = zip(workoutids, colors)
|
items = zip(workoutids, colors)
|
||||||
|
|
||||||
script = """
|
trajectories = []
|
||||||
<script>
|
|
||||||
|
|
||||||
var streets = L.tileLayer(
|
|
||||||
'https://api.mapbox.com/styles/v1/{{id}}/tiles/{{z}}/{{x}}/{{y}}?access_token={{accessToken}}', {{
|
|
||||||
attribution: '© <a href="https://www.mapbox.com/about/maps/">Mapbox</a> © <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> <strong><a href="https://www.mapbox.com/map-feedback/" target="_blank">Improve this map</a></strong>',
|
|
||||||
tileSize: 512,
|
|
||||||
maxZoom: 18,
|
|
||||||
zoomOffset: -1,
|
|
||||||
id: 'mapbox/streets-v11',
|
|
||||||
accessToken: 'pk.eyJ1Ijoic2FuZGVycm9vc2VuZGFhbCIsImEiOiJjajY3aTRkeWQwNmx6MzJvMTN3andlcnBlIn0.MFG8Xt0kDeSA9j7puZQ9hA'
|
|
||||||
}}
|
|
||||||
),
|
|
||||||
|
|
||||||
|
|
||||||
satellite = L.tileLayer(
|
|
||||||
'https://api.mapbox.com/styles/v1/{{id}}/tiles/{{z}}/{{x}}/{{y}}?access_token={{accessToken}}', {{
|
|
||||||
attribution: '© <a href="https://www.mapbox.com/about/maps/">Mapbox</a> © <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> <strong><a href="https://www.mapbox.com/map-feedback/" target="_blank">Improve this map</a></strong>',
|
|
||||||
tileSize: 512,
|
|
||||||
maxZoom: 18,
|
|
||||||
zoomOffset: -1,
|
|
||||||
id: 'mapbox/satellite-v9',
|
|
||||||
accessToken: 'pk.eyJ1Ijoic2FuZGVycm9vc2VuZGFhbCIsImEiOiJjajY3aTRkeWQwNmx6MzJvMTN3andlcnBlIn0.MFG8Xt0kDeSA9j7puZQ9hA'
|
|
||||||
}}
|
|
||||||
),
|
|
||||||
|
|
||||||
outdoors = L.tileLayer(
|
|
||||||
'https://api.mapbox.com/styles/v1/{{id}}/tiles/{{z}}/{{x}}/{{y}}?access_token={{accessToken}}', {{
|
|
||||||
attribution: '© <a href="https://www.mapbox.com/about/maps/">Mapbox</a> © <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> <strong><a href="https://www.mapbox.com/map-feedback/" target="_blank">Improve this map</a></strong>',
|
|
||||||
tileSize: 512,
|
|
||||||
maxZoom: 18,
|
|
||||||
zoomOffset: -1,
|
|
||||||
id: 'mapbox/outdoors-v11',
|
|
||||||
accessToken: 'pk.eyJ1Ijoic2FuZGVycm9vc2VuZGFhbCIsImEiOiJjajY3aTRkeWQwNmx6MzJvMTN3andlcnBlIn0.MFG8Xt0kDeSA9j7puZQ9hA'
|
|
||||||
}}
|
|
||||||
);
|
|
||||||
|
|
||||||
var navionics = new JNC.Leaflet.NavionicsOverlay({{
|
|
||||||
navKey: 'Navionics_webapi_03205',
|
|
||||||
chartType: JNC.NAVIONICS_CHARTS.NAUTICAL,
|
|
||||||
isTransparent: true,
|
|
||||||
zIndex: 1
|
|
||||||
}});
|
|
||||||
|
|
||||||
var mymap = L.map('map_canvas', {{
|
|
||||||
center: [{latmean}, {lonmean}],
|
|
||||||
zoom: 13,
|
|
||||||
layers: [outdoors]
|
|
||||||
}}).setView([{latmean},{lonmean}], 13);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var osmUrl2='http://tiles.openseamap.org/seamark/{{z}}/{{x}}/{{y}}.png';
|
|
||||||
var osmUrl='http://{{s}}.tile.openstreetmap.org/{{z}}/{{x}}/{{y}}.png';
|
|
||||||
|
|
||||||
|
|
||||||
//create two TileLayer
|
|
||||||
var nautical=new L.TileLayer(osmUrl,{{
|
|
||||||
maxZoom:18}});
|
|
||||||
|
|
||||||
|
|
||||||
L.control.layers({{
|
|
||||||
"Streets": streets,
|
|
||||||
"Satellite": satellite,
|
|
||||||
"Outdoors": outdoors,
|
|
||||||
"Nautical": nautical,
|
|
||||||
}},{{
|
|
||||||
"Navionics":navionics,
|
|
||||||
}}).addTo(mymap);
|
|
||||||
|
|
||||||
|
|
||||||
var platlongs = {pcoordinates}
|
|
||||||
var polygons = L.polygon(platlongs, {{color:'blue'}}).addTo(mymap)
|
|
||||||
|
|
||||||
{plabels}
|
|
||||||
|
|
||||||
""".format(
|
|
||||||
latmean=latmean,
|
|
||||||
lonmean=lonmean,
|
|
||||||
pcoordinates=pcoordinates,
|
|
||||||
plabels=plabels,
|
|
||||||
)
|
|
||||||
|
|
||||||
for id, color in items:
|
for id, color in items:
|
||||||
group = df[df['workoutid'] == int(id)].copy()
|
group = df[df['workoutid'] == int(id)].copy()
|
||||||
@@ -2466,311 +2342,29 @@ var navionics = new JNC.Leaflet.NavionicsOverlay({{
|
|||||||
lat = group['lat'].dropna()
|
lat = group['lat'].dropna()
|
||||||
lon = group['lon'].dropna()
|
lon = group['lon'].dropna()
|
||||||
|
|
||||||
coordinates = zip(lat, lon)
|
coordinates = zip(lat, lon)
|
||||||
|
|
||||||
scoordinates = "["
|
trajectory_dict = {
|
||||||
for x, y in coordinates:
|
'coordinates' :[{'latitude':c[0], 'longitude': c[1]} for c in list(coordinates)],
|
||||||
scoordinates += """[{x},{y}],
|
'color': color,
|
||||||
""".format(x=x, y=y)
|
'label': label,
|
||||||
scoordinates += "]"
|
}
|
||||||
|
|
||||||
if not group.empty:
|
trajectories.append(trajectory_dict)
|
||||||
script += """
|
|
||||||
var latlongs = {scoordinates}
|
|
||||||
var polyline = L.polyline(latlongs, {{color:'{color}'}}).addTo(mymap)
|
|
||||||
polyline.bindPopup("<b>{label}</b>",{{ autoPan: false, autoClose: false }}).openPopup()
|
|
||||||
polyline.on('mouseover',function(ev) {{
|
|
||||||
ev.target.openPopup();
|
|
||||||
}});
|
|
||||||
polyline.on('dblclick', function (e) {{
|
|
||||||
mymap.removeLayer(this);
|
|
||||||
}});
|
|
||||||
mymap.fitBounds(polyline.getBounds())
|
|
||||||
""".format(
|
|
||||||
scoordinates=scoordinates,
|
|
||||||
color=color,
|
|
||||||
label=label,
|
|
||||||
)
|
|
||||||
|
|
||||||
script += """
|
mapdata = {
|
||||||
|
'course': course_dict,
|
||||||
</script>
|
'latmean': latmean,
|
||||||
"""
|
'lonmean': lonmean,
|
||||||
|
'trajectories': trajectories,
|
||||||
div = """
|
}
|
||||||
<div id="map_canvas" style="width: 100%; height: 100%; min-height: 100vh"><p> </p></div>
|
|
||||||
"""
|
script, div = get_chart("/mapcompare", mapdata)
|
||||||
|
|
||||||
return script, div
|
return script, div
|
||||||
|
|
||||||
|
|
||||||
def leaflet_chart2(lat, lon, name=""):
|
|
||||||
if lat.empty or lon.empty: # pragma: no cover
|
|
||||||
return [0, "invalid coordinate data"]
|
|
||||||
|
|
||||||
# Throw out 0,0
|
|
||||||
df = pd.DataFrame({
|
|
||||||
'lat': lat,
|
|
||||||
'lon': lon
|
|
||||||
})
|
|
||||||
|
|
||||||
df = df.replace(0, np.nan)
|
|
||||||
df = df.loc[(df != 0).any(axis=1)]
|
|
||||||
df.fillna(method='bfill', axis=0, inplace=True)
|
|
||||||
df.fillna(method='ffill', axis=0, inplace=True)
|
|
||||||
lat = df['lat']
|
|
||||||
lon = df['lon']
|
|
||||||
if lat.empty or lon.empty: # pragma: no cover
|
|
||||||
return [0, "invalid coordinate data"]
|
|
||||||
|
|
||||||
latmean = lat.mean()
|
|
||||||
lonmean = lon.mean()
|
|
||||||
latbegin = lat[lat.index[0]]
|
|
||||||
longbegin = lon[lon.index[0]]
|
|
||||||
latend = lat[lat.index[-1]]
|
|
||||||
longend = lon[lon.index[-1]]
|
|
||||||
|
|
||||||
coordinates = zip(lat, lon)
|
|
||||||
|
|
||||||
scoordinates = "["
|
|
||||||
|
|
||||||
for x, y in coordinates:
|
|
||||||
scoordinates += """[{x},{y}],
|
|
||||||
""".format(
|
|
||||||
x=x,
|
|
||||||
y=y
|
|
||||||
)
|
|
||||||
|
|
||||||
scoordinates += "]"
|
|
||||||
|
|
||||||
script = """
|
|
||||||
<script>
|
|
||||||
|
|
||||||
var streets = L.tileLayer(
|
|
||||||
'https://api.mapbox.com/styles/v1/{{id}}/tiles/{{z}}/{{x}}/{{y}}?access_token={{accessToken}}', {{
|
|
||||||
attribution: '© <a href="https://www.mapbox.com/about/maps/">Mapbox</a> © <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> <strong><a href="https://www.mapbox.com/map-feedback/" target="_blank">Improve this map</a></strong>',
|
|
||||||
tileSize: 512,
|
|
||||||
maxZoom: 18,
|
|
||||||
zoomOffset: -1,
|
|
||||||
id: 'mapbox/streets-v11',
|
|
||||||
accessToken: 'pk.eyJ1Ijoic2FuZGVycm9vc2VuZGFhbCIsImEiOiJjajY3aTRkeWQwNmx6MzJvMTN3andlcnBlIn0.MFG8Xt0kDeSA9j7puZQ9hA'
|
|
||||||
}}
|
|
||||||
),
|
|
||||||
|
|
||||||
|
|
||||||
satellite = L.tileLayer(
|
|
||||||
'https://api.mapbox.com/styles/v1/{{id}}/tiles/{{z}}/{{x}}/{{y}}?access_token={{accessToken}}', {{
|
|
||||||
attribution: '© <a href="https://www.mapbox.com/about/maps/">Mapbox</a> © <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> <strong><a href="https://www.mapbox.com/map-feedback/" target="_blank">Improve this map</a></strong>',
|
|
||||||
tileSize: 512,
|
|
||||||
maxZoom: 18,
|
|
||||||
zoomOffset: -1,
|
|
||||||
id: 'mapbox/satellite-v9',
|
|
||||||
accessToken: 'pk.eyJ1Ijoic2FuZGVycm9vc2VuZGFhbCIsImEiOiJjajY3aTRkeWQwNmx6MzJvMTN3andlcnBlIn0.MFG8Xt0kDeSA9j7puZQ9hA'
|
|
||||||
}}
|
|
||||||
),
|
|
||||||
|
|
||||||
outdoors = L.tileLayer(
|
|
||||||
'https://api.mapbox.com/styles/v1/{{id}}/tiles/{{z}}/{{x}}/{{y}}?access_token={{accessToken}}', {{
|
|
||||||
attribution: '© <a href="https://www.mapbox.com/about/maps/">Mapbox</a> © <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> <strong><a href="https://www.mapbox.com/map-feedback/" target="_blank">Improve this map</a></strong>',
|
|
||||||
tileSize: 512,
|
|
||||||
maxZoom: 18,
|
|
||||||
zoomOffset: -1,
|
|
||||||
id: 'mapbox/outdoors-v11',
|
|
||||||
accessToken: 'pk.eyJ1Ijoic2FuZGVycm9vc2VuZGFhbCIsImEiOiJjajY3aTRkeWQwNmx6MzJvMTN3andlcnBlIn0.MFG8Xt0kDeSA9j7puZQ9hA'
|
|
||||||
}}
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var mymap = L.map('map_canvas', {{
|
|
||||||
center: [{latmean}, {lonmean}],
|
|
||||||
zoom: 13,
|
|
||||||
layers: [streets, satellite]
|
|
||||||
}}).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 osmUrl='http://{{s}}.tile.openstreetmap.org/{{z}}/{{x}}/{{y}}.png';
|
|
||||||
|
|
||||||
|
|
||||||
//create two TileLayer
|
|
||||||
var nautical=new L.TileLayer(osmUrl,{{
|
|
||||||
maxZoom:18}});
|
|
||||||
|
|
||||||
|
|
||||||
L.control.layers({{
|
|
||||||
"Streets": streets,
|
|
||||||
"Satellite": satellite,
|
|
||||||
"Outdoors": outdoors,
|
|
||||||
"Nautical": nautical,
|
|
||||||
}},{{
|
|
||||||
"Navionics":navionics,
|
|
||||||
}}).addTo(mymap);
|
|
||||||
|
|
||||||
var marker = L.marker([{latbegin}, {longbegin}]).addTo(mymap);
|
|
||||||
marker.bindPopup("<b>Start</b>");
|
|
||||||
var emarker = new L.marker([{latend}, {longend}]).addTo(mymap);
|
|
||||||
emarker.bindPopup("<b>End</b>");
|
|
||||||
|
|
||||||
var latlongs = {scoordinates}
|
|
||||||
var polyline = L.polyline(latlongs, {{color:'red'}}).addTo(mymap)
|
|
||||||
mymap.fitBounds(polyline.getBounds())
|
|
||||||
|
|
||||||
</script>
|
|
||||||
""".format(
|
|
||||||
latmean=latmean,
|
|
||||||
lonmean=lonmean,
|
|
||||||
latbegin=latbegin,
|
|
||||||
latend=latend,
|
|
||||||
longbegin=longbegin,
|
|
||||||
longend=longend,
|
|
||||||
scoordinates=scoordinates,
|
|
||||||
)
|
|
||||||
|
|
||||||
div = """
|
|
||||||
<div id="map_canvas" style="width: 100%; height: 100%; min-height: 100vh"><p> </p></div>
|
|
||||||
"""
|
|
||||||
|
|
||||||
return script, div
|
|
||||||
|
|
||||||
|
|
||||||
def leaflet_chart_video(lat, lon, name=""):
|
|
||||||
if not len(lat) or not len(lon): # pragma: no cover
|
|
||||||
return [0, "invalid coordinate data"]
|
|
||||||
|
|
||||||
# Throw out 0,0
|
|
||||||
df = pd.DataFrame({
|
|
||||||
'lat': lat,
|
|
||||||
'lon': lon
|
|
||||||
})
|
|
||||||
|
|
||||||
df = df.replace(0, np.nan)
|
|
||||||
df = df.loc[(df != 0).any(axis=1)]
|
|
||||||
df.fillna(method='bfill', axis=0, inplace=True)
|
|
||||||
df.fillna(method='ffill', axis=0, inplace=True)
|
|
||||||
lat = df['lat']
|
|
||||||
lon = df['lon']
|
|
||||||
if lat.empty or lon.empty: # pragma: no cover
|
|
||||||
return [0, "invalid coordinate data"]
|
|
||||||
|
|
||||||
latmean = lat.mean()
|
|
||||||
lonmean = lon.mean()
|
|
||||||
latbegin = lat[lat.index[0]]
|
|
||||||
longbegin = lon[lon.index[0]]
|
|
||||||
|
|
||||||
coordinates = zip(lat, lon)
|
|
||||||
|
|
||||||
scoordinates = "["
|
|
||||||
|
|
||||||
for x, y in coordinates:
|
|
||||||
scoordinates += """[{x},{y}],
|
|
||||||
""".format(
|
|
||||||
x=x,
|
|
||||||
y=y
|
|
||||||
)
|
|
||||||
|
|
||||||
scoordinates += "]"
|
|
||||||
|
|
||||||
script = """
|
|
||||||
|
|
||||||
|
|
||||||
var streets = L.tileLayer(
|
|
||||||
'https://api.mapbox.com/styles/v1/{{id}}/tiles/{{z}}/{{x}}/{{y}}?access_token={{accessToken}}', {{
|
|
||||||
attribution: '© <a href="https://www.mapbox.com/about/maps/">Mapbox</a> © <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> <strong><a href="https://www.mapbox.com/map-feedback/" target="_blank">Improve this map</a></strong>',
|
|
||||||
tileSize: 512,
|
|
||||||
maxZoom: 18,
|
|
||||||
zoomOffset: -1,
|
|
||||||
id: 'mapbox/streets-v11',
|
|
||||||
accessToken: 'pk.eyJ1Ijoic2FuZGVycm9vc2VuZGFhbCIsImEiOiJjajY3aTRkeWQwNmx6MzJvMTN3andlcnBlIn0.MFG8Xt0kDeSA9j7puZQ9hA'
|
|
||||||
}}
|
|
||||||
),
|
|
||||||
|
|
||||||
satellite = L.tileLayer(
|
|
||||||
'https://api.mapbox.com/styles/v1/{{id}}/tiles/{{z}}/{{x}}/{{y}}?access_token={{accessToken}}', {{
|
|
||||||
attribution: '© <a href="https://www.mapbox.com/about/maps/">Mapbox</a> © <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> <strong><a href="https://www.mapbox.com/map-feedback/" target="_blank">Improve this map</a></strong>',
|
|
||||||
tileSize: 512,
|
|
||||||
maxZoom: 18,
|
|
||||||
zoomOffset: -1,
|
|
||||||
id: 'mapbox/satellite-v9',
|
|
||||||
accessToken: 'pk.eyJ1Ijoic2FuZGVycm9vc2VuZGFhbCIsImEiOiJjajY3aTRkeWQwNmx6MzJvMTN3andlcnBlIn0.MFG8Xt0kDeSA9j7puZQ9hA'
|
|
||||||
}}
|
|
||||||
),
|
|
||||||
|
|
||||||
outdoors = L.tileLayer(
|
|
||||||
'https://api.mapbox.com/styles/v1/{{id}}/tiles/{{z}}/{{x}}/{{y}}?access_token={{accessToken}}', {{
|
|
||||||
attribution: '© <a href="https://www.mapbox.com/about/maps/">Mapbox</a> © <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> <strong><a href="https://www.mapbox.com/map-feedback/" target="_blank">Improve this map</a></strong>',
|
|
||||||
tileSize: 512,
|
|
||||||
maxZoom: 18,
|
|
||||||
zoomOffset: -1,
|
|
||||||
id: 'mapbox/outdoors-v11',
|
|
||||||
accessToken: 'pk.eyJ1Ijoic2FuZGVycm9vc2VuZGFhbCIsImEiOiJjajY3aTRkeWQwNmx6MzJvMTN3andlcnBlIn0.MFG8Xt0kDeSA9j7puZQ9hA'
|
|
||||||
}}
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var mymap = L.map('map_canvas', {{
|
|
||||||
center: [{latmean}, {lonmean}],
|
|
||||||
zoom: 13,
|
|
||||||
layers: [streets, satellite]
|
|
||||||
}}).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 osmUrl='http://{{s}}.tile.openstreetmap.org/{{z}}/{{x}}/{{y}}.png';
|
|
||||||
|
|
||||||
|
|
||||||
//create two TileLayer
|
|
||||||
var nautical=new L.TileLayer(osmUrl,{{
|
|
||||||
maxZoom:18}});
|
|
||||||
|
|
||||||
|
|
||||||
L.control.layers({{
|
|
||||||
"Streets": streets,
|
|
||||||
"Satellite": satellite,
|
|
||||||
"Outdoors": outdoors,
|
|
||||||
"Nautical": nautical,
|
|
||||||
}},{{
|
|
||||||
"Navionics":navionics,
|
|
||||||
}},
|
|
||||||
{{
|
|
||||||
position:'topleft'
|
|
||||||
}}).addTo(mymap);
|
|
||||||
|
|
||||||
var marker = L.marker([{latbegin}, {longbegin}]).addTo(mymap);
|
|
||||||
marker.bindPopup("<b>Start</b>");
|
|
||||||
|
|
||||||
var latlongs = {scoordinates}
|
|
||||||
var polyline = L.polyline(latlongs, {{color:'red'}}).addTo(mymap)
|
|
||||||
mymap.fitBounds(polyline.getBounds())
|
|
||||||
|
|
||||||
""".format(
|
|
||||||
latmean=latmean,
|
|
||||||
lonmean=lonmean,
|
|
||||||
latbegin=latbegin,
|
|
||||||
longbegin=longbegin,
|
|
||||||
scoordinates=scoordinates,
|
|
||||||
)
|
|
||||||
|
|
||||||
div = """
|
|
||||||
<div id="map_canvas" style="width: 640px; height: 390px;"><p> </p></div>
|
|
||||||
"""
|
|
||||||
|
|
||||||
return script, div
|
|
||||||
|
|
||||||
|
|
||||||
def interactive_agegroupcpchart(age, normalized=False):
|
def interactive_agegroupcpchart(age, normalized=False):
|
||||||
@@ -4272,12 +3866,10 @@ def interactive_chart_video(videodata):
|
|||||||
|
|
||||||
data = zip(time, spm)
|
data = zip(time, spm)
|
||||||
|
|
||||||
data2 = "["
|
data2 = []
|
||||||
|
|
||||||
for t, s in data:
|
for t, s in data:
|
||||||
data2 += "{x: %s, y: %s}, " % (t, s)
|
data2.append( {'x': t, 'y': s})
|
||||||
|
|
||||||
data2 = data2[:-2] + "]"
|
|
||||||
|
|
||||||
markerpoint = {
|
markerpoint = {
|
||||||
'x': time[0],
|
'x': time[0],
|
||||||
@@ -4285,89 +3877,13 @@ def interactive_chart_video(videodata):
|
|||||||
'r': 10,
|
'r': 10,
|
||||||
}
|
}
|
||||||
|
|
||||||
div = """
|
chart_data = {
|
||||||
<canvas id="myChart">
|
'data': data2,
|
||||||
</canvas>
|
'markerpoint': markerpoint,
|
||||||
"""
|
|
||||||
|
|
||||||
script = """
|
|
||||||
var ctx = document.getElementById("myChart").getContext('2d');
|
|
||||||
var data = %s
|
|
||||||
|
|
||||||
var myChart = new Chart(ctx, {
|
|
||||||
type: 'scatter',
|
|
||||||
label: 'SPM',
|
|
||||||
animationSteps: 10,
|
|
||||||
options: {
|
|
||||||
legend: {
|
|
||||||
display: false,
|
|
||||||
},
|
|
||||||
animation: {
|
|
||||||
duration: 100,
|
|
||||||
},
|
|
||||||
scales: {
|
|
||||||
yAxes: [{
|
|
||||||
scaleLabel: {
|
|
||||||
display: true,
|
|
||||||
labelString: 'Stroke Rate'
|
|
||||||
}
|
|
||||||
}],
|
|
||||||
xAxes: [{
|
|
||||||
scaleLabel: {
|
|
||||||
type: 'linear',
|
|
||||||
display: true,
|
|
||||||
labelString: 'Time (seconds)'
|
|
||||||
}
|
|
||||||
}],
|
|
||||||
}
|
|
||||||
},
|
|
||||||
data:
|
|
||||||
{
|
|
||||||
datasets: [
|
|
||||||
{
|
|
||||||
type: 'bubble',
|
|
||||||
label: 'now',
|
|
||||||
data: [ %s ],
|
|
||||||
backgroundColor: '#36a2eb',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'spm',
|
|
||||||
data: data,
|
|
||||||
backgroundColor: "#ff0000",
|
|
||||||
borderColor: "#ff0000",
|
|
||||||
fill: false,
|
|
||||||
borderDash: [0, 0],
|
|
||||||
pointRadius: 1,
|
|
||||||
pointHoverRadius: 1,
|
|
||||||
showLine: true,
|
|
||||||
tension: 0,
|
|
||||||
},
|
|
||||||
|
|
||||||
]
|
|
||||||
},
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
var marker = {
|
|
||||||
datapoint: %s ,
|
|
||||||
setLatLng: function (LatLng) {
|
|
||||||
var lat = LatLng.lat;
|
|
||||||
var lng = LatLng.lng;
|
|
||||||
this.datapoint = {
|
|
||||||
'x': lat,
|
|
||||||
'y': lng,
|
|
||||||
'r': 10,
|
|
||||||
}
|
|
||||||
myChart.data.datasets[0].data[0] = this.datapoint;
|
|
||||||
myChart.update();
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
marker.setLatLng({
|
|
||||||
'lat': data[0]['x'],
|
|
||||||
'lng': data[0]['y']
|
|
||||||
})
|
|
||||||
|
|
||||||
""" % (data2, markerpoint, markerpoint)
|
|
||||||
|
script, div = get_chart("/videochart", chart_data)
|
||||||
|
|
||||||
return [script, div]
|
return [script, div]
|
||||||
|
|
||||||
|
|||||||
@@ -32,8 +32,9 @@
|
|||||||
<div class="mapdiv">
|
<div class="mapdiv">
|
||||||
{{ mapdiv|safe }}
|
{{ mapdiv|safe }}
|
||||||
|
|
||||||
|
<script>
|
||||||
{{ mapscript|safe }}
|
{{ mapscript|safe }}
|
||||||
|
</script>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
|||||||
@@ -37,8 +37,9 @@
|
|||||||
<div class="mapdiv">
|
<div class="mapdiv">
|
||||||
{{ mapdiv|safe }}
|
{{ mapdiv|safe }}
|
||||||
|
|
||||||
|
<script>
|
||||||
{{ mapscript|safe }}
|
{{ mapscript|safe }}
|
||||||
|
</script>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -45,7 +45,9 @@
|
|||||||
<li class="grid_4">
|
<li class="grid_4">
|
||||||
<div class="mapdiv">
|
<div class="mapdiv">
|
||||||
{{ mapdiv|safe }}
|
{{ mapdiv|safe }}
|
||||||
{{ mapscript|safe }}
|
<script>
|
||||||
|
{{ mapscript|safe }}
|
||||||
|
</script>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -39,8 +39,9 @@
|
|||||||
<div class="mapdiv">
|
<div class="mapdiv">
|
||||||
{{ mapdiv|safe }}
|
{{ mapdiv|safe }}
|
||||||
|
|
||||||
|
<script>
|
||||||
{{ mapscript|safe }}
|
{{ mapscript|safe }}
|
||||||
|
</script>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
{% if records %}
|
{% if records %}
|
||||||
|
|||||||
@@ -19,7 +19,9 @@
|
|||||||
<h1>{{ course.name }}</h1>
|
<h1>{{ course.name }}</h1>
|
||||||
<div class="mapdiv">
|
<div class="mapdiv">
|
||||||
{{ mapdiv|safe }}
|
{{ mapdiv|safe }}
|
||||||
{{ mapscript|safe }}
|
<script>
|
||||||
|
{{ mapscript|safe }}
|
||||||
|
</script>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -26,8 +26,9 @@
|
|||||||
<div style="height:100%;" id="theplot" class="flexplot mapdiv">
|
<div style="height:100%;" id="theplot" class="flexplot mapdiv">
|
||||||
{{ mapdiv|safe }}
|
{{ mapdiv|safe }}
|
||||||
|
|
||||||
|
<script>
|
||||||
{{ mapscript|safe }}
|
{{ mapscript|safe }}
|
||||||
|
</script>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,9 @@
|
|||||||
|
|
||||||
<div class="mapdiv">
|
<div class="mapdiv">
|
||||||
{{ mapdiv|safe }}
|
{{ mapdiv|safe }}
|
||||||
{{ mapscript|safe }}
|
<script>
|
||||||
|
{{ mapscript|safe }}
|
||||||
|
</script>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -11,8 +11,10 @@
|
|||||||
Bokeh.set_log_level("info");
|
Bokeh.set_log_level("info");
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<script>
|
||||||
{{ interactiveplot |safe }}
|
{{ interactiveplot |safe }}
|
||||||
|
</script>
|
||||||
|
|
||||||
<h1>Interactive Comparison</h1>
|
<h1>Interactive Comparison</h1>
|
||||||
|
|
||||||
<form enctype="multipart/form-data" action="" method="post">
|
<form enctype="multipart/form-data" action="" method="post">
|
||||||
|
|||||||
@@ -3,8 +3,9 @@
|
|||||||
<div class="mapdiv">
|
<div class="mapdiv">
|
||||||
{{ mapdiv|safe }}
|
{{ mapdiv|safe }}
|
||||||
|
|
||||||
|
<script>
|
||||||
{{ mapscript|safe }}
|
{{ mapscript|safe }}
|
||||||
|
</script>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -67,7 +67,9 @@
|
|||||||
<div class="mapdiv">
|
<div class="mapdiv">
|
||||||
|
|
||||||
{{ gmapdiv |safe }}
|
{{ gmapdiv |safe }}
|
||||||
{{ gmap |safe }}
|
<script>
|
||||||
|
{{ gmap |safe }}
|
||||||
|
</script>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -217,9 +217,9 @@
|
|||||||
<div class="mapdiv">
|
<div class="mapdiv">
|
||||||
{{ mapdiv|safe }}
|
{{ mapdiv|safe }}
|
||||||
</div>
|
</div>
|
||||||
|
<script>
|
||||||
{{ mapscript|safe }}
|
{{ mapscript|safe }}
|
||||||
|
</script>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% for graph in graphs %}
|
{% for graph in graphs %}
|
||||||
|
|||||||
@@ -131,8 +131,9 @@
|
|||||||
|
|
||||||
{{ mapdiv|safe }}
|
{{ mapdiv|safe }}
|
||||||
|
|
||||||
|
<script>
|
||||||
{{ mapscript|safe }}
|
{{ mapscript|safe }}
|
||||||
|
</script>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
@@ -126,8 +126,7 @@ def workout_video_view_mini(request, id=''):
|
|||||||
hascoordinates = pd.Series(data['latitude']).std() > 0
|
hascoordinates = pd.Series(data['latitude']).std() > 0
|
||||||
# create map
|
# create map
|
||||||
if hascoordinates and mode == 'water':
|
if hascoordinates and mode == 'water':
|
||||||
mapscript, mapdiv = leaflet_chart_video(data['latitude'], data['longitude'],
|
mapscript, mapdiv = leaflet_chart(data['latitude'], data['longitude'])
|
||||||
w.name)
|
|
||||||
else:
|
else:
|
||||||
mapscript, mapdiv = interactive_chart_video(data)
|
mapscript, mapdiv = interactive_chart_video(data)
|
||||||
data['longitude'] = data['spm']
|
data['longitude'] = data['spm']
|
||||||
@@ -237,8 +236,7 @@ def workout_video_view(request, id=''):
|
|||||||
hascoordinates = pd.Series(data['latitude']).std() > 0
|
hascoordinates = pd.Series(data['latitude']).std() > 0
|
||||||
# create map
|
# create map
|
||||||
if hascoordinates and mode == 'water':
|
if hascoordinates and mode == 'water':
|
||||||
mapscript, mapdiv = leaflet_chart_video(data['latitude'], data['longitude'],
|
mapscript, mapdiv = leaflet_chart(data['latitude'], data['longitude'])
|
||||||
w.name)
|
|
||||||
else:
|
else:
|
||||||
mapscript, mapdiv = interactive_chart_video(data)
|
mapscript, mapdiv = interactive_chart_video(data)
|
||||||
data['longitude'] = data['spm']
|
data['longitude'] = data['spm']
|
||||||
@@ -353,8 +351,7 @@ def workout_video_create_view(request, id=0):
|
|||||||
|
|
||||||
# create map
|
# create map
|
||||||
if hascoordinates and mode == 'water':
|
if hascoordinates and mode == 'water':
|
||||||
mapscript, mapdiv = leaflet_chart_video(data['latitude'], data['longitude'],
|
mapscript, mapdiv = leaflet_chart(data['latitude'], data['longitude'])
|
||||||
w.name)
|
|
||||||
else:
|
else:
|
||||||
mapscript, mapdiv = interactive_chart_video(data)
|
mapscript, mapdiv = interactive_chart_video(data)
|
||||||
data['longitude'] = data['spm']
|
data['longitude'] = data['spm']
|
||||||
@@ -4141,7 +4138,7 @@ def workout_workflow_view(request, id):
|
|||||||
|
|
||||||
if 'panel_map.html' in r.workflowmiddlepanel and rowhascoordinates(row):
|
if 'panel_map.html' in r.workflowmiddlepanel and rowhascoordinates(row):
|
||||||
rowdata = rdata(csvfile=row.csvfilename)
|
rowdata = rdata(csvfile=row.csvfilename)
|
||||||
mapscript, mapdiv = leaflet_chart2(rowdata.df[' latitude'],
|
mapscript, mapdiv = leaflet_chart(rowdata.df[' latitude'],
|
||||||
rowdata.df[' longitude'],
|
rowdata.df[' longitude'],
|
||||||
row.name)
|
row.name)
|
||||||
else:
|
else:
|
||||||
@@ -4182,6 +4179,8 @@ def workout_workflow_view(request, id):
|
|||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
print(middleTemplates)
|
||||||
|
|
||||||
return render(request,
|
return render(request,
|
||||||
'workflow.html',
|
'workflow.html',
|
||||||
{
|
{
|
||||||
@@ -5063,7 +5062,7 @@ def workout_map_view(request, id=0):
|
|||||||
hascoordinates = 0
|
hascoordinates = 0
|
||||||
|
|
||||||
if hascoordinates:
|
if hascoordinates:
|
||||||
mapscript, mapdiv = leaflet_chart2(rowdata.df[' latitude'],
|
mapscript, mapdiv = leaflet_chart(rowdata.df[' latitude'],
|
||||||
rowdata.df[' longitude'],
|
rowdata.df[' longitude'],
|
||||||
w.name)
|
w.name)
|
||||||
else:
|
else:
|
||||||
@@ -5188,7 +5187,7 @@ def workout_uploadimage_view(request, id): # pragma: no cover
|
|||||||
# Generic chart creation
|
# Generic chart creation
|
||||||
@permission_required('workout.change_workout', fn=get_workout_by_opaqueid, raise_exception=True)
|
@permission_required('workout.change_workout', fn=get_workout_by_opaqueid, raise_exception=True)
|
||||||
def workout_add_chart_view(request, id, plotnr=1):
|
def workout_add_chart_view(request, id, plotnr=1):
|
||||||
|
|
||||||
w = get_workoutuser(id, request)
|
w = get_workoutuser(id, request)
|
||||||
r = getrower(request.user)
|
r = getrower(request.user)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user