mirror of
https://github.com/enzet/map-machine.git
synced 2025-06-07 21:31:49 +02:00
Issues #126: refactor figures sorting.
This commit is contained in:
parent
32bad69fc5
commit
5a934e2f37
2 changed files with 7 additions and 7 deletions
|
@ -529,6 +529,10 @@ class Constructor:
|
||||||
)
|
)
|
||||||
self.points.append(point)
|
self.points.append(point)
|
||||||
|
|
||||||
|
def get_sorted_figures(self) -> list[StyledFigure]:
|
||||||
|
"""Get all figures sorted by priority."""
|
||||||
|
return sorted(self.figures, key=lambda x: x.line_style.priority)
|
||||||
|
|
||||||
|
|
||||||
def check_level_number(tags: Tags, level: float) -> bool:
|
def check_level_number(tags: Tags, level: float) -> bool:
|
||||||
"""Check if element described by tags is no the specified level."""
|
"""Check if element described by tags is no the specified level."""
|
||||||
|
|
|
@ -18,7 +18,6 @@ from map_machine.constructor import Constructor
|
||||||
from map_machine.drawing import draw_text
|
from map_machine.drawing import draw_text
|
||||||
from map_machine.feature.building import Building, draw_walls, BUILDING_SCALE
|
from map_machine.feature.building import Building, draw_walls, BUILDING_SCALE
|
||||||
from map_machine.feature.road import Intersection, Road, RoadPart
|
from map_machine.feature.road import Intersection, Road, RoadPart
|
||||||
from map_machine.figure import StyledFigure
|
|
||||||
from map_machine.geometry.boundary_box import BoundaryBox
|
from map_machine.geometry.boundary_box import BoundaryBox
|
||||||
from map_machine.geometry.flinger import Flinger
|
from map_machine.geometry.flinger import Flinger
|
||||||
from map_machine.geometry.vector import Segment
|
from map_machine.geometry.vector import Segment
|
||||||
|
@ -59,16 +58,13 @@ class Map:
|
||||||
self.svg.add(
|
self.svg.add(
|
||||||
Rect((0.0, 0.0), self.flinger.size, fill=self.background_color)
|
Rect((0.0, 0.0), self.flinger.size, fill=self.background_color)
|
||||||
)
|
)
|
||||||
ways: list[StyledFigure] = sorted(
|
|
||||||
constructor.figures, key=lambda x: x.line_style.priority
|
|
||||||
)
|
|
||||||
logging.info("Drawing ways...")
|
logging.info("Drawing ways...")
|
||||||
|
|
||||||
for way in ways:
|
for figure in constructor.get_sorted_figures():
|
||||||
path_commands: str = way.get_path(self.flinger)
|
path_commands: str = figure.get_path(self.flinger)
|
||||||
if path_commands:
|
if path_commands:
|
||||||
path: SVGPath = SVGPath(d=path_commands)
|
path: SVGPath = SVGPath(d=path_commands)
|
||||||
path.update(way.line_style.style)
|
path.update(figure.line_style.style)
|
||||||
self.svg.add(path)
|
self.svg.add(path)
|
||||||
|
|
||||||
constructor.roads.draw(self.svg, self.flinger)
|
constructor.roads.draw(self.svg, self.flinger)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue