Move building style from scheme.

This commit is contained in:
Sergey Vartanov 2021-05-27 00:53:01 +03:00
parent ff88424a34
commit 579940d75f
3 changed files with 41 additions and 25 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 167 KiB

After

Width:  |  Height:  |  Size: 167 KiB

Before After
Before After

View file

@ -136,9 +136,12 @@ class Building(Figure):
def __init__( def __init__(
self, tags: Dict[str, str], inners, outers, flinger: Flinger, self, tags: Dict[str, str], inners, outers, flinger: Flinger,
line_style: LineStyle scheme: Scheme
): ):
super().__init__(tags, inners, outers, line_style) super().__init__(tags, inners, outers, LineStyle({
"fill": scheme.get_color("building_color").hex,
"stroke": scheme.get_color("building_border_color").hex,
}))
self.parts = [] self.parts = []
@ -160,6 +163,18 @@ class Building(Figure):
return 3 return 3
class Road(Figure):
"""
Road or track on the map.
"""
def __init__(
self, tags: Dict[str, str], inners, outers, flinger: Flinger,
line_style: LineStyle
):
super().__init__(tags, inners, outers, line_style)
def line_center(nodes: List[OSMNode], flinger: Flinger) -> np.array: def line_center(nodes: List[OSMNode], flinger: Flinger) -> np.array:
""" """
Get geometric center of nodes set. Get geometric center of nodes set.
@ -278,6 +293,7 @@ class Constructor:
self.points: List[Point] = [] self.points: List[Point] = []
self.figures: List[Figure] = [] self.figures: List[Figure] = []
self.buildings: List[Building] = [] self.buildings: List[Building] = []
self.roads: List[Road] = []
self.levels: Set[float] = {0.5, 1.0} self.levels: Set[float] = {0.5, 1.0}
@ -304,7 +320,8 @@ class Constructor:
for way_id in self.map_.way_map: # type: int for way_id in self.map_.way_map: # type: int
ui.progress_bar( ui.progress_bar(
way_number, len(self.map_.way_map), step=10, way_number, len(self.map_.way_map), step=10,
text="Constructing ways") text="Constructing ways"
)
way_number += 1 way_number += 1
way: OSMWay = self.map_.way_map[way_id] way: OSMWay = self.map_.way_map[way_id]
if not self.check_level(way.tags): if not self.check_level(way.tags):
@ -314,8 +331,10 @@ class Constructor:
ui.progress_bar(-1, len(self.map_.way_map), text="Constructing ways") ui.progress_bar(-1, len(self.map_.way_map), text="Constructing ways")
def construct_line( def construct_line(
self, line: Optional[Tagged], self,
inners: List[List[OSMNode]], outers: List[List[OSMNode]] line: Optional[Tagged],
inners: List[List[OSMNode]],
outers: List[List[OSMNode]],
) -> None: ) -> None:
""" """
Way or relation construction. Way or relation construction.
@ -327,8 +346,8 @@ class Constructor:
assert len(outers) >= 1 assert len(outers) >= 1
center_point, center_coordinates = ( center_point, center_coordinates = (
line_center(outers[0], self.flinger)) line_center(outers[0], self.flinger)
)
if self.mode == "user-coloring": if self.mode == "user-coloring":
user_color = get_user_color(line.user, self.seed) user_color = get_user_color(line.user, self.seed)
self.figures.append(Figure( self.figures.append(Figure(
@ -356,14 +375,16 @@ class Constructor:
line_styles: List[LineStyle] = self.scheme.get_style(line.tags, scale) line_styles: List[LineStyle] = self.scheme.get_style(line.tags, scale)
if "building" in line.tags:
self.add_building(
Building(line.tags, inners, outers, self.flinger, self.scheme)
)
for line_style in line_styles: # type: LineStyle for line_style in line_styles: # type: LineStyle
if "building" in line.tags: self.figures.append(
self.add_building(Building( Figure(line.tags, inners, outers, line_style)
line.tags, inners, outers, self.flinger, line_style )
))
else:
self.figures.append(
Figure(line.tags, inners, outers, line_style))
if ( if (
line.get_tag("area") == "yes" or line.get_tag("area") == "yes" or
is_cycle(outers[0]) and line.get_tag("area") != "no" and is_cycle(outers[0]) and line.get_tag("area") != "no" and
@ -384,10 +405,13 @@ class Constructor:
if not line_styles: if not line_styles:
if DEBUG: if DEBUG:
style: Dict[str, Any] = { style: Dict[str, Any] = {
"fill": "none", "stroke": Color("red").hex, "fill": "none",
"stroke-width": 1} "stroke": Color("red").hex,
"stroke-width": 1
}
self.figures.append(Figure( self.figures.append(Figure(
line.tags, inners, outers, LineStyle(style, 1000))) line.tags, inners, outers, LineStyle(style, 1000)
))
priority: int priority: int
icon_set: IconSet icon_set: IconSet

View file

@ -1001,14 +1001,6 @@ ways:
fill: hidden_color fill: hidden_color
opacity: 0.05 opacity: 0.05
- tags: {building: "*"}
style:
fill: building_color
stroke: building_border_color
#- tags: {building:part: "*"}
# fill: building_color
# stroke: building_border_color
- tags: {amenity: ferry_terminal} - tags: {amenity: ferry_terminal}
style: style:
fill: ferry_terminal_color fill: ferry_terminal_color