mirror of
https://github.com/enzet/map-machine.git
synced 2025-08-06 10:09:52 +02:00
Issue #45: refactor road specification in scheme.
Add special "road" part and move road specifications from the "ways". Add road matcher. We should remove "priority" key and use specifications order instead in the future.
This commit is contained in:
parent
38925e3a71
commit
9d41b34214
4 changed files with 171 additions and 266 deletions
|
@ -19,7 +19,7 @@ from roentgen.osm_reader import (
|
|||
Map, OSMMember, OSMNode, OSMRelation, OSMWay, Tagged
|
||||
)
|
||||
from roentgen.point import Point
|
||||
from roentgen.scheme import DEFAULT_COLOR, LineStyle, Scheme
|
||||
from roentgen.scheme import DEFAULT_COLOR, LineStyle, Scheme, RoadMatcher
|
||||
from roentgen.util import MinMax
|
||||
|
||||
__author__ = "Sergey Vartanov"
|
||||
|
@ -30,12 +30,6 @@ TIME_COLOR_SCALE: List[Color] = [
|
|||
Color("#581845"), Color("#900C3F"), Color("#C70039"), Color("#FF5733"),
|
||||
Color("#FFC300"), Color("#DAF7A6")
|
||||
]
|
||||
ROAD_HIGHWAY_VALUES: List[str] = [
|
||||
"motorway", "trunk", "primary", "secondary", "tertiary", "unclassified",
|
||||
"residential", "motorway_link", "trunk_link", "primary_link",
|
||||
"secondary_link", "tertiary_link", "living_street", "service",
|
||||
"pedestrian", "track", "bus_guideway", "escape", "raceway", "road", "busway"
|
||||
]
|
||||
|
||||
|
||||
def is_clockwise(polygon: List[OSMNode]) -> bool:
|
||||
|
@ -175,11 +169,10 @@ class Road(Figure):
|
|||
"""
|
||||
|
||||
def __init__(
|
||||
self, tags: Dict[str, str], inners, outers, flinger: Flinger,
|
||||
line_styles: List[LineStyle]
|
||||
self, tags: Dict[str, str], inners, outers, matcher
|
||||
):
|
||||
super().__init__(tags, inners, outers, None)
|
||||
self.line_styles = line_styles
|
||||
self.matcher: RoadMatcher = matcher
|
||||
|
||||
|
||||
def line_center(nodes: List[OSMNode], flinger: Flinger) -> np.array:
|
||||
|
@ -387,12 +380,10 @@ class Constructor:
|
|||
Building(line.tags, inners, outers, self.flinger, self.scheme)
|
||||
)
|
||||
|
||||
if (
|
||||
"highway" in line.tags
|
||||
and line.tags["highway"] in ROAD_HIGHWAY_VALUES
|
||||
):
|
||||
road_matcher = self.scheme.get_road(line.tags)
|
||||
if road_matcher:
|
||||
self.roads.append(
|
||||
Road(line.tags, inners, outers, self.flinger, line_styles)
|
||||
Road(line.tags, inners, outers, road_matcher)
|
||||
)
|
||||
return
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue