mirror of
https://github.com/enzet/map-machine.git
synced 2025-08-06 10:09:52 +02:00
Reformat with Black.
This commit is contained in:
parent
e52acd30a1
commit
4228146eca
6 changed files with 73 additions and 28 deletions
|
@ -247,7 +247,7 @@ def write_mapcss() -> None:
|
||||||
Write MapCSS 0.2 scheme.
|
Write MapCSS 0.2 scheme.
|
||||||
"""
|
"""
|
||||||
out_path: Path = Path("out")
|
out_path: Path = Path("out")
|
||||||
directory: Path = (out_path / "roentgen_icons_mapcss")
|
directory: Path = out_path / "roentgen_icons_mapcss"
|
||||||
directory.mkdir(exist_ok=True)
|
directory.mkdir(exist_ok=True)
|
||||||
icons_with_outline_path: Path = directory / "icons"
|
icons_with_outline_path: Path = directory / "icons"
|
||||||
|
|
||||||
|
|
|
@ -136,9 +136,13 @@ class Painter:
|
||||||
Draw trunk and circumference.
|
Draw trunk and circumference.
|
||||||
"""
|
"""
|
||||||
for node in constructor.points:
|
for node in constructor.points:
|
||||||
if not (node.get_tag("natural") == "tree" and
|
if not (
|
||||||
("diameter_crown" in node.tags or
|
node.get_tag("natural") == "tree"
|
||||||
"circumference" in node.tags)):
|
and (
|
||||||
|
"diameter_crown" in node.tags
|
||||||
|
or "circumference" in node.tags
|
||||||
|
)
|
||||||
|
):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
scale: float = self.flinger.get_scale(node.coordinates)
|
scale: float = self.flinger.get_scale(node.coordinates)
|
||||||
|
@ -250,8 +254,8 @@ class Painter:
|
||||||
if "angle" in node.tags:
|
if "angle" in node.tags:
|
||||||
angle = float(node.get_tag("angle"))
|
angle = float(node.get_tag("angle"))
|
||||||
direction_radius: float = 25
|
direction_radius: float = 25
|
||||||
direction_color: Color = (
|
direction_color: Color = self.scheme.get_color(
|
||||||
self.scheme.get_color("direction_camera_color")
|
"direction_camera_color"
|
||||||
)
|
)
|
||||||
elif node.get_tag("traffic_sign") == "stop":
|
elif node.get_tag("traffic_sign") == "stop":
|
||||||
direction = node.get_tag("direction")
|
direction = node.get_tag("direction")
|
||||||
|
@ -260,8 +264,8 @@ class Painter:
|
||||||
else:
|
else:
|
||||||
direction = node.get_tag("direction")
|
direction = node.get_tag("direction")
|
||||||
direction_radius: float = 50
|
direction_radius: float = 50
|
||||||
direction_color: Color = (
|
direction_color: Color = self.scheme.get_color(
|
||||||
self.scheme.get_color("direction_view_color")
|
"direction_view_color"
|
||||||
)
|
)
|
||||||
is_revert_gradient = True
|
is_revert_gradient = True
|
||||||
|
|
||||||
|
|
|
@ -192,9 +192,9 @@ class Point(Tagged):
|
||||||
text = text.replace(""", '"')
|
text = text.replace(""", '"')
|
||||||
text = text.replace("&", "&")
|
text = text.replace("&", "&")
|
||||||
text = text[:26] + ("..." if len(text) > 26 else "")
|
text = text[:26] + ("..." if len(text) > 26 else "")
|
||||||
|
point = self.point + np.array((0, self.y + 2))
|
||||||
self.draw_text(
|
self.draw_text(
|
||||||
svg, text, self.point + np.array((0, self.y + 2)),
|
svg, text, point, occupied, label.fill, size=label.size
|
||||||
occupied, label.fill, size=label.size
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def draw_text(
|
def draw_text(
|
||||||
|
|
|
@ -113,7 +113,10 @@ class RoadPart:
|
||||||
self.left_projection = (
|
self.left_projection = (
|
||||||
self.right_connection - self.right_vector + self.left_vector
|
self.right_connection - self.right_vector + self.left_vector
|
||||||
)
|
)
|
||||||
if self.left_connection is not None and self.right_connection is not None:
|
if (
|
||||||
|
self.left_connection is not None
|
||||||
|
and self.right_connection is not None
|
||||||
|
):
|
||||||
a = np.linalg.norm(self.right_connection - self.point_1)
|
a = np.linalg.norm(self.right_connection - self.point_1)
|
||||||
b = np.linalg.norm(self.right_projection - self.point_1)
|
b = np.linalg.norm(self.right_projection - self.point_1)
|
||||||
if a > b:
|
if a > b:
|
||||||
|
@ -127,7 +130,9 @@ class RoadPart:
|
||||||
max_: float = 100
|
max_: float = 100
|
||||||
|
|
||||||
if np.linalg.norm(self.point_middle - self.point_1) > max_:
|
if np.linalg.norm(self.point_middle - self.point_1) > max_:
|
||||||
self.point_a = self.point_1 + max_ * norm(self.point_middle - self.point_1)
|
self.point_a = self.point_1 + max_ * norm(
|
||||||
|
self.point_middle - self.point_1
|
||||||
|
)
|
||||||
self.right_outer = self.point_a + self.right_vector
|
self.right_outer = self.point_a + self.right_vector
|
||||||
self.left_outer = self.point_a + self.left_vector
|
self.left_outer = self.point_a + self.left_vector
|
||||||
else:
|
else:
|
||||||
|
@ -186,24 +191,46 @@ class RoadPart:
|
||||||
radius: float = 2
|
radius: float = 2
|
||||||
|
|
||||||
if self.right_connection is not None:
|
if self.right_connection is not None:
|
||||||
circle = drawing.circle(self.right_connection, 2.5, fill="#FF0000", opacity=opacity)
|
circle = drawing.circle(
|
||||||
|
self.right_connection, 2.5, fill="#FF0000", opacity=opacity
|
||||||
|
)
|
||||||
drawing.add(circle)
|
drawing.add(circle)
|
||||||
if self.left_connection is not None:
|
if self.left_connection is not None:
|
||||||
circle = drawing.circle(self.left_connection, 2.5, fill="#0000FF", opacity=opacity)
|
circle = drawing.circle(
|
||||||
|
self.left_connection, 2.5, fill="#0000FF", opacity=opacity
|
||||||
|
)
|
||||||
drawing.add(circle)
|
drawing.add(circle)
|
||||||
|
|
||||||
if self.right_projection is not None:
|
if self.right_projection is not None:
|
||||||
circle = drawing.circle(self.right_projection, 1.5, fill="#FF0000", opacity=opacity)
|
circle = drawing.circle(
|
||||||
|
self.right_projection, 1.5, fill="#FF0000", opacity=opacity
|
||||||
|
)
|
||||||
drawing.add(circle)
|
drawing.add(circle)
|
||||||
if self.left_projection is not None:
|
if self.left_projection is not None:
|
||||||
circle = drawing.circle(self.left_projection, 1.5, fill="#0000FF", opacity=opacity)
|
circle = drawing.circle(
|
||||||
|
self.left_projection, 1.5, fill="#0000FF", opacity=opacity
|
||||||
|
)
|
||||||
drawing.add(circle)
|
drawing.add(circle)
|
||||||
|
|
||||||
if self.right_outer is not None:
|
if self.right_outer is not None:
|
||||||
circle = drawing.circle(self.right_outer, 3.5, stroke_width=0.5, fill="none", stroke="#FF0000", opacity=opacity)
|
circle = drawing.circle(
|
||||||
|
self.right_outer,
|
||||||
|
3.5,
|
||||||
|
stroke_width=0.5,
|
||||||
|
fill="none",
|
||||||
|
stroke="#FF0000",
|
||||||
|
opacity=opacity,
|
||||||
|
)
|
||||||
drawing.add(circle)
|
drawing.add(circle)
|
||||||
if self.left_outer is not None:
|
if self.left_outer is not None:
|
||||||
circle = drawing.circle(self.left_outer, 3.5, stroke_width=0.5, fill="none", stroke="#0000FF", opacity=opacity)
|
circle = drawing.circle(
|
||||||
|
self.left_outer,
|
||||||
|
3.5,
|
||||||
|
stroke_width=0.5,
|
||||||
|
fill="none",
|
||||||
|
stroke="#0000FF",
|
||||||
|
opacity=opacity,
|
||||||
|
)
|
||||||
drawing.add(circle)
|
drawing.add(circle)
|
||||||
|
|
||||||
if self.point_a is not None:
|
if self.point_a is not None:
|
||||||
|
@ -230,7 +257,10 @@ class RoadPart:
|
||||||
"""
|
"""
|
||||||
Draw intersection entrance part.
|
Draw intersection entrance part.
|
||||||
"""
|
"""
|
||||||
if self.left_connection is not None and self.right_connection is not None:
|
if (
|
||||||
|
self.left_connection is not None
|
||||||
|
and self.right_connection is not None
|
||||||
|
):
|
||||||
path_commands = [
|
path_commands = [
|
||||||
"M", self.right_projection,
|
"M", self.right_projection,
|
||||||
"L", self.right_connection,
|
"L", self.right_connection,
|
||||||
|
@ -240,7 +270,10 @@ class RoadPart:
|
||||||
]
|
]
|
||||||
if is_debug:
|
if is_debug:
|
||||||
path = drawing.path(
|
path = drawing.path(
|
||||||
path_commands, fill="none", stroke="#880088", stroke_width=0.5
|
path_commands,
|
||||||
|
fill="none",
|
||||||
|
stroke="#880088",
|
||||||
|
stroke_width=0.5,
|
||||||
)
|
)
|
||||||
drawing.add(path)
|
drawing.add(path)
|
||||||
else:
|
else:
|
||||||
|
@ -331,8 +364,12 @@ class Intersection:
|
||||||
# part.draw_normal(drawing)
|
# part.draw_normal(drawing)
|
||||||
|
|
||||||
if is_debug:
|
if is_debug:
|
||||||
drawing.add(drawing.path(outer_commands, fill="#0000FF", opacity=0.2))
|
drawing.add(
|
||||||
drawing.add(drawing.path(inner_commands, fill="#FF0000", opacity=0.2))
|
drawing.path(outer_commands, fill="#0000FF", opacity=0.2)
|
||||||
|
)
|
||||||
|
drawing.add(
|
||||||
|
drawing.path(inner_commands, fill="#FF0000", opacity=0.2)
|
||||||
|
)
|
||||||
|
|
||||||
for part in self.parts:
|
for part in self.parts:
|
||||||
if is_debug:
|
if is_debug:
|
||||||
|
|
|
@ -85,24 +85,28 @@ def get_text(tags: Dict[str, Any], processed: Set[str]) -> List[Label]:
|
||||||
Get text representation of writable tags.
|
Get text representation of writable tags.
|
||||||
"""
|
"""
|
||||||
texts: List[Label] = []
|
texts: List[Label] = []
|
||||||
|
|
||||||
values: List[str] = []
|
values: List[str] = []
|
||||||
|
|
||||||
if "voltage:primary" in tags:
|
if "voltage:primary" in tags:
|
||||||
values.append(tags["voltage:primary"])
|
values.append(tags["voltage:primary"])
|
||||||
processed.add("voltage:primary")
|
processed.add("voltage:primary")
|
||||||
|
|
||||||
if "voltage:secondary" in tags:
|
if "voltage:secondary" in tags:
|
||||||
values.append(tags["voltage:secondary"])
|
values.append(tags["voltage:secondary"])
|
||||||
processed.add("voltage:secondary")
|
processed.add("voltage:secondary")
|
||||||
|
|
||||||
if "voltage" in tags:
|
if "voltage" in tags:
|
||||||
values = tags["voltage"].split(";")
|
values = tags["voltage"].split(";")
|
||||||
processed.add("voltage")
|
processed.add("voltage")
|
||||||
|
|
||||||
if values:
|
if values:
|
||||||
texts.append(Label(", ".join(map(format_voltage, values))))
|
texts.append(Label(", ".join(map(format_voltage, values))))
|
||||||
|
|
||||||
if "frequency" in tags:
|
if "frequency" in tags:
|
||||||
texts.append(Label(", ".join(map(
|
text: str = ", ".join(
|
||||||
format_frequency, tags["frequency"].split(";")
|
map(format_frequency, tags["frequency"].split(";"))
|
||||||
))))
|
)
|
||||||
|
texts.append(Label(text))
|
||||||
processed.add("frequency")
|
processed.add("frequency")
|
||||||
|
|
||||||
return texts
|
return texts
|
||||||
|
|
|
@ -76,7 +76,7 @@ def add_render_arguments(render) -> None:
|
||||||
"--boundary-box",
|
"--boundary-box",
|
||||||
metavar="<lon1>,<lat1>,<lon2>,<lat2>",
|
metavar="<lon1>,<lat1>,<lon2>,<lat2>",
|
||||||
help='geo boundary box, use space before "-" if the first value is '
|
help='geo boundary box, use space before "-" if the first value is '
|
||||||
'negative',
|
"negative",
|
||||||
)
|
)
|
||||||
render.add_argument(
|
render.add_argument(
|
||||||
"-s",
|
"-s",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue