render colors in right order
This commit is contained in:
parent
0afdc0793d
commit
27287b8a00
3 changed files with 11 additions and 4 deletions
|
@ -125,12 +125,17 @@ class Location(LocationSlug, AccessRestrictionMixin, TitledMixin, models.Model):
|
|||
return None
|
||||
|
||||
def get_color(self, instance=None):
|
||||
# dont filter in the query here so prefetch_related works
|
||||
result = self.get_color_sorted(instance)
|
||||
return None if result is None else result[1]
|
||||
|
||||
def get_color_sorted(self, instance=None):
|
||||
# dont filter in the query here so prefetch_related works
|
||||
if instance is None:
|
||||
instance = self
|
||||
for group in instance.groups.all():
|
||||
if group.color and getattr(group.category, 'allow_'+self.__class__._meta.default_related_name):
|
||||
return group.color
|
||||
return (0, group.category.priority, group.priority), group.color
|
||||
return None
|
||||
|
||||
def get_icon(self):
|
||||
|
|
|
@ -127,14 +127,14 @@ class LevelGeometries:
|
|||
buffered.difference(buildings_geom)
|
||||
)
|
||||
|
||||
colors.setdefault(space.get_color(), {}).setdefault(access_restriction, []).append(space.geometry)
|
||||
colors.setdefault(space.get_color_sorted(), {}).setdefault(access_restriction, []).append(space.geometry)
|
||||
|
||||
for area in space.areas.all():
|
||||
access_restriction = area.access_restriction_id or space.access_restriction_id
|
||||
area.geometry = area.geometry.intersection(space.walkable_geom)
|
||||
if access_restriction is not None:
|
||||
access_restriction_affected.setdefault(access_restriction, []).append(area.geometry)
|
||||
colors.setdefault(area.get_color(), {}).setdefault(access_restriction, []).append(area.geometry)
|
||||
colors.setdefault(area.get_color_sorted(), {}).setdefault(access_restriction, []).append(area.geometry)
|
||||
|
||||
for column in space.columns.all():
|
||||
access_restriction = column.access_restriction_id
|
||||
|
@ -172,6 +172,8 @@ class LevelGeometries:
|
|||
for access_restriction, areas in tuple(color_group.items()):
|
||||
color_group[access_restriction] = unary_union(areas)
|
||||
|
||||
colors = {color: geometry for color, geometry in sorted(colors.items(), key=lambda v: v[0][0], reverse=True)}
|
||||
|
||||
# add altitudegroup geometries and split ground colors into them
|
||||
for altitudearea in level.altitudeareas.all():
|
||||
altitudearea_prep = prepared.prep(altitudearea.geometry)
|
||||
|
|
|
@ -93,7 +93,7 @@ class MapRenderer:
|
|||
category='ground', item=i)
|
||||
|
||||
j = 0
|
||||
for color, areas in altitudearea.colors.items():
|
||||
for (order, color), areas in altitudearea.colors.items():
|
||||
# only select ground colors if their access restriction is unlocked
|
||||
areas = tuple(area for access_restriction, area in areas.items()
|
||||
if access_restriction in access_permissions)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue