diff options
author | Étienne Loks <etienne.loks@peacefrogs.net> | 2012-11-13 23:29:53 +0000 |
---|---|---|
committer | Étienne Loks <etienne.loks@peacefrogs.net> | 2012-11-13 23:29:53 +0000 |
commit | 7a9fe6fd46f7308f8752032b6fbe29f3fe0daa62 (patch) | |
tree | 56762a81ccdb23859628581a33ed67bf53b9b51c /chimere/views.py | |
parent | 40d7d3b373a392b68b43524a4049216b1223c81c (diff) | |
download | Chimère-7a9fe6fd46f7308f8752032b6fbe29f3fe0daa62.tar.bz2 Chimère-7a9fe6fd46f7308f8752032b6fbe29f3fe0daa62.zip |
Fix warning on route
Diffstat (limited to 'chimere/views.py')
-rw-r--r-- | chimere/views.py | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/chimere/views.py b/chimere/views.py index 378307b..a2c7564 100644 --- a/chimere/views.py +++ b/chimere/views.py @@ -749,22 +749,31 @@ def route(request, area_name, lon1, lat1, lonlat_steps, lon2, lat2, cats = SubCategory.objects.filter(routing_warn=True) message = '' if cats.count(): + st_string = '{"type":"Feature", "geometry":{ "type": "Point", '\ + '"coordinates": [ %f, %f ] }, "properties":{"icon_path":"%s",'\ + '"icon_width":%d, "icon_height":%d}}' points = [(m.point, m.categories.all()[0].icon) for m in list(Marker.objects.filter(status='A', categories__in=cats, point__distance_lte=(route, D(m=15)) ).all())] + for pt, icon in points: + st = st_string % (pt.x, pt.y, icon.image.url, icon.image.width, + icon.image.height) + jsons.append(st) routes = Route.objects.filter(status='A', categories__in=cats, route__crosses=route) + intersect = False for rout in routes.intersection(route): - rt = rout.intersection - points.append((rt, rout.categories.all()[0].icon)) - for pt, icon in points: - st = '{"type":"Feature", "geometry":{ "type": "Point", '\ - '"coordinates": [ %f, %f ] }, "properties":{"icon_path":"%s",'\ - '"icon_width":%d, "icon_height":%d}}' % (pt.x, pt.y, - icon.image.url, icon.image.width, icon.image.height) - jsons.append(st) - if points: + pts = rout.intersection + icon = rout.categories.all()[0].icon + if hasattr(pts, 'x'): + pts = [pts] + if pts: + pt = pts[0] + st = st_string % (pt.x, pt.y, icon.image.url, icon.image.width, + icon.image.height) + jsons.append(st) + if points or intersect: message = getattr(settings, 'CHIMERE_ROUTING_WARN_MESSAGE', '') if message: message = ', "message":%s' % jsonencoder.encode( |