mirror of
https://github.com/enzet/map-machine.git
synced 2025-06-03 03:11:52 +02:00
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.
This commit is contained in:
parent
a6c94a091f
commit
d0ef85cd0b
1 changed files with 20 additions and 1 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue