Add Inskcape requirement.

This commit is contained in:
Sergey Vartanov 2021-08-17 09:30:55 +03:00
parent bc08d90587
commit a1f90abcbd
2 changed files with 12 additions and 11 deletions

View file

@ -10,16 +10,22 @@ from typing import List
__author__ = "Sergey Vartanov"
__email__ = "me@enzet.ru"
INKSCAPE_BIN: str = "INKSCAPE_BIN"
def rasterize(from_: Path, to_: Path, area: str = "", dpi: float = 90) -> None:
"""
Make PNG image out of SVG using Inkscape.
"""
inkscape: str = "inkscape"
if "INKSCAPE_BIN" in os.environ:
inkscape: str = os.environ["INKSCAPE_BIN"]
commands: List[str] = [inkscape]
See https://inkscape.org/
"""
if "INKSCAPE_BIN" not in os.environ:
logging.fatal(
f"Environment variable {INKSCAPE_BIN} not set. Please, install "
f"Inkscape and set the variable to be able to rasterize SVG files."
)
commands: List[str] = [os.environ[INKSCAPE_BIN]]
commands += ["--export-png", to_.absolute()]
commands += ["--export-dpi", str(dpi)]
if area:

View file

@ -83,12 +83,7 @@ class RoadPart:
@classmethod
def from_nodes(
cls,
node_1: OSMNode,
node_2: OSMNode,
flinger: Flinger,
road,
scale,
cls, node_1: OSMNode, node_2: OSMNode, flinger: Flinger, road, scale
) -> "RoadPart":
"""
Construct road part from OSM nodes.