fix glitches when routing from/to coordinates
This commit is contained in:
parent
ced5e691b5
commit
39ada6deb9
3 changed files with 7 additions and 6 deletions
|
@ -118,6 +118,6 @@ class GraphArea():
|
|||
there, back = self.check_connection(point, other_point.xy)
|
||||
ctype = there if mode == 'orig' else back
|
||||
if ctype is not None:
|
||||
distance = np.linalg.norm(point - other_point.xy)
|
||||
distance = abs(np.linalg.norm(point - other_point.xy))
|
||||
connections[point_i] = (distance, ctype)
|
||||
return connections
|
||||
|
|
|
@ -249,8 +249,8 @@ class Graph:
|
|||
if not points:
|
||||
return (), None, None
|
||||
points, distances, ctypes = zip(*((point, distance, ctype) for point, (distance, ctype) in points.items()))
|
||||
distances = {points[i]: distance for i, distance in enumerate(distances)}
|
||||
points = np.array(points)
|
||||
distances = np.array(distances)
|
||||
return points, distances, ctypes
|
||||
try:
|
||||
if isinstance(location, AreaLocation):
|
||||
|
@ -339,12 +339,13 @@ class Graph:
|
|||
# add distances to room routers
|
||||
if orig_distances is not None:
|
||||
for room in orig_rooms:
|
||||
print(orig_distances[:, None].shape)
|
||||
routers[room].shortest_paths[orig_room_points[room], :] += orig_distances[:, None]
|
||||
distances = np.array(tuple(orig_distances[room.points[i]] for i in orig_room_points[room]))
|
||||
routers[room].shortest_paths[orig_room_points[room], :] += distances[:, None]
|
||||
|
||||
if dest_distances is not None:
|
||||
for room in dest_rooms:
|
||||
routers[room].shortest_paths[:, dest_room_points[room]] += dest_distances
|
||||
distances = np.array(tuple(dest_distances[room.points[i]] for i in dest_room_points[room]))
|
||||
routers[room].shortest_paths[:, dest_room_points[room]] += distances
|
||||
|
||||
# if the points have common rooms, search for routes within those rooms
|
||||
if common_rooms:
|
||||
|
|
|
@ -405,7 +405,7 @@ class GraphLevel():
|
|||
cache_key = ('c3nav__routing__connected_points__%s__%s__%.2f_%.2f__%s' %
|
||||
(self.graph.mtime, self.level.name, point[0], point[1], mode))
|
||||
points = cache.get(cache_key, None)
|
||||
if points is None:
|
||||
if points is None or True:
|
||||
points = self._connected_points(point, mode)
|
||||
cache.set(cache_key, points, 60)
|
||||
return points
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue