mirror of
https://github.com/enzet/map-machine.git
synced 2025-05-01 11:17:48 +02:00
Issue #84: fix code style.
This commit is contained in:
parent
3187906e62
commit
e0988fbe0f
2 changed files with 25 additions and 19 deletions
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
echo "Checking code format with Black..."
|
echo "Checking code format with Black..."
|
||||||
if ! black -l 80 --check tests map_machine; then
|
if ! black -l 80 --check tests map_machine; then
|
||||||
black -l 80 --diff tests map_machine
|
black -l 80 --diff --color tests map_machine
|
||||||
echo "FAIL"
|
echo "FAIL"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -9,6 +9,7 @@ import svgwrite
|
||||||
from colour import Color
|
from colour import Color
|
||||||
from svgwrite import Drawing
|
from svgwrite import Drawing
|
||||||
from svgwrite.path import Path
|
from svgwrite.path import Path
|
||||||
|
from svgwrite.shapes import Circle
|
||||||
|
|
||||||
from map_machine.drawing import PathCommands
|
from map_machine.drawing import PathCommands
|
||||||
from map_machine.flinger import Flinger
|
from map_machine.flinger import Flinger
|
||||||
|
@ -568,30 +569,35 @@ class ComplexConnector(Connector):
|
||||||
node: OSMNode = road_1.nodes[index_1]
|
node: OSMNode = road_1.nodes[index_1]
|
||||||
point: np.ndarray = flinger.fling(node.coordinates)
|
point: np.ndarray = flinger.fling(node.coordinates)
|
||||||
|
|
||||||
c1: list[np.ndarray] = get_curve_points(
|
points_1: list[np.ndarray] = get_curve_points(
|
||||||
road_1, scale, point, road_1.line.points[index_1]
|
road_1, scale, point, road_1.line.points[index_1]
|
||||||
)
|
)
|
||||||
c2: list[np.ndarray] = get_curve_points(
|
points_2: list[np.ndarray] = get_curve_points(
|
||||||
road_2, scale, point, road_2.line.points[index_2]
|
road_2, scale, point, road_2.line.points[index_2]
|
||||||
)
|
)
|
||||||
self.curve_1: PathCommands = [c1[0], "C", c1[1], c2[2], c2[3]]
|
# fmt: off
|
||||||
self.curve_2: PathCommands = [c2[0], "C", c2[1], c1[2], c1[3]]
|
self.curve_1: PathCommands = [
|
||||||
|
points_1[0], "C", points_1[1], points_2[2], points_2[3]
|
||||||
|
]
|
||||||
|
self.curve_2: PathCommands = [
|
||||||
|
points_2[0], "C", points_2[1], points_1[2], points_1[3]
|
||||||
|
]
|
||||||
|
# fmt: on
|
||||||
|
|
||||||
def draw(self, svg: Drawing) -> None:
|
def draw(self, svg: Drawing) -> None:
|
||||||
"""Draw connection fill."""
|
"""Draw connection fill."""
|
||||||
circle = svg.circle(
|
for road, index in [
|
||||||
self.road_1.line.points[self.index_1],
|
(self.road_1, self.index_1),
|
||||||
self.road_1.width * self.scale / 2,
|
(self.road_2, self.index_2),
|
||||||
fill=self.road_1.matcher.color.hex,
|
]:
|
||||||
|
circle: Circle = svg.circle(
|
||||||
|
road.line.points[index],
|
||||||
|
road.width * self.scale / 2,
|
||||||
|
fill=road.matcher.color.hex,
|
||||||
)
|
)
|
||||||
svg.add(circle)
|
svg.add(circle)
|
||||||
circle = svg.circle(
|
|
||||||
self.road_2.line.points[self.index_2],
|
path: Path = svg.path(
|
||||||
self.road_2.width * self.scale / 2,
|
|
||||||
fill=self.road_2.matcher.color.hex,
|
|
||||||
)
|
|
||||||
svg.add(circle)
|
|
||||||
path = svg.path(
|
|
||||||
d=["M"] + self.curve_1 + ["L"] + self.curve_2 + ["Z"],
|
d=["M"] + self.curve_1 + ["L"] + self.curve_2 + ["Z"],
|
||||||
fill=self.road_1.matcher.color.hex,
|
fill=self.road_1.matcher.color.hex,
|
||||||
)
|
)
|
||||||
|
@ -599,7 +605,7 @@ class ComplexConnector(Connector):
|
||||||
|
|
||||||
def draw_border(self, svg: Drawing) -> None:
|
def draw_border(self, svg: Drawing) -> None:
|
||||||
"""Draw connection outline."""
|
"""Draw connection outline."""
|
||||||
path = svg.path(
|
path: Path = svg.path(
|
||||||
d=["M"] + self.curve_1 + ["L"] + self.curve_2 + ["Z"],
|
d=["M"] + self.curve_1 + ["L"] + self.curve_2 + ["Z"],
|
||||||
fill="none",
|
fill="none",
|
||||||
stroke=self.road_1.matcher.border_color.hex,
|
stroke=self.road_1.matcher.border_color.hex,
|
||||||
|
|
Loading…
Add table
Reference in a new issue