mirror of
https://github.com/enzet/map-machine.git
synced 2025-08-02 16:19:20 +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.
|
||||
"""
|
||||
out_path: Path = Path("out")
|
||||
directory: Path = (out_path / "roentgen_icons_mapcss")
|
||||
directory: Path = out_path / "roentgen_icons_mapcss"
|
||||
directory.mkdir(exist_ok=True)
|
||||
icons_with_outline_path: Path = directory / "icons"
|
||||
|
||||
|
|
|
@ -136,9 +136,13 @@ class Painter:
|
|||
Draw trunk and circumference.
|
||||
"""
|
||||
for node in constructor.points:
|
||||
if not (node.get_tag("natural") == "tree" and
|
||||
("diameter_crown" in node.tags or
|
||||
"circumference" in node.tags)):
|
||||
if not (
|
||||
node.get_tag("natural") == "tree"
|
||||
and (
|
||||
"diameter_crown" in node.tags
|
||||
or "circumference" in node.tags
|
||||
)
|
||||
):
|
||||
continue
|
||||
|
||||
scale: float = self.flinger.get_scale(node.coordinates)
|
||||
|
@ -250,8 +254,8 @@ class Painter:
|
|||
if "angle" in node.tags:
|
||||
angle = float(node.get_tag("angle"))
|
||||
direction_radius: float = 25
|
||||
direction_color: Color = (
|
||||
self.scheme.get_color("direction_camera_color")
|
||||
direction_color: Color = self.scheme.get_color(
|
||||
"direction_camera_color"
|
||||
)
|
||||
elif node.get_tag("traffic_sign") == "stop":
|
||||
direction = node.get_tag("direction")
|
||||
|
@ -260,8 +264,8 @@ class Painter:
|
|||
else:
|
||||
direction = node.get_tag("direction")
|
||||
direction_radius: float = 50
|
||||
direction_color: Color = (
|
||||
self.scheme.get_color("direction_view_color")
|
||||
direction_color: Color = self.scheme.get_color(
|
||||
"direction_view_color"
|
||||
)
|
||||
is_revert_gradient = True
|
||||
|
||||
|
|
|
@ -192,9 +192,9 @@ class Point(Tagged):
|
|||
text = text.replace(""", '"')
|
||||
text = text.replace("&", "&")
|
||||
text = text[:26] + ("..." if len(text) > 26 else "")
|
||||
point = self.point + np.array((0, self.y + 2))
|
||||
self.draw_text(
|
||||
svg, text, self.point + np.array((0, self.y + 2)),
|
||||
occupied, label.fill, size=label.size
|
||||
svg, text, point, occupied, label.fill, size=label.size
|
||||
)
|
||||
|
||||
def draw_text(
|
||||
|
|
|
@ -113,7 +113,10 @@ class RoadPart:
|
|||
self.left_projection = (
|
||||
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)
|
||||
b = np.linalg.norm(self.right_projection - self.point_1)
|
||||
if a > b:
|
||||
|
@ -127,7 +130,9 @@ class RoadPart:
|
|||
max_: float = 100
|
||||
|
||||
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.left_outer = self.point_a + self.left_vector
|
||||
else:
|
||||
|
@ -186,24 +191,46 @@ class RoadPart:
|
|||
radius: float = 2
|
||||
|
||||
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)
|
||||
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)
|
||||
|
||||
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)
|
||||
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)
|
||||
|
||||
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)
|
||||
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)
|
||||
|
||||
if self.point_a is not None:
|
||||
|
@ -230,7 +257,10 @@ class RoadPart:
|
|||
"""
|
||||
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 = [
|
||||
"M", self.right_projection,
|
||||
"L", self.right_connection,
|
||||
|
@ -240,7 +270,10 @@ class RoadPart:
|
|||
]
|
||||
if is_debug:
|
||||
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)
|
||||
else:
|
||||
|
@ -331,8 +364,12 @@ class Intersection:
|
|||
# part.draw_normal(drawing)
|
||||
|
||||
if is_debug:
|
||||
drawing.add(drawing.path(outer_commands, fill="#0000FF", opacity=0.2))
|
||||
drawing.add(drawing.path(inner_commands, fill="#FF0000", opacity=0.2))
|
||||
drawing.add(
|
||||
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:
|
||||
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.
|
||||
"""
|
||||
texts: List[Label] = []
|
||||
|
||||
values: List[str] = []
|
||||
|
||||
if "voltage:primary" in tags:
|
||||
values.append(tags["voltage:primary"])
|
||||
processed.add("voltage:primary")
|
||||
|
||||
if "voltage:secondary" in tags:
|
||||
values.append(tags["voltage:secondary"])
|
||||
processed.add("voltage:secondary")
|
||||
processed.add("voltage:secondary")
|
||||
|
||||
if "voltage" in tags:
|
||||
values = tags["voltage"].split(";")
|
||||
processed.add("voltage")
|
||||
|
||||
if values:
|
||||
texts.append(Label(", ".join(map(format_voltage, values))))
|
||||
|
||||
if "frequency" in tags:
|
||||
texts.append(Label(", ".join(map(
|
||||
format_frequency, tags["frequency"].split(";")
|
||||
))))
|
||||
text: str = ", ".join(
|
||||
map(format_frequency, tags["frequency"].split(";"))
|
||||
)
|
||||
texts.append(Label(text))
|
||||
processed.add("frequency")
|
||||
|
||||
return texts
|
||||
|
|
|
@ -76,7 +76,7 @@ def add_render_arguments(render) -> None:
|
|||
"--boundary-box",
|
||||
metavar="<lon1>,<lat1>,<lon2>,<lat2>",
|
||||
help='geo boundary box, use space before "-" if the first value is '
|
||||
'negative',
|
||||
"negative",
|
||||
)
|
||||
render.add_argument(
|
||||
"-s",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue