Issue #63: add MapCSS and icons generation.

This commit is contained in:
Sergey Vartanov 2021-07-10 19:50:47 +03:00
parent 2eeccdb877
commit 5d49843a79
3 changed files with 41 additions and 9 deletions

View file

@ -177,19 +177,38 @@ def draw_icons() -> None:
Draw all possible icon shapes combinations as grid in one SVG file and as
individual SVG files.
"""
os.makedirs("icon_set", exist_ok=True)
os.makedirs("icon_set/ids", exist_ok=True)
os.makedirs("icon_set/josm", exist_ok=True)
os.makedirs("icon_set/names", exist_ok=True)
out_path: Path = Path("out")
icons_by_id_path: Path = out_path / "icons_by_id"
icons_by_name_path: Path = out_path / "icons_by_name"
icons_with_outline_path: Path = out_path / "roentgen_icons" / "icons"
for path in (
out_path, icons_by_id_path, icons_by_name_path, icons_with_outline_path
):
path.mkdir(parents=True, exist_ok=True)
scheme: Scheme = Scheme(Path("scheme/default.yml"))
extractor: ShapeExtractor = ShapeExtractor(
Path("icons/icons.svg"), Path("icons/config.json")
)
collection: IconCollection = IconCollection.from_scheme(scheme, extractor)
collection.draw_grid(Path("icon_grid.svg"))
collection.draw_icons(Path("icon_set/ids"))
collection.draw_icons(Path("icon_set/josm"), color=Color("black"), outline=True)
collection.draw_icons(Path("icon_set/names"), by_name=True)
collection.draw_grid(out_path / "icon_grid.svg")
collection.draw_icons(icons_by_id_path)
collection.draw_icons(icons_by_name_path, by_name=True)
collection.draw_icons(
icons_with_outline_path, color=Color("black"), outline=True
)
(out_path / "roentgen_icons").mkdir(exist_ok=True)
with Path("data/roentgen_icons_part.mapcss").open() as input_file:
with (
out_path / "roentgen_icons" / "roentgen_icons.mapcss"
).open("w+") as output_file:
for line in input_file.readlines():
if line == "%CONTENT%\n":
output_file.write(collection.get_mapcss_selectors())
else:
output_file.write(line)
if __name__ == "__main__":