fix room router creation
This commit is contained in:
parent
07f15aa6ce
commit
90a2b2b3ae
2 changed files with 7 additions and 5 deletions
|
@ -16,4 +16,3 @@ class Command(BaseCommand):
|
||||||
start = time.time()
|
start = time.time()
|
||||||
graph.build_router()
|
graph.build_router()
|
||||||
print('Routers built in %.4fs' % (time.time() - start))
|
print('Routers built in %.4fs' % (time.time() - start))
|
||||||
print('%s transfer points' % len(graph.transfer_points))
|
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from matplotlib.path import Path
|
from matplotlib.path import Path
|
||||||
|
from scipy.sparse.csgraph._shortest_path import shortest_path
|
||||||
|
from scipy.sparse.csgraph._tools import csgraph_from_dense
|
||||||
from shapely.geometry import CAP_STYLE, JOIN_STYLE, LineString
|
from shapely.geometry import CAP_STYLE, JOIN_STYLE, LineString
|
||||||
|
|
||||||
from c3nav.mapdata.utils.geometry import assert_multilinestring, assert_multipolygon
|
from c3nav.mapdata.utils.geometry import assert_multilinestring, assert_multipolygon
|
||||||
from c3nav.routing.area import GraphArea
|
from c3nav.routing.area import GraphArea
|
||||||
from c3nav.routing.point import GraphPoint
|
from c3nav.routing.point import GraphPoint
|
||||||
from c3nav.routing.router import Router
|
|
||||||
from c3nav.routing.utils.coords import coord_angle, get_coords_angles
|
from c3nav.routing.utils.coords import coord_angle, get_coords_angles
|
||||||
from c3nav.routing.utils.mpl import shapely_to_mpl
|
from c3nav.routing.utils.mpl import shapely_to_mpl
|
||||||
|
|
||||||
|
@ -182,7 +183,7 @@ class GraphRoom():
|
||||||
area.build_connections()
|
area.build_connections()
|
||||||
|
|
||||||
def connection_count(self):
|
def connection_count(self):
|
||||||
return np.count_nonzero(self.distances != np.inf)
|
return np.count_nonzero(self.distances >= 0)
|
||||||
|
|
||||||
def finish_build(self):
|
def finish_build(self):
|
||||||
self.areas = tuple(self.areas)
|
self.areas = tuple(self.areas)
|
||||||
|
@ -202,5 +203,7 @@ class GraphRoom():
|
||||||
|
|
||||||
# Routing
|
# Routing
|
||||||
def build_router(self):
|
def build_router(self):
|
||||||
self.router = Router()
|
# noinspection PyTypeChecker
|
||||||
self.router.build(self._built_points)
|
g_sparse = csgraph_from_dense(self.distances, null_value=np.inf)
|
||||||
|
shortest_paths, predecessors = shortest_path(g_sparse, return_predecessors=True)
|
||||||
|
return shortest_paths, predecessors
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue