mirror of
https://github.com/enzet/map-machine.git
synced 2025-06-09 06:11:54 +02:00
Fix area detection.
This commit is contained in:
parent
918e9a7022
commit
3ee56a2f6d
2 changed files with 8 additions and 4 deletions
|
@ -269,9 +269,10 @@ class Constructor:
|
||||||
|
|
||||||
road_matcher: RoadMatcher = self.scheme.get_road(line.tags)
|
road_matcher: RoadMatcher = self.scheme.get_road(line.tags)
|
||||||
if road_matcher:
|
if road_matcher:
|
||||||
self.roads.append(
|
road: Road = Road(
|
||||||
Road(line.tags, outers[0], road_matcher, self.flinger)
|
line.tags, outers[0], road_matcher, self.flinger, self.scheme
|
||||||
)
|
)
|
||||||
|
self.roads.append(road)
|
||||||
return
|
return
|
||||||
|
|
||||||
processed: set[str] = set()
|
processed: set[str] = set()
|
||||||
|
|
|
@ -24,7 +24,7 @@ from map_machine.geometry.vector import (
|
||||||
turn_by_angle,
|
turn_by_angle,
|
||||||
)
|
)
|
||||||
from map_machine.osm.osm_reader import OSMNode, Tagged
|
from map_machine.osm.osm_reader import OSMNode, Tagged
|
||||||
from map_machine.scheme import RoadMatcher
|
from map_machine.scheme import RoadMatcher, Scheme
|
||||||
|
|
||||||
__author__ = "Sergey Vartanov"
|
__author__ = "Sergey Vartanov"
|
||||||
__email__ = "me@enzet.ru"
|
__email__ = "me@enzet.ru"
|
||||||
|
@ -372,6 +372,7 @@ class Road(Tagged):
|
||||||
nodes: list[OSMNode],
|
nodes: list[OSMNode],
|
||||||
matcher: RoadMatcher,
|
matcher: RoadMatcher,
|
||||||
flinger: Flinger,
|
flinger: Flinger,
|
||||||
|
scheme: Scheme,
|
||||||
) -> None:
|
) -> None:
|
||||||
super().__init__(tags)
|
super().__init__(tags)
|
||||||
self.nodes: list[OSMNode] = nodes
|
self.nodes: list[OSMNode] = nodes
|
||||||
|
@ -385,6 +386,8 @@ class Road(Tagged):
|
||||||
|
|
||||||
self.scale: float = flinger.get_scale(self.nodes[0].coordinates)
|
self.scale: float = flinger.get_scale(self.nodes[0].coordinates)
|
||||||
|
|
||||||
|
self.is_area = scheme.is_area(tags) and nodes[0] == nodes[-1]
|
||||||
|
|
||||||
if "lanes" in tags:
|
if "lanes" in tags:
|
||||||
try:
|
try:
|
||||||
self.width = int(tags["lanes"]) * DEFAULT_LANE_WIDTH
|
self.width = int(tags["lanes"]) * DEFAULT_LANE_WIDTH
|
||||||
|
@ -483,7 +486,7 @@ class Road(Tagged):
|
||||||
extra_width = 4.0
|
extra_width = 4.0
|
||||||
|
|
||||||
fill: str = "none"
|
fill: str = "none"
|
||||||
if self.tags.get("area") == "yes":
|
if self.is_area:
|
||||||
fill = color.hex
|
fill = color.hex
|
||||||
|
|
||||||
style: dict[str, Union[int, float, str]] = {
|
style: dict[str, Union[int, float, str]] = {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue