From c954f3976b71fd40ff64b726cda75115252c1e08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laura=20Kl=C3=BCnder?= Date: Fri, 23 Dec 2016 23:03:25 +0100 Subject: [PATCH] fix Level.nearest_point if there is no nearest point --- src/c3nav/mapdata/models/locations.py | 9 ++++----- src/c3nav/routing/level.py | 2 ++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/c3nav/mapdata/models/locations.py b/src/c3nav/mapdata/models/locations.py index 89e7fa86..537f58b9 100644 --- a/src/c3nav/mapdata/models/locations.py +++ b/src/c3nav/mapdata/models/locations.py @@ -210,16 +210,15 @@ class AreaLocation(LocationModelMixin, GeometryMapItemWithLevel): @property def subtitle(self): - return self.get_subtitle(with_type=False) + return self.get_subtitle() @property def subtitle_without_type(self): - return self.get_subtitle(with_type=False) + return self.get_subtitle() - def get_subtitle(self, with_type=True): + def get_subtitle(self): items = [] - if with_type: - items += [self.get_location_type_display()] + items += [group.title for group in self.groups.all()] items += [area.title for area in self.get_in_areas() if area.can_describe] return ', '.join(items) diff --git a/src/c3nav/routing/level.py b/src/c3nav/routing/level.py index c9bacd3b..09760410 100644 --- a/src/c3nav/routing/level.py +++ b/src/c3nav/routing/level.py @@ -391,6 +391,8 @@ class GraphLevel(): if nearest_point is None: nearest_point = self._nearest_point(point, mode) cache.set(cache_key, nearest_point, 60) + if nearest_point is None: + return None return self.graph.points[nearest_point] def _nearest_point(self, point, mode):