From d0ef85cd0bd6ffedc69a94337397dacba425872d Mon Sep 17 00:00:00 2001 From: Sergey Vartanov Date: Tue, 31 May 2022 00:43:45 +0300 Subject: [PATCH] Issue #125: split way priority. Now 40.0 is a special way priority. Ways that have priority less than 40.0 will be drawn below the road layer, and ways that have priority greater than 40.0 will be drawn above the road layer. --- map_machine/mapper.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/map_machine/mapper.py b/map_machine/mapper.py index e8c67d0..59cbe3e 100644 --- a/map_machine/mapper.py +++ b/map_machine/mapper.py @@ -19,6 +19,7 @@ from map_machine.constructor import Constructor from map_machine.drawing import draw_text from map_machine.feature.building import Building, draw_walls, BUILDING_SCALE 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.flinger import Flinger from map_machine.geometry.vector import Segment @@ -34,6 +35,8 @@ from map_machine.workspace import workspace __author__ = "Sergey Vartanov" __email__ = "me@enzet.ru" +ROAD_PRIORITY: float = 40.0 + class Map: """Map drawing.""" @@ -61,7 +64,16 @@ class Map: ) logging.info("Drawing ways...") - for figure in constructor.get_sorted_figures(): + figures: list[StyledFigure] = constructor.get_sorted_figures() + + top_figures: list[StyledFigure] = [ + x for x in figures if x.line_style.priority >= ROAD_PRIORITY + ] + bottom_figures: list[StyledFigure] = [ + x for x in figures if x.line_style.priority < ROAD_PRIORITY + ] + + for figure in bottom_figures: path_commands: str = figure.get_path(self.flinger) if path_commands: path: SVGPath = SVGPath(d=path_commands) @@ -70,6 +82,13 @@ class Map: constructor.roads.draw(self.svg, self.flinger) + for figure in top_figures: + path_commands: str = figure.get_path(self.flinger) + if path_commands: + path: SVGPath = SVGPath(d=path_commands) + path.update(figure.line_style.style) + self.svg.add(path) + for tree in constructor.trees: tree.draw(self.svg, self.flinger, self.scheme) for crater in constructor.craters: