avoiding connection types shoud avoid, but not forbid them.
This commit is contained in:
parent
10e331bf43
commit
4536245570
5 changed files with 23 additions and 3 deletions
|
@ -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'):
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -3,6 +3,11 @@
|
|||
{% load route_render %}
|
||||
|
||||
<h2>{% trans 'Your Route' %}</h2>
|
||||
{% if route.ctypes_exception %}
|
||||
<div class="alert alert-warning">
|
||||
<strong>{% trans 'This Route contains way types you wanted to avoid.' %}</strong>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="routeparts">
|
||||
{% for routepart in route.routeparts %}
|
||||
<div class="row routepart">
|
||||
|
|
|
@ -191,7 +191,6 @@ def main(request, location=None, origin=None, destination=None):
|
|||
except AlreadyThere:
|
||||
ctx.update({'error': 'alreadythere'})
|
||||
else:
|
||||
route.create_routeparts()
|
||||
ctx.update({'route': route})
|
||||
|
||||
response = render(request, 'site/main.html', ctx)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue