UI error if buildgraph is not yet finished
This commit is contained in:
parent
1a86b826e6
commit
d5a52bf9e3
4 changed files with 22 additions and 8 deletions
|
@ -2,5 +2,9 @@ class NoRouteFound(Exception):
|
|||
pass
|
||||
|
||||
|
||||
class NotYetRoutable(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class AlreadyThere(Exception):
|
||||
pass
|
||||
|
|
|
@ -12,7 +12,7 @@ from c3nav.mapdata.models import Elevator, Level
|
|||
from c3nav.mapdata.models.geometry import LevelConnector
|
||||
from c3nav.mapdata.models.locations import AreaLocation, Location, LocationGroup, PointLocation
|
||||
from c3nav.routing.connection import GraphConnection
|
||||
from c3nav.routing.exceptions import AlreadyThere, NoRouteFound
|
||||
from c3nav.routing.exceptions import AlreadyThere, NoRouteFound, NotYetRoutable
|
||||
from c3nav.routing.level import GraphLevel
|
||||
from c3nav.routing.point import GraphPoint
|
||||
from c3nav.routing.route import NoRoute, Route
|
||||
|
@ -252,12 +252,15 @@ class Graph:
|
|||
points = np.array(points)
|
||||
distances = np.array(distances)
|
||||
return points, distances, ctypes
|
||||
elif isinstance(location, AreaLocation):
|
||||
try:
|
||||
if isinstance(location, AreaLocation):
|
||||
points = self.levels[location.level.name].arealocation_points[location.name]
|
||||
return points, None, None
|
||||
elif isinstance(location, LocationGroup):
|
||||
points = set(np.hstack(tuple(self.get_location_points(area) for area in location.locationareas)))
|
||||
return points, None, None
|
||||
except KeyError:
|
||||
raise NotYetRoutable
|
||||
|
||||
def _get_points_by_i(self, points):
|
||||
return tuple(self.points[i] for i in points)
|
||||
|
|
|
@ -76,6 +76,11 @@
|
|||
{% elif error == 'alreadythere' %}
|
||||
<div class="alert alert-success">
|
||||
<strong>{% trans 'Congratulations, you are already there!' %}</strong>
|
||||
</div>
|
||||
{% elif error == 'notyetroutable' %}
|
||||
<div class="alert alert-danger">
|
||||
<strong>{% trans 'One or both of your locations are not in the routing table yet.' %}</strong>
|
||||
<p>{% trans 'Please try again in a few minutes.' %}</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if route %}
|
||||
|
|
|
@ -11,7 +11,7 @@ from c3nav.mapdata.permissions import get_excludables_includables
|
|||
from c3nav.mapdata.render.compose import composer
|
||||
from c3nav.mapdata.utils.cache import get_levels_cached
|
||||
from c3nav.mapdata.utils.misc import get_dimensions
|
||||
from c3nav.routing.exceptions import AlreadyThere, NoRouteFound
|
||||
from c3nav.routing.exceptions import AlreadyThere, NoRouteFound, NotYetRoutable
|
||||
from c3nav.routing.graph import Graph
|
||||
|
||||
ctype_mapping = {
|
||||
|
@ -190,6 +190,8 @@ def main(request, location=None, origin=None, destination=None):
|
|||
ctx.update({'error': 'noroutefound'})
|
||||
except AlreadyThere:
|
||||
ctx.update({'error': 'alreadythere'})
|
||||
except NotYetRoutable:
|
||||
ctx.update({'error': 'notyetroutable'})
|
||||
else:
|
||||
ctx.update({'route': route})
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue