improve renderer: add obstacles and doors
This commit is contained in:
parent
b76cfa1985
commit
df0598e5ee
2 changed files with 53 additions and 25 deletions
|
@ -1,6 +1,7 @@
|
|||
from django.db import models
|
||||
from django.utils.functional import cached_property
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from shapely.geometry import JOIN_STYLE
|
||||
from shapely.ops import cascaded_union
|
||||
|
||||
from c3nav.mapdata.models.base import MapItem
|
||||
|
@ -57,3 +58,35 @@ class LevelGeometries():
|
|||
@cached_property
|
||||
def areas(self):
|
||||
return cascaded_union([area.geometry for area in self.level.areas.all()])
|
||||
|
||||
@cached_property
|
||||
def mapped(self):
|
||||
return cascaded_union([self.buildings, self.areas])
|
||||
|
||||
@cached_property
|
||||
def obstacles(self):
|
||||
return cascaded_union([obstacle.geometry for obstacle in self.level.obstacles.all()])
|
||||
|
||||
@cached_property
|
||||
def raw_doors(self):
|
||||
return cascaded_union([door.geometry for door in self.level.doors.all()]).intersection(self.mapped)
|
||||
|
||||
@cached_property
|
||||
def areas_and_doors(self):
|
||||
return cascaded_union([self.areas, self.raw_doors])
|
||||
|
||||
@cached_property
|
||||
def walls(self):
|
||||
return self.buildings.difference(self.areas)
|
||||
|
||||
@cached_property
|
||||
def walls_without_doors(self):
|
||||
return self.walls.difference(self.areas_and_doors)
|
||||
|
||||
@cached_property
|
||||
def walls_shadow(self):
|
||||
return self.walls_without_doors.buffer(0.2, join_style=JOIN_STYLE.mitre).intersection(self.mapped)
|
||||
|
||||
@cached_property
|
||||
def doors(self):
|
||||
return self.raw_doors.difference(self.areas)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue