mirror of
https://github.com/enzet/map-machine.git
synced 2025-06-09 06:11:54 +02:00
Fix type defects found by Pyre.
This commit is contained in:
parent
266e5622d6
commit
1fcc41e4f2
2 changed files with 18 additions and 4 deletions
|
@ -77,7 +77,7 @@ def run_server(options: argparse.Namespace) -> None:
|
||||||
handler = TileServerHandler
|
handler = TileServerHandler
|
||||||
handler.cache = Path(options.cache)
|
handler.cache = Path(options.cache)
|
||||||
handler.options = options
|
handler.options = options
|
||||||
server: HTTPServer = HTTPServer(("", options.port), handler)
|
server = HTTPServer(("", options.port), handler)
|
||||||
logging.info(f"Server started on port {options.port}.")
|
logging.info(f"Server started on port {options.port}.")
|
||||||
server.serve_forever()
|
server.serve_forever()
|
||||||
finally:
|
finally:
|
||||||
|
|
|
@ -475,14 +475,23 @@ def generate_tiles(options: argparse.Namespace) -> None:
|
||||||
if options.input_file_name:
|
if options.input_file_name:
|
||||||
osm_data: OSMData = OSMData()
|
osm_data: OSMData = OSMData()
|
||||||
osm_data.parse_osm_file(Path(options.input_file_name))
|
osm_data.parse_osm_file(Path(options.input_file_name))
|
||||||
|
|
||||||
|
if osm_data.view_box is None:
|
||||||
|
logging.fatal(
|
||||||
|
"Failed to parse boundary box input file "
|
||||||
|
f"{options.input_file_name}."
|
||||||
|
)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
boundary_box: BoundaryBox = osm_data.view_box
|
||||||
|
|
||||||
for zoom_level in zoom_levels:
|
for zoom_level in zoom_levels:
|
||||||
configuration: MapConfiguration = MapConfiguration.from_options(
|
configuration: MapConfiguration = MapConfiguration.from_options(
|
||||||
options, zoom_level
|
options, zoom_level
|
||||||
)
|
)
|
||||||
tiles: Tiles = Tiles.from_boundary_box(
|
tiles: Tiles = Tiles.from_boundary_box(boundary_box, zoom_level)
|
||||||
osm_data.view_box, zoom_level
|
|
||||||
)
|
|
||||||
tiles.draw(directory, Path(options.cache), configuration, osm_data)
|
tiles.draw(directory, Path(options.cache), configuration, osm_data)
|
||||||
|
|
||||||
elif options.coordinates:
|
elif options.coordinates:
|
||||||
coordinates: list[float] = list(
|
coordinates: list[float] = list(
|
||||||
map(float, options.coordinates.strip().split(","))
|
map(float, options.coordinates.strip().split(","))
|
||||||
|
@ -506,6 +515,7 @@ def generate_tiles(options: argparse.Namespace) -> None:
|
||||||
tile.draw_with_osm_data(osm_data, directory, configuration)
|
tile.draw_with_osm_data(osm_data, directory, configuration)
|
||||||
except NetworkError as error:
|
except NetworkError as error:
|
||||||
logging.fatal(error.message)
|
logging.fatal(error.message)
|
||||||
|
|
||||||
elif options.tile:
|
elif options.tile:
|
||||||
zoom_level, x, y = map(int, options.tile.split("/"))
|
zoom_level, x, y = map(int, options.tile.split("/"))
|
||||||
tile: Tile = Tile(x, y, zoom_level)
|
tile: Tile = Tile(x, y, zoom_level)
|
||||||
|
@ -513,12 +523,15 @@ def generate_tiles(options: argparse.Namespace) -> None:
|
||||||
options, zoom_level
|
options, zoom_level
|
||||||
)
|
)
|
||||||
tile.draw(directory, Path(options.cache), configuration)
|
tile.draw(directory, Path(options.cache), configuration)
|
||||||
|
|
||||||
elif options.boundary_box:
|
elif options.boundary_box:
|
||||||
boundary_box: Optional[BoundaryBox] = BoundaryBox.from_text(
|
boundary_box: Optional[BoundaryBox] = BoundaryBox.from_text(
|
||||||
options.boundary_box
|
options.boundary_box
|
||||||
)
|
)
|
||||||
if boundary_box is None:
|
if boundary_box is None:
|
||||||
|
logging.fatal("Failed to parse boundary box.")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
min_tiles: Tiles = Tiles.from_boundary_box(boundary_box, min_zoom_level)
|
min_tiles: Tiles = Tiles.from_boundary_box(boundary_box, min_zoom_level)
|
||||||
try:
|
try:
|
||||||
osm_data: OSMData = min_tiles.load_osm_data(Path(options.cache))
|
osm_data: OSMData = min_tiles.load_osm_data(Path(options.cache))
|
||||||
|
@ -534,6 +547,7 @@ def generate_tiles(options: argparse.Namespace) -> None:
|
||||||
options, zoom_level
|
options, zoom_level
|
||||||
)
|
)
|
||||||
tiles.draw(directory, Path(options.cache), configuration, osm_data)
|
tiles.draw(directory, Path(options.cache), configuration, osm_data)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
logging.fatal(
|
logging.fatal(
|
||||||
"Specify either --coordinates, --boundary-box, --tile, or --input."
|
"Specify either --coordinates, --boundary-box, --tile, or --input."
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue