adding gates
This commit is contained in:
@@ -2069,6 +2069,52 @@ def leaflet_chart_compare(course,workoutids,labeldict={},startenddict={}):
|
|||||||
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)
|
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
|
# Throw out 0,0
|
||||||
df = df.replace(0,np.nan)
|
df = df.replace(0,np.nan)
|
||||||
df = df.loc[(df!=0).any(axis=1)]
|
df = df.loc[(df!=0).any(axis=1)]
|
||||||
@@ -2093,18 +2139,7 @@ def leaflet_chart_compare(course,workoutids,labeldict={},startenddict={}):
|
|||||||
except AttributeError:
|
except AttributeError:
|
||||||
items = zip(workoutids,colors)
|
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 = """
|
||||||
<script>
|
<script>
|
||||||
@@ -2178,6 +2213,10 @@ def leaflet_chart_compare(course,workoutids,labeldict={},startenddict={}):
|
|||||||
}}).addTo(mymap);
|
}}).addTo(mymap);
|
||||||
|
|
||||||
|
|
||||||
|
var platlongs = {pcoordinates}
|
||||||
|
var polygons = L.polygon(platlongs, {{color:'blue'}}).addTo(mymap)
|
||||||
|
|
||||||
|
{plabels}
|
||||||
|
|
||||||
""".format(
|
""".format(
|
||||||
latmean=latmean,
|
latmean=latmean,
|
||||||
@@ -2186,7 +2225,8 @@ def leaflet_chart_compare(course,workoutids,labeldict={},startenddict={}):
|
|||||||
latend=latend,
|
latend=latend,
|
||||||
longbegin=longbegin,
|
longbegin=longbegin,
|
||||||
longend=longend,
|
longend=longend,
|
||||||
scoordinates=scoordinates,
|
pcoordinates=pcoordinates,
|
||||||
|
plabels=plabels,
|
||||||
)
|
)
|
||||||
|
|
||||||
for id,color in items:
|
for id,color in items:
|
||||||
|
|||||||
@@ -20,8 +20,8 @@
|
|||||||
<h1>Course Map Comparison</h1>
|
<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>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">
|
<div class="mapdiv">
|
||||||
{{ mapdiv|safe }}
|
{{ mapdiv|safe }}
|
||||||
|
|||||||
Reference in New Issue
Block a user