split route into connections

This commit is contained in:
Laura Klünder 2016-12-17 14:46:15 +01:00
parent 988c7b1d11
commit 4f847f4e49
5 changed files with 87 additions and 29 deletions

View file

@ -9,6 +9,7 @@ from shapely.geometry import CAP_STYLE, JOIN_STYLE, LineString
from c3nav.mapdata.utils.geometry import assert_multilinestring, assert_multipolygon
from c3nav.routing.area import GraphArea
from c3nav.routing.connection import GraphConnection
from c3nav.routing.point import GraphPoint
from c3nav.routing.utils.coords import coord_angle, get_coords_angles
from c3nav.routing.utils.mpl import shapely_to_mpl
@ -218,5 +219,8 @@ class GraphRoom():
shortest_paths, predecessors = shortest_path(g_sparse, return_predecessors=True)
return RoomRouter(shortest_paths, predecessors)
def get_connection(self, from_i, to_i):
return GraphConnection(self.graph.points[self.points[from_i]], self.graph.points[self.points[to_i]])
RoomRouter = namedtuple('RoomRouter', ('shortest_paths', 'predecessors', ))