add LineObstacle and various improvements

This commit is contained in:
Laura Klünder 2016-12-08 22:23:42 +01:00
parent 06aec21669
commit 0f81d1e49a
9 changed files with 150 additions and 5 deletions

View file

@ -104,6 +104,14 @@ class LevelGeometries():
def mapped(self):
return cascaded_union([self.buildings, self.outsides])
@cached_property
def lineobstacles(self):
lineobstacles = []
for obstacle in self.level.lineobstacles.all():
lineobstacles.append(obstacle.geometry.buffer(obstacle.width/2,
join_style=JOIN_STYLE.mitre, cap_style=CAP_STYLE.flat))
return cascaded_union(lineobstacles)
@cached_property
def obstacles(self):
levels_by_name = {}
@ -119,6 +127,7 @@ class LevelGeometries():
if level_name is not None:
obstacles = obstacles.intersection(levels_by_name[level_name].geometries.mapped)
all_obstacles.append(obstacles)
all_obstacles.extend(self.lineobstacles)
return cascaded_union(all_obstacles).intersection(self.mapped)