routing: stuffedareas
This commit is contained in:
parent
3a44985840
commit
4c547326bf
4 changed files with 19 additions and 2 deletions
|
@ -47,6 +47,9 @@ class GraphArea():
|
||||||
if self.mpl_clear.intersects_path(path):
|
if self.mpl_clear.intersects_path(path):
|
||||||
return None, None, None
|
return None, None, None
|
||||||
|
|
||||||
|
if self.room.stuffedareas.intersects_path(path, filled=True):
|
||||||
|
distance *= 2.5
|
||||||
|
|
||||||
# stair checker
|
# stair checker
|
||||||
angle = coord_angle(point1, point2)
|
angle = coord_angle(point1, point2)
|
||||||
stair_direction_up = None
|
stair_direction_up = None
|
||||||
|
|
|
@ -69,6 +69,7 @@ class GraphLevel():
|
||||||
self.create_elevatorlevels()
|
self.create_elevatorlevels()
|
||||||
|
|
||||||
self.collect_arealocations()
|
self.collect_arealocations()
|
||||||
|
self.collect_stuffedareas()
|
||||||
|
|
||||||
self._built_points = sum((room._built_points for room in self.rooms), [])
|
self._built_points = sum((room._built_points for room in self.rooms), [])
|
||||||
self._built_points.extend(self._built_room_transfer_points)
|
self._built_points.extend(self._built_room_transfer_points)
|
||||||
|
@ -156,6 +157,15 @@ class GraphLevel():
|
||||||
for interior in polygon.interiors:
|
for interior in polygon.interiors:
|
||||||
room._add_ring(interior, want_left=False)
|
room._add_ring(interior, want_left=False)
|
||||||
|
|
||||||
|
def collect_stuffedareas(self):
|
||||||
|
self._built_stuffedareas = self.level.geometries.stuffedareas
|
||||||
|
for polygon in assert_multipolygon(self._built_stuffedareas.buffer(0.05, join_style=JOIN_STYLE.mitre)):
|
||||||
|
for room in self.rooms:
|
||||||
|
room._add_ring(polygon.exterior, want_left=True)
|
||||||
|
|
||||||
|
for interior in polygon.interiors:
|
||||||
|
room._add_ring(interior, want_left=False)
|
||||||
|
|
||||||
def create_doors(self):
|
def create_doors(self):
|
||||||
doors = self.level.geometries.doors
|
doors = self.level.geometries.doors
|
||||||
doors = assert_multipolygon(doors)
|
doors = assert_multipolygon(doors)
|
||||||
|
|
|
@ -29,6 +29,7 @@ class GraphRoom():
|
||||||
self.distances = np.zeros((1, ))
|
self.distances = np.zeros((1, ))
|
||||||
self.ctypes = None
|
self.ctypes = None
|
||||||
self.excludables = None
|
self.excludables = None
|
||||||
|
self.stuffedareas = None
|
||||||
|
|
||||||
def serialize(self):
|
def serialize(self):
|
||||||
return (
|
return (
|
||||||
|
@ -40,13 +41,14 @@ class GraphRoom():
|
||||||
self.ctypes,
|
self.ctypes,
|
||||||
self.excludables,
|
self.excludables,
|
||||||
self.excludable_points,
|
self.excludable_points,
|
||||||
|
self.stuffedareas,
|
||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def unserialize(cls, level, data):
|
def unserialize(cls, level, data):
|
||||||
room = cls(level)
|
room = cls(level)
|
||||||
(room.mpl_clear, areas, room.points, room.room_transfer_points,
|
(room.mpl_clear, areas, room.points, room.room_transfer_points,
|
||||||
room.distances, room.ctypes, room.excludables, room.excludable_points) = data
|
room.distances, room.ctypes, room.excludables, room.excludable_points, room.stuffedareas) = data
|
||||||
room.areas = tuple(GraphArea(room, *area) for area in areas)
|
room.areas = tuple(GraphArea(room, *area) for area in areas)
|
||||||
return room
|
return room
|
||||||
|
|
||||||
|
@ -206,6 +208,8 @@ class GraphRoom():
|
||||||
if self._built_is_elevatorlevel:
|
if self._built_is_elevatorlevel:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
self.stuffedareas = shapely_to_mpl(self.level._built_stuffedareas.intersection(self._built_geometry))
|
||||||
|
|
||||||
for area in self.areas:
|
for area in self.areas:
|
||||||
area.build_connections()
|
area.build_connections()
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,7 @@ def shapely_to_mpl(geometry):
|
||||||
"""
|
"""
|
||||||
if isinstance(geometry, Polygon):
|
if isinstance(geometry, Polygon):
|
||||||
return MplPolygonPath(geometry)
|
return MplPolygonPath(geometry)
|
||||||
elif isinstance(geometry, MultiPolygon):
|
elif isinstance(geometry, MultiPolygon) or geometry.is_empty:
|
||||||
return MplMultipolygonPath(geometry)
|
return MplMultipolygonPath(geometry)
|
||||||
raise TypeError
|
raise TypeError
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue