Issue #11: fix user and time modes.

This commit is contained in:
Sergey Vartanov 2020-08-26 09:54:15 +03:00
parent f452a08177
commit f88f3b9f50
3 changed files with 26 additions and 16 deletions

View file

@ -219,6 +219,8 @@ class Constructor:
nodes = way.nodes nodes = way.nodes
if self.mode == "user-coloring": if self.mode == "user-coloring":
if not way:
return
user_color = get_user_color(way.user, self.seed) user_color = get_user_color(way.user, self.seed)
self.ways.append( self.ways.append(
Way("way", nodes, path, Way("way", nodes, path,
@ -629,8 +631,10 @@ class Constructor:
if self.mode == "user-coloring": if self.mode == "user-coloring":
fill = get_user_color(node.user, self.seed) fill = get_user_color(node.user, self.seed)
shapes = ["small"]
if self.mode == "time": if self.mode == "time":
fill = get_time_color(node.timestamp) fill = get_time_color(node.timestamp)
shapes = ["small"]
# for k in tags: # for k in tags:
# if k in processed or self.no_draw(k): # if k in processed or self.no_draw(k):

View file

@ -64,6 +64,8 @@ class IconExtractor:
if id_ in self.icons: if id_ in self.icons:
return self.icons[id_] return self.icons[id_]
else: else:
if id_ != "no": if id_ == "no":
ui.error(f"no such icon ID {id_}") return "M 4,4 L 4,10 10,10 10,4 z", 0, 0
return "M 4,4 L 4,10 10,10 10,4 z", 0, 0 if id_ == "small":
return "M 6,6 L 6,8 8,8 8,6 z", 0, 0
ui.error(f"no such icon ID {id_}")

View file

@ -288,11 +288,11 @@ class Painter:
if way.kind == "way": if way.kind == "way":
if way.nodes: if way.nodes:
path = get_path(way.nodes, [0, 0], self.map_, self.flinger) path = get_path(way.nodes, [0, 0], self.map_, self.flinger)
self.output_file.write(f'<path d="{path}" ' + self.output_file.write(
'style="' + way.style + '" />\n') f'<path d="{path}" style="' + way.style + '" />\n')
else: else:
self.output_file.write('<path d="' + way.path + '" ' + self.output_file.write(
'style="' + way.style + '" />\n') f'<path d="{way.path}" style="' + way.style + '" />\n')
# Building shade # Building shade
@ -360,20 +360,24 @@ class Painter:
node.tags["natural"] == "tree" and \ node.tags["natural"] == "tree" and \
"diameter_crown" in node.tags: "diameter_crown" in node.tags:
continue continue
self.draw_shapes(node.shapes, points, node.x, node.y, self.draw_shapes(
node.color, node.tags, node.processed) node.shapes, points, node.x, node.y, node.color, node.tags,
node.processed)
for node in nodes: for node in nodes:
self.draw_texts(node.shapes, points, node.x, node.y, if self.mode not in ["time", "user-coloring"]:
node.color, node.tags, node.processed) self.draw_texts(
node.shapes, points, node.x, node.y, node.color,
node.tags, node.processed)
def draw_point_shape(self, name, x, y, fill, tags=None): def draw_point_shape(self, name, x, y, fill, tags=None):
if not isinstance(name, list): if not isinstance(name, list):
name = [name] name = [name]
for one_name in name: if self.mode not in ["time", "user-coloring"]:
shape, xx, yy = self.icons.get_path(one_name) for one_name in name:
self.draw_point_outline( shape, xx, yy = self.icons.get_path(one_name)
shape, x, y, fill, mode=self.mode, size=16, xx=xx, yy=yy) self.draw_point_outline(
shape, x, y, fill, mode=self.mode, size=16, xx=xx, yy=yy)
for one_name in name: for one_name in name:
shape, xx, yy = self.icons.get_path(one_name) shape, xx, yy = self.icons.get_path(one_name)
self.draw_point(shape, x, y, fill, size=16, xx=xx, yy=yy, tags=tags) self.draw_point(shape, x, y, fill, size=16, xx=xx, yy=yy, tags=tags)