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
if self.mode == "user-coloring":
if not way:
return
user_color = get_user_color(way.user, self.seed)
self.ways.append(
Way("way", nodes, path,
@ -629,8 +631,10 @@ class Constructor:
if self.mode == "user-coloring":
fill = get_user_color(node.user, self.seed)
shapes = ["small"]
if self.mode == "time":
fill = get_time_color(node.timestamp)
shapes = ["small"]
# for k in tags:
# if k in processed or self.no_draw(k):
@ -664,4 +668,4 @@ class Constructor:
# print("Tags processed: " + str(processed_tags) + ", tags skipped: " +
# str(skipped_tags) + " (" +
# str(processed_tags / float(
# processed_tags + skipped_tags) * 100) + " %).")
# processed_tags + skipped_tags) * 100) + " %).")

View file

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