Private
Public Access
1
0

adding gates

This commit is contained in:
Sander Roosendaal
2020-06-03 14:16:09 +02:00
parent 7ac7dbe422
commit b395bcfbd1
2 changed files with 54 additions and 14 deletions

View File

@@ -2069,6 +2069,52 @@ def leaflet_chart_compare(course,workoutids,labeldict={},startenddict={}):
latmean,lonmean,coordinates = course_coord_center(course)
lat_min, lat_max, long_min, long_max = course_coord_maxmin(course)
coordinates = course_spline(coordinates)
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
df = df.replace(0,np.nan)
df = df.loc[(df!=0).any(axis=1)]
@@ -2093,18 +2139,7 @@ def leaflet_chart_compare(course,workoutids,labeldict={},startenddict={}):
except AttributeError:
items = zip(workoutids,colors)
coordinates = zip(lat,lon)
scoordinates = "["
for x,y in coordinates:
scoordinates += """[{x},{y}],
""".format(
x=x,
y=y
)
scoordinates += "]"
script = """
<script>
@@ -2178,6 +2213,10 @@ def leaflet_chart_compare(course,workoutids,labeldict={},startenddict={}):
}}).addTo(mymap);
var platlongs = {pcoordinates}
var polygons = L.polygon(platlongs, {{color:'blue'}}).addTo(mymap)
{plabels}
""".format(
latmean=latmean,
@@ -2186,7 +2225,8 @@ def leaflet_chart_compare(course,workoutids,labeldict={},startenddict={}):
latend=latend,
longbegin=longbegin,
longend=longend,
scoordinates=scoordinates,
pcoordinates=pcoordinates,
plabels=plabels,
)
for id,color in items:

View File

@@ -20,8 +20,8 @@
<h1>Course Map Comparison</h1>
<p>Click on a line to see the label. Double click on a line to remove it. Reload to get back all lines.</p>
<p>We show your original GPS coordinates on the course. For course time, we use a finer interpolation, to get
the exact time when you crossed the line.</p>
<div class="mapdiv">
{{ mapdiv|safe }}