Skip to content

Commit

Permalink
Issue #11: fix user and time modes.
Browse files Browse the repository at this point in the history
  • Loading branch information
enzet committed Aug 26, 2020
1 parent f452a08 commit f88f3b9
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 16 deletions.
6 changes: 5 additions & 1 deletion roentgen/constructor.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ def construct_way(
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,
Expand Down Expand Up @@ -629,8 +631,10 @@ def construct_nodes(self):

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):
Expand Down Expand Up @@ -664,4 +668,4 @@ def construct_nodes(self):
# 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) + " %).")
8 changes: 5 additions & 3 deletions roentgen/extract_icon.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ def get_path(self, id_: str) -> (str, float, float):
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_}")
28 changes: 16 additions & 12 deletions roentgen/mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,11 +288,11 @@ def draw(self, nodes, ways, points):
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

Expand Down Expand Up @@ -360,20 +360,24 @@ def draw(self, nodes, ways, points):
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)
Expand Down

0 comments on commit f88f3b9

Please sign in to comment.