mirror of
https://github.com/enzet/map-machine.git
synced 2025-05-21 04:56:24 +02:00
Fix Pylint warnings.
This commit is contained in:
parent
d2b208ea51
commit
5746edaa3f
22 changed files with 94 additions and 197 deletions
|
@ -152,9 +152,7 @@ def try_to_glue(
|
||||||
|
|
||||||
|
|
||||||
class Constructor:
|
class Constructor:
|
||||||
"""
|
"""Map Machine node and way constructor."""
|
||||||
Map Machine node and way constructor.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
|
|
@ -116,9 +116,9 @@ class ArgumentParser(argparse.ArgumentParser):
|
||||||
class MapMachineMoire(Default, ABC):
|
class MapMachineMoire(Default, ABC):
|
||||||
"""Moire extension stub for Map Machine."""
|
"""Moire extension stub for Map Machine."""
|
||||||
|
|
||||||
def osm(self, args: Arguments) -> str:
|
def osm(self, arg: Arguments) -> str:
|
||||||
"""OSM tag key or key–value pair of tag."""
|
"""OSM tag key or key–value pair of tag."""
|
||||||
spec: str = self.clear(args[0])
|
spec: str = self.clear(arg[0])
|
||||||
if "=" in spec:
|
if "=" in spec:
|
||||||
key, tag = spec.split("=")
|
key, tag = spec.split("=")
|
||||||
return (
|
return (
|
||||||
|
@ -129,26 +129,26 @@ class MapMachineMoire(Default, ABC):
|
||||||
|
|
||||||
return self.get_ref_(f"{PREFIX}Key:{spec}", self.m([spec]))
|
return self.get_ref_(f"{PREFIX}Key:{spec}", self.m([spec]))
|
||||||
|
|
||||||
def color(self, args: Arguments) -> str:
|
def color(self, arg: Arguments) -> str:
|
||||||
"""Simple color sample."""
|
"""Simple color sample."""
|
||||||
raise NotImplementedError("color")
|
raise NotImplementedError("color")
|
||||||
|
|
||||||
def page_icon(self, args: Arguments) -> str:
|
def page_icon(self, arg: Arguments) -> str:
|
||||||
"""HTML page icon."""
|
"""HTML page icon."""
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
def command(self, args: Arguments) -> str:
|
def command(self, arg: Arguments) -> str:
|
||||||
"""Bash command from integration tests."""
|
"""Bash command from integration tests."""
|
||||||
return "map-machine " + " ".join(COMMAND_LINES[self.clear(args[0])])
|
return "map-machine " + " ".join(COMMAND_LINES[self.clear(arg[0])])
|
||||||
|
|
||||||
def icon(self, args: Arguments) -> str:
|
def icon(self, arg: Arguments) -> str:
|
||||||
"""Image with Röntgen icon."""
|
"""Image with Röntgen icon."""
|
||||||
raise NotImplementedError("icon")
|
raise NotImplementedError("icon")
|
||||||
|
|
||||||
def options(self, args: Arguments) -> str:
|
def options(self, arg: Arguments) -> str:
|
||||||
"""Table with option descriptions."""
|
"""Table with option descriptions."""
|
||||||
parser: ArgumentParser = ArgumentParser()
|
parser: ArgumentParser = ArgumentParser()
|
||||||
command: str = self.clear(args[0])
|
command: str = self.clear(arg[0])
|
||||||
if command == "render":
|
if command == "render":
|
||||||
cli.add_render_arguments(parser)
|
cli.add_render_arguments(parser)
|
||||||
elif command == "server":
|
elif command == "server":
|
||||||
|
@ -167,13 +167,13 @@ class MapMachineMoire(Default, ABC):
|
||||||
)
|
)
|
||||||
return self.parse(parser.get_moire_help())
|
return self.parse(parser.get_moire_help())
|
||||||
|
|
||||||
def kbd(self, args: Arguments) -> str:
|
def kbd(self, arg: Arguments) -> str:
|
||||||
"""Keyboard key."""
|
"""Keyboard key."""
|
||||||
return self.m(args)
|
return self.m(arg)
|
||||||
|
|
||||||
def no_wrap(self, args: Arguments) -> str:
|
def no_wrap(self, arg: Arguments) -> str:
|
||||||
"""Do not wrap text at white spaces."""
|
"""Do not wrap text at white spaces."""
|
||||||
return self.parse(args[0])
|
return self.parse(arg[0])
|
||||||
|
|
||||||
|
|
||||||
class MapMachineHTML(MapMachineMoire, DefaultHTML):
|
class MapMachineHTML(MapMachineMoire, DefaultHTML):
|
||||||
|
@ -197,41 +197,39 @@ class MapMachineHTML(MapMachineMoire, DefaultHTML):
|
||||||
content += f"<tr>{cell}</tr>"
|
content += f"<tr>{cell}</tr>"
|
||||||
return f"<table>{content}</table>"
|
return f"<table>{content}</table>"
|
||||||
|
|
||||||
def color(self, args: Arguments) -> str:
|
def color(self, arg: Arguments) -> str:
|
||||||
"""Simple color sample."""
|
"""Simple color sample."""
|
||||||
return (
|
return (
|
||||||
f'<span class="color" '
|
f'<span class="color" '
|
||||||
f'style="background-color: {self.clear(args[0])};"></span>'
|
f'style="background-color: {self.clear(arg[0])};"></span>'
|
||||||
)
|
)
|
||||||
|
|
||||||
def icon(self, args: Arguments) -> str:
|
def icon(self, arg: Arguments) -> str:
|
||||||
"""Image with Röntgen icon."""
|
"""Image with Röntgen icon."""
|
||||||
size: str = self.clear(args[1]) if len(args) > 1 else 16
|
size: str = self.clear(arg[1]) if len(arg) > 1 else 16
|
||||||
return (
|
return (
|
||||||
f'<img class="icon" style="width: {size}px; height: {size}px;" '
|
f'<img class="icon" style="width: {size}px; height: {size}px;" '
|
||||||
f'src="out/icons_by_id/{self.clear(args[0])}.svg" />'
|
f'src="out/icons_by_id/{self.clear(arg[0])}.svg" />'
|
||||||
)
|
)
|
||||||
|
|
||||||
def kbd(self, args: Arguments) -> str:
|
def kbd(self, arg: Arguments) -> str:
|
||||||
"""Keyboard key."""
|
"""Keyboard key."""
|
||||||
return f"<kbd>{self.clear(args[0])}</kbd>"
|
return f"<kbd>{self.clear(arg[0])}</kbd>"
|
||||||
|
|
||||||
def page_icon(self, args: Arguments) -> str:
|
def page_icon(self, arg: Arguments) -> str:
|
||||||
"""HTML page icon."""
|
"""HTML page icon."""
|
||||||
return (
|
return (
|
||||||
f'<link rel="icon" type="image/svg" href="{self.clear(args[0])}"'
|
f'<link rel="icon" type="image/svg" href="{self.clear(arg[0])}"'
|
||||||
' sizes="16x16">'
|
' sizes="16x16">'
|
||||||
)
|
)
|
||||||
|
|
||||||
def no_wrap(self, args: Arguments) -> str:
|
def no_wrap(self, arg: Arguments) -> str:
|
||||||
"""Do not wrap text at white spaces."""
|
"""Do not wrap text at white spaces."""
|
||||||
return (
|
return f'<span style="white-space: nowrap;">{self.parse(arg[0])}</span>'
|
||||||
f'<span style="white-space: nowrap;">{self.parse(args[0])}</span>'
|
|
||||||
)
|
|
||||||
|
|
||||||
def formal(self, args: Arguments) -> str:
|
def formal(self, arg: Arguments) -> str:
|
||||||
"""Formal variable."""
|
"""Formal variable."""
|
||||||
return f'<span class="formal">{self.parse(args[0])}</span>'
|
return f'<span class="formal">{self.parse(arg[0])}</span>'
|
||||||
|
|
||||||
|
|
||||||
class MapMachineOSMWiki(MapMachineMoire, DefaultWiki):
|
class MapMachineOSMWiki(MapMachineMoire, DefaultWiki):
|
||||||
|
@ -248,23 +246,23 @@ class MapMachineOSMWiki(MapMachineMoire, DefaultWiki):
|
||||||
workspace.ICONS_PATH, workspace.ICONS_CONFIG_PATH
|
workspace.ICONS_PATH, workspace.ICONS_CONFIG_PATH
|
||||||
)
|
)
|
||||||
|
|
||||||
def osm(self, args: Arguments) -> str:
|
def osm(self, arg: Arguments) -> str:
|
||||||
"""OSM tag key or key–value pair of tag."""
|
"""OSM tag key or key–value pair of tag."""
|
||||||
spec: str = self.clear(args[0])
|
spec: str = self.clear(arg[0])
|
||||||
if "=" in spec:
|
if "=" in spec:
|
||||||
key, tag = spec.split("=")
|
key, tag = spec.split("=")
|
||||||
return f"{{{{Key|{key}|{tag}}}}}"
|
return f"{{{{Key|{key}|{tag}}}}}"
|
||||||
|
|
||||||
return f"{{{{Tag|{spec}}}}}"
|
return f"{{{{Tag|{spec}}}}}"
|
||||||
|
|
||||||
def color(self, args: Arguments) -> str:
|
def color(self, arg: Arguments) -> str:
|
||||||
"""Simple color sample."""
|
"""Simple color sample."""
|
||||||
return f"{{{{Color box|{self.clear(args[0])}}}}}"
|
return f"{{{{Color box|{self.clear(arg[0])}}}}}"
|
||||||
|
|
||||||
def icon(self, args: Arguments) -> str:
|
def icon(self, arg: Arguments) -> str:
|
||||||
"""Image with Röntgen icon."""
|
"""Image with Röntgen icon."""
|
||||||
size: str = self.clear(args[1]) if len(args) > 1 else 16
|
size: str = self.clear(arg[1]) if len(arg) > 1 else 16
|
||||||
shape_id: str = self.clear(args[0])
|
shape_id: str = self.clear(arg[0])
|
||||||
name: str = self.extractor.get_shape(shape_id).name
|
name: str = self.extractor.get_shape(shape_id).name
|
||||||
return f"[[File:Röntgen {name}.svg|{size}px]]"
|
return f"[[File:Röntgen {name}.svg|{size}px]]"
|
||||||
|
|
||||||
|
@ -274,27 +272,25 @@ class MapMachineMarkdown(MapMachineMoire, DefaultMarkdown):
|
||||||
|
|
||||||
images = {}
|
images = {}
|
||||||
|
|
||||||
def color(self, args: Arguments) -> str:
|
def color(self, arg: Arguments) -> str:
|
||||||
"""Simple color sample."""
|
"""Simple color sample."""
|
||||||
return self.clear(args[0])
|
return self.clear(arg[0])
|
||||||
|
|
||||||
def icon(self, args: Arguments) -> str:
|
def icon(self, arg: Arguments) -> str:
|
||||||
"""Image with Röntgen icon."""
|
"""Image with Röntgen icon."""
|
||||||
return f"[{self.clear(args[0])}]"
|
return f"[{self.clear(arg[0])}]"
|
||||||
|
|
||||||
def kbd(self, args: Arguments) -> str:
|
def kbd(self, arg: Arguments) -> str:
|
||||||
"""Keyboard key."""
|
"""Keyboard key."""
|
||||||
return f"<kbd>{self.clear(args[0])}</kbd>"
|
return f"<kbd>{self.clear(arg[0])}</kbd>"
|
||||||
|
|
||||||
def no_wrap(self, args: Arguments) -> str:
|
def no_wrap(self, arg: Arguments) -> str:
|
||||||
"""Do not wrap text at white spaces."""
|
"""Do not wrap text at white spaces."""
|
||||||
return (
|
return f'<span style="white-space: nowrap;">{self.parse(arg[0])}</span>'
|
||||||
f'<span style="white-space: nowrap;">{self.parse(args[0])}</span>'
|
|
||||||
)
|
|
||||||
|
|
||||||
def formal(self, args: Arguments) -> str:
|
def formal(self, arg: Arguments) -> str:
|
||||||
"""Formal variable."""
|
"""Formal variable."""
|
||||||
return f"<{self.parse(args[0])}>"
|
return f"<{self.parse(arg[0])}>"
|
||||||
|
|
||||||
|
|
||||||
def convert(input_path: Path, output_path: Path) -> None:
|
def convert(input_path: Path, output_path: Path) -> None:
|
||||||
|
|
|
@ -21,9 +21,7 @@ from map_machine.workspace import workspace
|
||||||
|
|
||||||
|
|
||||||
class TaginfoProjectFile:
|
class TaginfoProjectFile:
|
||||||
"""
|
"""JSON structure with OpenStreetMap tag usage."""
|
||||||
JSON structure with OpenStreetMap tag usage.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self, path: Path, scheme: Scheme) -> None:
|
def __init__(self, path: Path, scheme: Scheme) -> None:
|
||||||
self.path: Path = path
|
self.path: Path = path
|
||||||
|
|
|
@ -23,9 +23,7 @@ PathCommands = list[Union[float, str, np.ndarray]]
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class Style:
|
class Style:
|
||||||
"""
|
"""Drawing element style."""
|
||||||
Drawing element style.
|
|
||||||
"""
|
|
||||||
|
|
||||||
fill: Optional[Color] = None
|
fill: Optional[Color] = None
|
||||||
stroke: Optional[Color] = None
|
stroke: Optional[Color] = None
|
||||||
|
@ -60,9 +58,7 @@ class Style:
|
||||||
|
|
||||||
|
|
||||||
class Drawing:
|
class Drawing:
|
||||||
"""
|
"""Image."""
|
||||||
Image.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self, file_path: Path, width: int, height: int) -> None:
|
def __init__(self, file_path: Path, width: int, height: int) -> None:
|
||||||
self.file_path: Path = file_path
|
self.file_path: Path = file_path
|
||||||
|
@ -95,9 +91,7 @@ class Drawing:
|
||||||
|
|
||||||
|
|
||||||
class SVGDrawing(Drawing):
|
class SVGDrawing(Drawing):
|
||||||
"""
|
"""SVG image."""
|
||||||
SVG image.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self, file_path: Path, width: int, height: int) -> None:
|
def __init__(self, file_path: Path, width: int, height: int) -> None:
|
||||||
super().__init__(file_path, width, height)
|
super().__init__(file_path, width, height)
|
||||||
|
@ -145,9 +139,7 @@ class SVGDrawing(Drawing):
|
||||||
|
|
||||||
|
|
||||||
class PNGDrawing(Drawing):
|
class PNGDrawing(Drawing):
|
||||||
"""
|
"""PNG image."""
|
||||||
PNG image.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self, file_path: Path, width: int, height: int) -> None:
|
def __init__(self, file_path: Path, width: int, height: int) -> None:
|
||||||
super().__init__(file_path, width, height)
|
super().__init__(file_path, width, height)
|
||||||
|
|
|
@ -51,9 +51,7 @@ def rotation_matrix(angle: float) -> np.ndarray:
|
||||||
|
|
||||||
|
|
||||||
class Sector:
|
class Sector:
|
||||||
"""
|
"""Sector described by two vectors."""
|
||||||
Sector described by two vectors.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self, text: str, angle: Optional[float] = None) -> None:
|
def __init__(self, text: str, angle: Optional[float] = None) -> None:
|
||||||
"""
|
"""
|
||||||
|
@ -120,9 +118,7 @@ class Sector:
|
||||||
|
|
||||||
|
|
||||||
class DirectionSet:
|
class DirectionSet:
|
||||||
"""
|
"""Describes direction, set of directions."""
|
||||||
Describes direction, set of directions.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self, text: str) -> None:
|
def __init__(self, text: str) -> None:
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -33,9 +33,7 @@ USE_BLUR: bool = False
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class Lane:
|
class Lane:
|
||||||
"""
|
"""Road lane specification."""
|
||||||
Road lane specification.
|
|
||||||
"""
|
|
||||||
|
|
||||||
width: Optional[float] = None # Width in meters
|
width: Optional[float] = None # Width in meters
|
||||||
is_forward: Optional[bool] = None # Whether lane is forward or backward
|
is_forward: Optional[bool] = None # Whether lane is forward or backward
|
||||||
|
@ -57,9 +55,7 @@ class Lane:
|
||||||
|
|
||||||
|
|
||||||
class RoadPart:
|
class RoadPart:
|
||||||
"""
|
"""Line part of the road."""
|
||||||
Line part of the road.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
@ -366,9 +362,7 @@ class Intersection:
|
||||||
|
|
||||||
|
|
||||||
class Road(Tagged):
|
class Road(Tagged):
|
||||||
"""
|
"""Road or track on the map."""
|
||||||
Road or track on the map.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
@ -755,16 +749,9 @@ class ComplexConnector(Connector):
|
||||||
class SimpleIntersection(Connector):
|
class SimpleIntersection(Connector):
|
||||||
"""Connection between more than two roads."""
|
"""Connection between more than two roads."""
|
||||||
|
|
||||||
def __init__(
|
|
||||||
self,
|
|
||||||
connections: list[tuple[Road, int]],
|
|
||||||
flinger: Flinger,
|
|
||||||
) -> None:
|
|
||||||
super().__init__(connections, flinger)
|
|
||||||
|
|
||||||
def draw(self, svg: Drawing) -> None:
|
def draw(self, svg: Drawing) -> None:
|
||||||
"""Draw connection fill."""
|
"""Draw connection fill."""
|
||||||
for road, index in sorted(
|
for road, _ in sorted(
|
||||||
self.connections, key=lambda x: x[0].matcher.priority
|
self.connections, key=lambda x: x[0].matcher.priority
|
||||||
):
|
):
|
||||||
node: OSMNode = self.road_1.nodes[self.index_1]
|
node: OSMNode = self.road_1.nodes[self.index_1]
|
||||||
|
@ -776,7 +763,7 @@ class SimpleIntersection(Connector):
|
||||||
|
|
||||||
def draw_border(self, svg: Drawing) -> None:
|
def draw_border(self, svg: Drawing) -> None:
|
||||||
"""Draw connection outline."""
|
"""Draw connection outline."""
|
||||||
for road, index in self.connections:
|
for road, _ in self.connections:
|
||||||
node: OSMNode = self.road_1.nodes[self.index_1]
|
node: OSMNode = self.road_1.nodes[self.index_1]
|
||||||
point: np.ndarray = self.flinger.fling(node.coordinates)
|
point: np.ndarray = self.flinger.fling(node.coordinates)
|
||||||
circle: Circle = svg.circle(
|
circle: Circle = svg.circle(
|
||||||
|
@ -817,13 +804,13 @@ class Roads:
|
||||||
layered_roads[road.layer] = []
|
layered_roads[road.layer] = []
|
||||||
layered_roads[road.layer].append(road)
|
layered_roads[road.layer].append(road)
|
||||||
|
|
||||||
for id_ in self.nodes:
|
for _, connected in self.nodes.items():
|
||||||
connected: list[tuple[Road, int]] = self.nodes[id_]
|
|
||||||
connector: Connector
|
connector: Connector
|
||||||
|
|
||||||
if len(self.nodes[id_]) <= 1:
|
if len(connected) <= 1:
|
||||||
continue
|
continue
|
||||||
elif len(self.nodes[id_]) == 2:
|
|
||||||
|
if len(connected) == 2:
|
||||||
road_1, index_1 = connected[0]
|
road_1, index_1 = connected[0]
|
||||||
road_2, index_2 = connected[1]
|
road_2, index_2 = connected[1]
|
||||||
if (
|
if (
|
||||||
|
@ -851,11 +838,7 @@ class Roads:
|
||||||
roads: list[Road] = sorted(
|
roads: list[Road] = sorted(
|
||||||
layered_roads[layer], key=lambda x: x.matcher.priority
|
layered_roads[layer], key=lambda x: x.matcher.priority
|
||||||
)
|
)
|
||||||
connectors: list[Connector]
|
connectors: list[Connector] = layered_connectors.get(layer)
|
||||||
if layer in layered_connectors:
|
|
||||||
connectors = layered_connectors[layer]
|
|
||||||
else:
|
|
||||||
connectors = []
|
|
||||||
|
|
||||||
# Draw borders.
|
# Draw borders.
|
||||||
|
|
||||||
|
|
|
@ -26,9 +26,7 @@ BUILDING_MINIMAL_HEIGHT: float = 8.0
|
||||||
|
|
||||||
|
|
||||||
class Figure(Tagged):
|
class Figure(Tagged):
|
||||||
"""
|
"""Some figure on the map: way or area."""
|
||||||
Some figure on the map: way or area.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
@ -64,9 +62,7 @@ class Figure(Tagged):
|
||||||
|
|
||||||
|
|
||||||
class Building(Figure):
|
class Building(Figure):
|
||||||
"""
|
"""Building on the map."""
|
||||||
Building on the map.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
@ -193,9 +189,7 @@ class Building(Figure):
|
||||||
|
|
||||||
|
|
||||||
class StyledFigure(Figure):
|
class StyledFigure(Figure):
|
||||||
"""
|
"""Figure with stroke and fill style."""
|
||||||
Figure with stroke and fill style.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
@ -209,9 +203,7 @@ class StyledFigure(Figure):
|
||||||
|
|
||||||
|
|
||||||
class Crater(Tagged):
|
class Crater(Tagged):
|
||||||
"""
|
"""Volcano or impact crater on the map."""
|
||||||
Volcano or impact crater on the map.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, tags: dict[str, str], coordinates: np.ndarray, point: np.ndarray
|
self, tags: dict[str, str], coordinates: np.ndarray, point: np.ndarray
|
||||||
|
@ -248,9 +240,7 @@ class Crater(Tagged):
|
||||||
|
|
||||||
|
|
||||||
class Tree(Tagged):
|
class Tree(Tagged):
|
||||||
"""
|
"""Tree on the map."""
|
||||||
Tree on the map.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, tags: dict[str, str], coordinates: np.ndarray, point: np.ndarray
|
self, tags: dict[str, str], coordinates: np.ndarray, point: np.ndarray
|
||||||
|
@ -280,9 +270,7 @@ class Tree(Tagged):
|
||||||
|
|
||||||
|
|
||||||
class DirectionSector(Tagged):
|
class DirectionSector(Tagged):
|
||||||
"""
|
"""Sector that represents direction."""
|
||||||
Sector that represents direction.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self, tags: dict[str, str], point: np.ndarray) -> None:
|
def __init__(self, tags: dict[str, str], point: np.ndarray) -> None:
|
||||||
super().__init__(tags)
|
super().__init__(tags)
|
||||||
|
@ -354,9 +342,7 @@ class DirectionSector(Tagged):
|
||||||
|
|
||||||
|
|
||||||
class Segment:
|
class Segment:
|
||||||
"""
|
"""Closed line segment."""
|
||||||
Closed line segment.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self, point_1: np.ndarray, point_2: np.ndarray) -> None:
|
def __init__(self, point_1: np.ndarray, point_2: np.ndarray) -> None:
|
||||||
self.point_1: np.ndarray = point_1
|
self.point_1: np.ndarray = point_1
|
||||||
|
|
|
@ -17,9 +17,7 @@ LONGITUDE_MAX_DIFFERENCE: float = 0.5
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class BoundaryBox:
|
class BoundaryBox:
|
||||||
"""
|
"""Rectangle that limit space on the map."""
|
||||||
Rectangle that limit space on the map.
|
|
||||||
"""
|
|
||||||
|
|
||||||
left: float # Minimum longitude.
|
left: float # Minimum longitude.
|
||||||
bottom: float # Minimum latitude.
|
bottom: float # Minimum latitude.
|
||||||
|
|
|
@ -40,9 +40,7 @@ def osm_zoom_level_to_pixels_per_meter(
|
||||||
|
|
||||||
|
|
||||||
class Flinger:
|
class Flinger:
|
||||||
"""
|
"""Convert geo coordinates into SVG position points."""
|
||||||
Convert geo coordinates into SVG position points.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
|
|
@ -41,9 +41,7 @@ def norm(vector: np.ndarray) -> np.ndarray:
|
||||||
|
|
||||||
|
|
||||||
class Polyline:
|
class Polyline:
|
||||||
"""
|
"""List of connected points."""
|
||||||
List of connected points.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self, points: list[np.ndarray]) -> None:
|
def __init__(self, points: list[np.ndarray]) -> None:
|
||||||
self.points: list[np.ndarray] = points
|
self.points: list[np.ndarray] = points
|
||||||
|
|
|
@ -67,9 +67,7 @@ meta {{
|
||||||
|
|
||||||
|
|
||||||
class MapCSSWriter:
|
class MapCSSWriter:
|
||||||
"""
|
"""Writer that converts Map Machine scheme into MapCSS 0.2 format."""
|
||||||
Writer that converts Map Machine scheme into MapCSS 0.2 format.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
|
|
@ -33,9 +33,7 @@ __email__ = "me@enzet.ru"
|
||||||
|
|
||||||
|
|
||||||
class Map:
|
class Map:
|
||||||
"""
|
"""Map drawing."""
|
||||||
Map drawing.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
|
|
@ -59,9 +59,7 @@ def parse_levels(string: str) -> list[float]:
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class Tagged:
|
class Tagged:
|
||||||
"""
|
"""Something with tags (string to string mapping)."""
|
||||||
Something with tags (string to string mapping).
|
|
||||||
"""
|
|
||||||
|
|
||||||
tags: dict[str, str]
|
tags: dict[str, str]
|
||||||
|
|
||||||
|
@ -224,9 +222,7 @@ class OSMWay(Tagged):
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class OSMMember:
|
class OSMMember:
|
||||||
"""
|
"""Member of OpenStreetMap relation."""
|
||||||
Member of OpenStreetMap relation.
|
|
||||||
"""
|
|
||||||
|
|
||||||
type_: str
|
type_: str
|
||||||
ref: int
|
ref: int
|
||||||
|
@ -298,15 +294,11 @@ class OSMRelation(Tagged):
|
||||||
|
|
||||||
|
|
||||||
class NotWellFormedOSMDataException(Exception):
|
class NotWellFormedOSMDataException(Exception):
|
||||||
"""
|
"""OSM data structure is not well-formed."""
|
||||||
OSM data structure is not well-formed.
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
class OSMData:
|
class OSMData:
|
||||||
"""
|
"""The whole OpenStreetMap information about nodes, ways, and relations."""
|
||||||
The whole OpenStreetMap information about nodes, ways, and relations.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
self.nodes: dict[int, OSMNode] = {}
|
self.nodes: dict[int, OSMNode] = {}
|
||||||
|
|
|
@ -38,9 +38,7 @@ GRID_STEP: int = 16
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class Shape:
|
class Shape:
|
||||||
"""
|
"""SVG icon path description."""
|
||||||
SVG icon path description.
|
|
||||||
"""
|
|
||||||
|
|
||||||
path: str # SVG icon path
|
path: str # SVG icon path
|
||||||
offset: np.ndarray # vector that should be used to shift the path
|
offset: np.ndarray # vector that should be used to shift the path
|
||||||
|
@ -257,9 +255,7 @@ class ShapeExtractor:
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class ShapeSpecification:
|
class ShapeSpecification:
|
||||||
"""
|
"""Specification for shape as a part of an icon."""
|
||||||
Specification for shape as a part of an icon.
|
|
||||||
"""
|
|
||||||
|
|
||||||
shape: Shape
|
shape: Shape
|
||||||
color: Color = DEFAULT_COLOR
|
color: Color = DEFAULT_COLOR
|
||||||
|
@ -335,9 +331,7 @@ class ShapeSpecification:
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class Icon:
|
class Icon:
|
||||||
"""
|
"""Icon that consists of (probably) multiple shapes."""
|
||||||
Icon that consists of (probably) multiple shapes.
|
|
||||||
"""
|
|
||||||
|
|
||||||
shape_specifications: list[ShapeSpecification]
|
shape_specifications: list[ShapeSpecification]
|
||||||
opacity: float = 1.0
|
opacity: float = 1.0
|
||||||
|
@ -450,9 +444,7 @@ class Icon:
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class IconSet:
|
class IconSet:
|
||||||
"""
|
"""Node representation: icons and color."""
|
||||||
Node representation: icons and color.
|
|
||||||
"""
|
|
||||||
|
|
||||||
main_icon: Icon
|
main_icon: Icon
|
||||||
extra_icons: list[Icon]
|
extra_icons: list[Icon]
|
||||||
|
|
|
@ -25,9 +25,7 @@ __email__ = "me@enzet.ru"
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class IconCollection:
|
class IconCollection:
|
||||||
"""
|
"""Collection of icons."""
|
||||||
Collection of icons.
|
|
||||||
"""
|
|
||||||
|
|
||||||
icons: list[Icon]
|
icons: list[Icon]
|
||||||
|
|
||||||
|
|
|
@ -33,18 +33,14 @@ IconDescription = list[Union[str, dict[str, str]]]
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class LineStyle:
|
class LineStyle:
|
||||||
"""
|
"""SVG line style and its priority."""
|
||||||
SVG line style and its priority.
|
|
||||||
"""
|
|
||||||
|
|
||||||
style: dict[str, Union[int, float, str]]
|
style: dict[str, Union[int, float, str]]
|
||||||
priority: float = 0.0
|
priority: float = 0.0
|
||||||
|
|
||||||
|
|
||||||
class MatchingType(Enum):
|
class MatchingType(Enum):
|
||||||
"""
|
"""Description on how tag was matched."""
|
||||||
Description on how tag was matched.
|
|
||||||
"""
|
|
||||||
|
|
||||||
NOT_MATCHED = 0
|
NOT_MATCHED = 0
|
||||||
MATCHED_BY_SET = 1
|
MATCHED_BY_SET = 1
|
||||||
|
@ -106,9 +102,7 @@ def match_location(restrictions: dict[str, str], country: str) -> bool:
|
||||||
|
|
||||||
|
|
||||||
class Matcher:
|
class Matcher:
|
||||||
"""
|
"""Tag matching."""
|
||||||
Tag matching.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, structure: dict[str, Any], group: Optional[dict[str, Any]] = None
|
self, structure: dict[str, Any], group: Optional[dict[str, Any]] = None
|
||||||
|
@ -215,9 +209,7 @@ def get_shape_specifications(
|
||||||
|
|
||||||
|
|
||||||
class NodeMatcher(Matcher):
|
class NodeMatcher(Matcher):
|
||||||
"""
|
"""Tag specification matcher."""
|
||||||
Tag specification matcher.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, structure: dict[str, Any], group: dict[str, Any]
|
self, structure: dict[str, Any], group: dict[str, Any]
|
||||||
|
@ -265,9 +257,7 @@ class NodeMatcher(Matcher):
|
||||||
|
|
||||||
|
|
||||||
class WayMatcher(Matcher):
|
class WayMatcher(Matcher):
|
||||||
"""
|
"""Special tag matcher for ways."""
|
||||||
Special tag matcher for ways.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self, structure: dict[str, Any], scheme: "Scheme") -> None:
|
def __init__(self, structure: dict[str, Any], scheme: "Scheme") -> None:
|
||||||
super().__init__(structure)
|
super().__init__(structure)
|
||||||
|
@ -289,9 +279,7 @@ class WayMatcher(Matcher):
|
||||||
|
|
||||||
|
|
||||||
class RoadMatcher(Matcher):
|
class RoadMatcher(Matcher):
|
||||||
"""
|
"""Special tag matcher for highways."""
|
||||||
Special tag matcher for highways.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self, structure: dict[str, Any], scheme: "Scheme") -> None:
|
def __init__(self, structure: dict[str, Any], scheme: "Scheme") -> None:
|
||||||
super().__init__(structure)
|
super().__init__(structure)
|
||||||
|
|
|
@ -17,9 +17,7 @@ __email__ = "me@enzet.ru"
|
||||||
|
|
||||||
|
|
||||||
class _Handler(SimpleHTTPRequestHandler):
|
class _Handler(SimpleHTTPRequestHandler):
|
||||||
"""
|
"""HTTP request handler that process sloppy map tile requests."""
|
||||||
HTTP request handler that process sloppy map tile requests.
|
|
||||||
"""
|
|
||||||
|
|
||||||
cache: Path = Path("cache")
|
cache: Path = Path("cache")
|
||||||
update_cache: bool = False
|
update_cache: bool = False
|
||||||
|
|
|
@ -212,9 +212,7 @@ class Tile:
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class Tiles:
|
class Tiles:
|
||||||
"""
|
"""Collection of tiles."""
|
||||||
Collection of tiles.
|
|
||||||
"""
|
|
||||||
|
|
||||||
tiles: list[Tile]
|
tiles: list[Tile]
|
||||||
tile_1: Tile # Left top tile.
|
tile_1: Tile # Left top tile.
|
||||||
|
|
|
@ -17,9 +17,7 @@ DEFAULT_COLOR: Color = Color("#444444")
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class Label:
|
class Label:
|
||||||
"""
|
"""Text label."""
|
||||||
Text label.
|
|
||||||
"""
|
|
||||||
|
|
||||||
text: str
|
text: str
|
||||||
fill: Color = DEFAULT_COLOR
|
fill: Color = DEFAULT_COLOR
|
||||||
|
|
|
@ -12,9 +12,7 @@ from map_machine.ui.cli import COMMANDS
|
||||||
|
|
||||||
|
|
||||||
class ArgumentParser(argparse.ArgumentParser):
|
class ArgumentParser(argparse.ArgumentParser):
|
||||||
"""
|
"""Argument parser that generates fish shell autocompletion commands."""
|
||||||
Argument parser that generates fish shell autocompletion commands.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs) -> None:
|
def __init__(self, *args, **kwargs) -> None:
|
||||||
self.arguments: list[dict[str, Any]] = []
|
self.arguments: list[dict[str, Any]] = []
|
||||||
|
|
|
@ -10,9 +10,7 @@ __email__ = "me@enzet.ru"
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class MinMax:
|
class MinMax:
|
||||||
"""
|
"""Minimum and maximum."""
|
||||||
Minimum and maximum.
|
|
||||||
"""
|
|
||||||
|
|
||||||
min_: Any = None
|
min_: Any = None
|
||||||
max_: Any = None
|
max_: Any = None
|
||||||
|
|
|
@ -17,9 +17,7 @@ def check_and_create(directory: Path) -> Path:
|
||||||
|
|
||||||
|
|
||||||
class Workspace:
|
class Workspace:
|
||||||
"""
|
"""Project file and directory paths and generated files and directories."""
|
||||||
Project file and directory paths and generated files and directories.
|
|
||||||
"""
|
|
||||||
|
|
||||||
# Project directories and files, that are the part of the repository.
|
# Project directories and files, that are the part of the repository.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue