mirror of
https://github.com/enzet/map-machine.git
synced 2025-08-06 10:09:52 +02:00
Issue #63: add MapCSS and icons generation.
This commit is contained in:
parent
2eeccdb877
commit
5d49843a79
3 changed files with 41 additions and 9 deletions
13
data/roentgen_icons_part.mapcss
Normal file
13
data/roentgen_icons_part.mapcss
Normal file
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
Map paint style that adds icons from Röntgen icon set
|
||||
*/
|
||||
|
||||
meta {
|
||||
title: "Röntgen icons";
|
||||
description: "Icons from Röntgen icon set for JOSM";
|
||||
author: "Sergey Vartanov";
|
||||
version: "0.1";
|
||||
link: "https://github.com/enzet/Roentgen";
|
||||
}
|
||||
|
||||
%CONTENT%
|
35
roentgen.py
35
roentgen.py
|
@ -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__":
|
||||
|
|
|
@ -189,7 +189,7 @@ class IconCollection:
|
|||
for selector in self.selectors:
|
||||
for target in ["node", "area"]:
|
||||
s += target + selector + " {\n"
|
||||
s += ' icon-image: "icon_set/josm/' + "___".join(
|
||||
s += ' icon-image: "icons/' + "___".join(
|
||||
self.selectors[selector].get_shape_ids()) + '.svg";\n'
|
||||
s += " set icon_z17;\n"
|
||||
s += " icon-width: 16;\n"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue