mirror of
https://github.com/enzet/map-machine.git
synced 2025-05-23 22:16:25 +02:00
Fix road layers.
Draw roads layer by layer.
This commit is contained in:
parent
748b252d1e
commit
15466cb74c
3 changed files with 28 additions and 10 deletions
|
@ -245,6 +245,10 @@ class Road(Figure):
|
|||
except ValueError:
|
||||
pass
|
||||
|
||||
self.layer: float = 0
|
||||
if "layer" in tags:
|
||||
self.layer = float(tags["layer"])
|
||||
|
||||
def draw(
|
||||
self,
|
||||
svg: Drawing,
|
||||
|
@ -259,7 +263,10 @@ class Road(Figure):
|
|||
width = self.width
|
||||
else:
|
||||
width = self.matcher.default_width
|
||||
if extra_width and self.tags.get("bridge") == "yes":
|
||||
cap: str = "round"
|
||||
if extra_width:
|
||||
cap = "butt"
|
||||
if self.tags.get("bridge") == "yes":
|
||||
color = Color("#666666")
|
||||
scale: float = flinger.get_scale(self.outers[0][0].coordinates)
|
||||
path_commands: str = self.get_path(flinger)
|
||||
|
@ -267,7 +274,7 @@ class Road(Figure):
|
|||
style: dict[str, Any] = {
|
||||
"fill": "none",
|
||||
"stroke": color.hex,
|
||||
"stroke-linecap": "round",
|
||||
"stroke-linecap": cap,
|
||||
"stroke-linejoin": "round",
|
||||
"stroke-width": scale * width + extra_width,
|
||||
}
|
||||
|
|
|
@ -70,9 +70,14 @@ class Map:
|
|||
self.svg.add(path)
|
||||
progress_bar(-1, 0, text="Drawing ways")
|
||||
|
||||
roads: Iterator[Road] = sorted(
|
||||
constructor.roads, key=lambda x: x.matcher.priority
|
||||
)
|
||||
layered_roads: dict[float, list[Road]] = {}
|
||||
for road in constructor.roads:
|
||||
if road.layer not in layered_roads:
|
||||
layered_roads[road.layer] = []
|
||||
layered_roads[road.layer].append(road)
|
||||
|
||||
for layer in sorted(layered_roads.keys()):
|
||||
roads = layered_roads[layer]
|
||||
for road in roads:
|
||||
road.draw(self.svg, self.flinger, road.matcher.border_color, 2)
|
||||
for road in roads:
|
||||
|
|
|
@ -287,6 +287,12 @@ class RoadMatcher(Matcher):
|
|||
if "priority" in structure:
|
||||
self.priority = structure["priority"]
|
||||
|
||||
def get_priority(self, tags: dict[str, str]) -> float:
|
||||
layer: float = 0
|
||||
if "layer" in tags:
|
||||
layer = float(tags.get("layer"))
|
||||
return 1000 * layer + self.priority
|
||||
|
||||
|
||||
class Scheme:
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue