make linter happy

This commit is contained in:
Laura Klünder 2024-02-07 18:34:28 +01:00
parent d7f175f7ef
commit 8c8ef12cf0
19 changed files with 107 additions and 75 deletions

View file

@ -6,8 +6,7 @@ from itertools import chain
from typing import Literal, TypeVar
import numpy as np
from matplotlib.patches import Polygon
from shapely.geometry import GeometryCollection, LineString, MultiLineString, MultiPolygon, Point
from shapely.geometry import GeometryCollection, LineString, MultiLineString, MultiPolygon, Point, Polygon
from shapely.geometry.base import BaseGeometry
from shapely.ops import unary_union

View file

@ -1,4 +1,5 @@
import operator
import typing
from collections import Counter, deque
from functools import reduce
from itertools import chain
@ -15,6 +16,9 @@ from c3nav.mapdata.utils.cache import AccessRestrictionAffected
from c3nav.mapdata.utils.geometry import get_rings, unwrap_geom
from c3nav.mapdata.utils.mesh import triangulate_rings
if typing.TYPE_CHECKING:
from c3nav.mapdata.render.theme import ThemeColorManager
empty_geometry_collection = GeometryCollection()
@ -136,7 +140,9 @@ class LevelGeometries:
area.geometry = area.geometry.intersection(unwrap_geom(space.walkable_geom))
if access_restriction is not None:
access_restriction_affected.setdefault(access_restriction, []).append(area.geometry)
colors.setdefault(area.get_color_sorted(color_manager), {}).setdefault(access_restriction, []).append(area.geometry)
colors.setdefault(
area.get_color_sorted(color_manager), {}
).setdefault(access_restriction, []).append(area.geometry)
for column in space.columns.all():
access_restriction = column.access_restriction_id
@ -162,7 +168,9 @@ class LevelGeometries:
for lineobstacle in space.lineobstacles.all():
if not lineobstacle.height:
continue
obstacles.setdefault(int(lineobstacle.height*1000), {}).setdefault(lineobstacle.get_color(color_manager), []).append(
obstacles.setdefault(int(lineobstacle.height*1000), {}).setdefault(
lineobstacle.get_color(color_manager), []
).append(
lineobstacle.buffered_geometry.intersection(unwrap_geom(space.walkable_geom))
)

View file

@ -85,7 +85,9 @@ class LevelRenderData:
altitudeareas_above = [] # todo: typing
for render_level in reversed(levels):
# build level geometry for every single level
single_level_geoms[render_level.pk] = LevelGeometries.build_for_level(render_level, color_manager, altitudeareas_above)
single_level_geoms[render_level.pk] = LevelGeometries.build_for_level(
render_level, color_manager, altitudeareas_above
)
# ignore intermediate levels in this pass
if render_level.on_top_of_id is not None:

View file

@ -11,7 +11,6 @@ from c3nav.mapdata.render.utils import get_full_levels, get_min_altitude
from c3nav.mapdata.utils.color import color_to_rgb, rgb_to_color
class MapRenderer:
def __init__(self, level, minx, miny, maxx, maxy, scale=1, access_permissions=None, full_levels=False,
min_width=None):

View file

@ -24,13 +24,13 @@ class ThemeColorManager:
self.obstacles_default_border = RENDER_COLOR_OBSTACLES_DEFAULT_BORDER
self.location_group_border_colors = {}
self.location_group_fill_colors = {
l.pk: l.color
for l in LocationGroup.objects.filter(color__isnull=False).all()
location_group.pk: location_group.color
for location_group in LocationGroup.objects.filter(color__isnull=False).all()
}
self.obstacle_group_border_colors = {}
self.obstacle_group_fill_colors = {
o.pk: o.color
for o in ObstacleGroup.objects.filter(color__isnull=False).all()
obstacle_group.pk: obstacle_group.color
for obstacle_group in ObstacleGroup.objects.filter(color__isnull=False).all()
}
else:
self.background = theme.color_background
@ -41,20 +41,20 @@ class ThemeColorManager:
self.obstacles_default_fill = theme.color_obstacles_default_fill
self.obstacles_default_border = theme.color_obstacles_default_border
self.location_group_border_colors = {
l.location_group_id: l.border_color
for l in theme.location_groups.all()
theme_location_group.location_group_id: theme_location_group.border_color
for theme_location_group in theme.location_groups.all()
}
self.location_group_fill_colors = {
l.location_group_id: l.fill_color
for l in theme.location_groups.all()
theme_location_group.location_group_id: theme_location_group.fill_color
for theme_location_group in theme.location_groups.all()
}
self.obstacle_group_border_colors = {
o.obstacle_group_id: o.border_color
for o in theme.obstacle_groups.all()
theme_obstacle_group.obstacle_group_id: theme_obstacle_group.border_color
for theme_obstacle_group in theme.obstacle_groups.all()
}
self.obstacle_group_fill_colors = {
o.obstacle_group_id: o.fill_color
for o in theme.obstacle_groups.all()
theme_obstacle.obstacle_group_id: theme_obstacle.fill_color
for theme_obstacle in theme.obstacle_groups.all()
}
def locationgroup_border_color(self, location_group: LocationGroup):