diff --git a/src/c3nav/routing/graph.py b/src/c3nav/routing/graph.py index 45014d76..5f1ba666 100644 --- a/src/c3nav/routing/graph.py +++ b/src/c3nav/routing/graph.py @@ -443,7 +443,10 @@ class Graph: dest_ctype = dest_ctypes[tuple(dest_points_i).index(best_route.to_point)] if add_dest_point else None best_route = SegmentRouteWrapper(best_route, orig_point=add_orig_point, dest_point=add_dest_point, orig_ctype=orig_ctype, dest_ctype=dest_ctype) - return best_route.split() + best_route = best_route.split() + best_route.create_routeparts() + best_route.check_allowed_ctypes(allowed_ctypes) + return best_route def _room_transfers(self, rooms, room_points, routers, mode): if mode not in ('orig', 'dest'): diff --git a/src/c3nav/routing/room.py b/src/c3nav/routing/room.py index d984e2e2..0de88bbd 100644 --- a/src/c3nav/routing/room.py +++ b/src/c3nav/routing/room.py @@ -263,7 +263,10 @@ class GraphRoom(): return roomrouter def _build_router(self, ctypes, public, nonpublic, avoid, include): - distances = np.amin(self.distances[ctypes, :, :], axis=0).astype(np.float32) + ctype_factors = np.ones((len(self.ctypes), 1, 1))*1000 + ctype_factors[ctypes] = 1 + + distances = np.amin(self.distances*ctype_factors, axis=0).astype(np.float32) factors = np.ones_like(distances, dtype=np.float16) if ':public' in self.excludables and not public: diff --git a/src/c3nav/routing/route.py b/src/c3nav/routing/route.py index a2c0dd71..328ad941 100644 --- a/src/c3nav/routing/route.py +++ b/src/c3nav/routing/route.py @@ -14,6 +14,8 @@ class Route: self.from_point = connections[0].from_point self.to_point = connections[-1].to_point + self.ctypes_exception = None + self.routeparts = None def __repr__(self): @@ -210,6 +212,14 @@ class Route: if last_line.icon == 'location': last_line.ignore = True + def check_allowed_ctypes(self, allowed_ctypes): + allowed_ctypes = set(allowed_ctypes) + self.ctypes_exception = False + for connection in self.connections: + if connection.ctype not in allowed_ctypes: + self.ctypes_exception = True + return + class RoutePart: def __init__(self, graphlevel, lines): diff --git a/src/c3nav/site/templates/site/fragment_route.html b/src/c3nav/site/templates/site/fragment_route.html index 59efc397..927dfb30 100644 --- a/src/c3nav/site/templates/site/fragment_route.html +++ b/src/c3nav/site/templates/site/fragment_route.html @@ -3,6 +3,11 @@ {% load route_render %}