diff --git a/rowers/interactiveplots.py b/rowers/interactiveplots.py index ac99a831..aa884ea1 100644 --- a/rowers/interactiveplots.py +++ b/rowers/interactiveplots.py @@ -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("{name}"); + + """.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 = """