Fix Pylint warnings.

This commit is contained in:
Sergey Vartanov 2021-10-25 02:15:11 +03:00
parent 960a18633f
commit e9933e9f2b
5 changed files with 26 additions and 30 deletions

View file

@ -228,7 +228,7 @@ class Constructor:
if not self.check_level(line.tags):
return
center_point, center_coordinates = line_center(outers[0], self.flinger)
center_point, _ = line_center(outers[0], self.flinger)
if self.configuration.is_wireframe():
color: Color
if self.configuration.drawing_mode == DrawingMode.AUTHOR:

View file

@ -29,7 +29,7 @@ def main() -> None:
elif arguments.command == "render":
from map_machine import mapper
mapper.ui(arguments)
mapper.render_map(arguments)
elif arguments.command == "tile":
from map_machine.slippy import tile
@ -44,7 +44,7 @@ def main() -> None:
elif arguments.command == "mapcss":
from map_machine import mapcss
mapcss.ui(arguments)
mapcss.generate_mapcss(arguments)
elif arguments.command == "element":
from map_machine.element import draw_element

View file

@ -134,8 +134,8 @@ class MapCSSWriter:
return ""
selector: str = target + matcher.get_mapcss_selector(prefix) + " {\n"
for element in elements:
selector += f" {element}: {elements[element]};\n"
for key, value in elements.items():
selector += f" {key}: {value};\n"
selector += "}\n"
return selector
@ -176,7 +176,7 @@ class MapCSSWriter:
)
def ui(options: argparse.Namespace) -> None:
def generate_mapcss(options: argparse.Namespace) -> None:
"""Write MapCSS 0.2 scheme."""
directory: Path = workspace.get_mapcss_path()
icons_with_outline_path: Path = workspace.get_mapcss_icons_path()

View file

@ -3,6 +3,7 @@ Simple OpenStreetMap renderer.
"""
import argparse
import logging
import sys
from pathlib import Path
from typing import Iterator, Optional
@ -133,7 +134,6 @@ class Map:
previous_height: float = 0
for height in sorted(constructor.heights):
fill: Color()
for building in constructor.buildings:
if building.height < height or building.min_height > height:
continue
@ -168,15 +168,14 @@ class Map:
nodes[node_1].add(part_1)
nodes[node_2].add(part_2)
for node in nodes:
parts: set[RoadPart] = nodes[node]
for node, parts in nodes.items():
if len(parts) < 4:
continue
intersection: Intersection = Intersection(list(parts))
intersection.draw(self.svg, True)
def ui(arguments: argparse.Namespace) -> None:
def render_map(arguments: argparse.Namespace) -> None:
"""
Map Machine entry point.
@ -189,7 +188,6 @@ def ui(arguments: argparse.Namespace) -> None:
cache_path.mkdir(parents=True, exist_ok=True)
boundary_box: Optional[BoundaryBox] = None
input_file_names: list[Path] = []
if arguments.input_file_names:
input_file_names = list(map(Path, arguments.input_file_names))
@ -213,7 +211,7 @@ def ui(arguments: argparse.Namespace) -> None:
"Specify either --input, or --boundary-box, or --coordinates "
"and --size."
)
exit(1)
sys.exit(1)
try:
cache_file_path: Path = (
@ -221,13 +219,11 @@ def ui(arguments: argparse.Namespace) -> None:
)
get_osm(boundary_box, cache_file_path)
input_file_names = [cache_file_path]
except NetworkError as e:
logging.fatal(e.message)
exit(1)
except NetworkError as error:
logging.fatal(error.message)
sys.exit(1)
scheme: Scheme = Scheme(workspace.DEFAULT_SCHEME_PATH)
min_: np.ndarray
max_: np.ndarray
osm_data: OSMData
osm_data: OSMData = OSMData()

View file

@ -55,9 +55,9 @@ class Tile:
:param zoom_level: zoom level in OpenStreetMap terminology
"""
lat_rad: np.ndarray = np.radians(coordinates[0])
n: float = 2.0 ** zoom_level
x: int = int((coordinates[1] + 180.0) / 360.0 * n)
y: int = int((1.0 - np.arcsinh(np.tan(lat_rad)) / np.pi) / 2.0 * n)
scale: float = 2.0 ** zoom_level
x: int = int((coordinates[1] + 180.0) / 360.0 * scale)
y: int = int((1.0 - np.arcsinh(np.tan(lat_rad)) / np.pi) / 2.0 * scale)
return cls(x, y, zoom_level)
def get_coordinates(self) -> np.ndarray:
@ -66,9 +66,9 @@ class Tile:
Code from https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames
"""
n: float = 2.0 ** self.zoom_level
lon_deg: float = self.x / n * 360.0 - 180.0
lat_rad: float = np.arctan(np.sinh(np.pi * (1 - 2 * self.y / n)))
scale: float = 2.0 ** self.zoom_level
lon_deg: float = self.x / scale * 360.0 - 180.0
lat_rad: float = np.arctan(np.sinh(np.pi * (1 - 2 * self.y / scale)))
lat_deg: np.ndarray = np.degrees(lat_rad)
return np.array((lat_deg, lon_deg))
@ -141,8 +141,8 @@ class Tile:
"""
try:
osm_data: OSMData = self.load_osm_data(cache_path)
except NetworkError as e:
raise NetworkError(f"Map is not loaded. {e.message}")
except NetworkError as error:
raise NetworkError(f"Map is not loaded. {error.message}")
self.draw_with_osm_data(osm_data, directory_name, configuration)
@ -198,12 +198,12 @@ class Tile:
assert zoom_level >= self.zoom_level
tiles: list["Tile"] = []
n: int = 2 ** (zoom_level - self.zoom_level)
for i in range(n):
for j in range(n):
scale: int = 2 ** (zoom_level - self.zoom_level)
for i in range(scale):
for j in range(scale):
tile: Tile = Tile(
n * self.x + i,
n * self.y + j,
scale * self.x + i,
scale * self.y + j,
zoom_level,
)
tiles.append(tile)