mirror of
https://github.com/enzet/map-machine.git
synced 2025-05-03 04:06:41 +02:00
Issue #69: add logging.
This commit is contained in:
parent
edd3512526
commit
8fe2f15663
3 changed files with 14 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
||||||
"""
|
"""
|
||||||
Rasterize vector graphics using Inkscape.
|
Rasterize vector graphics using Inkscape.
|
||||||
"""
|
"""
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
@ -25,4 +26,5 @@ def rasterize(from_: Path, to_: Path, area: str = "", dpi: float = 90) -> None:
|
||||||
commands += ["--export-area", area]
|
commands += ["--export-area", area]
|
||||||
commands += [from_.absolute()]
|
commands += [from_.absolute()]
|
||||||
|
|
||||||
|
logging.info(f"Rasterize SVG file to {to_}...")
|
||||||
subprocess.run(commands)
|
subprocess.run(commands)
|
||||||
|
|
|
@ -29,6 +29,9 @@ class Lane:
|
||||||
change: Optional[str] = None # "not_left", "not_right"
|
change: Optional[str] = None # "not_left", "not_right"
|
||||||
destination: Optional[str] = None # Lane destination
|
destination: Optional[str] = None # Lane destination
|
||||||
|
|
||||||
|
def set_forward(self, is_forward: bool) -> None:
|
||||||
|
self.is_forward = is_forward
|
||||||
|
|
||||||
def get_width(self, scale: float):
|
def get_width(self, scale: float):
|
||||||
"""Get lane width. We use standard 3.7 m lane."""
|
"""Get lane width. We use standard 3.7 m lane."""
|
||||||
if self.width is None:
|
if self.width is None:
|
||||||
|
|
|
@ -78,10 +78,14 @@ class Tiles:
|
||||||
file_path: Path = tile.get_file_name(directory)
|
file_path: Path = tile.get_file_name(directory)
|
||||||
if not file_path.exists():
|
if not file_path.exists():
|
||||||
tile.draw_for_map(map_, directory)
|
tile.draw_for_map(map_, directory)
|
||||||
|
else:
|
||||||
|
logging.info(f"File {file_path} already exists.")
|
||||||
|
|
||||||
output_path: Path = file_path.with_suffix(".png")
|
output_path: Path = file_path.with_suffix(".png")
|
||||||
if not output_path.exists():
|
if not output_path.exists():
|
||||||
rasterize(file_path, output_path)
|
rasterize(file_path, output_path)
|
||||||
|
else:
|
||||||
|
logging.info(f"File {output_path} already exists.")
|
||||||
|
|
||||||
def draw_image(self, cache_path: Path) -> None:
|
def draw_image(self, cache_path: Path) -> None:
|
||||||
"""
|
"""
|
||||||
|
@ -130,12 +134,17 @@ class Tiles:
|
||||||
)
|
)
|
||||||
painter.draw(constructor)
|
painter.draw(constructor)
|
||||||
|
|
||||||
|
logging.info(f"Writing output SVG {output_path}...")
|
||||||
with output_path.open("w+") as output_file:
|
with output_path.open("w+") as output_file:
|
||||||
svg.write(output_file)
|
svg.write(output_file)
|
||||||
|
else:
|
||||||
|
logging.info(f"File {output_path} already exists.")
|
||||||
|
|
||||||
png_path: Path = cache_path / f"{self.boundary_box.get_format()}.png"
|
png_path: Path = cache_path / f"{self.boundary_box.get_format()}.png"
|
||||||
if not png_path.exists():
|
if not png_path.exists():
|
||||||
rasterize(output_path, png_path)
|
rasterize(output_path, png_path)
|
||||||
|
else:
|
||||||
|
logging.info(f"File {png_path} already exists.")
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
|
|
Loading…
Add table
Reference in a new issue