mirror of
https://github.com/enzet/map-machine.git
synced 2025-08-01 15:50:20 +02:00
Fix icon drawing.
This commit is contained in:
parent
ad2284e69a
commit
3c9054e7fc
3 changed files with 14 additions and 73 deletions
|
@ -14,7 +14,7 @@ from svgwrite.shapes import Line, Rect
|
|||
|
||||
from map_machine.map_configuration import MapConfiguration
|
||||
from map_machine.osm.osm_reader import Tags
|
||||
from map_machine.pictogram.icon import ShapeExtractor, Icon, IconSet
|
||||
from map_machine.pictogram.icon import ShapeExtractor, IconSet
|
||||
from map_machine.scheme import Scheme
|
||||
from map_machine.workspace import Workspace
|
||||
|
||||
|
@ -62,67 +62,6 @@ class Collection:
|
|||
)
|
||||
|
||||
|
||||
class WikiTable:
|
||||
"""SVG table with icon combinations."""
|
||||
|
||||
def __init__(self, collection: Collection, page_name: str):
|
||||
self.collection: Collection = collection
|
||||
self.page_name: str = page_name
|
||||
|
||||
def generate_wiki_table(self) -> tuple[str, list[Icon]]:
|
||||
"""
|
||||
Generate Röntgen icon table for the OpenStreetMap wiki page.
|
||||
"""
|
||||
icons: list[Icon] = []
|
||||
text: str = '{| class="wikitable"\n'
|
||||
|
||||
if self.collection.column_key is not None:
|
||||
text += f"! {{{{Key|{self.collection.column_key}}}}}"
|
||||
else:
|
||||
text += "! Tag || Icon"
|
||||
|
||||
if not self.collection.column_values:
|
||||
self.collection.column_values = [""]
|
||||
else:
|
||||
for column_value in self.collection.column_values:
|
||||
text += " ||"
|
||||
if column_value:
|
||||
text += (
|
||||
f" {{{{vert header|{{{{TagValue|"
|
||||
f"{self.collection.column_key}|{column_value}}}}}}}}}"
|
||||
)
|
||||
text += "\n"
|
||||
|
||||
processed: set[str] = set()
|
||||
|
||||
for row_value in self.collection.row_values:
|
||||
text += "|-\n"
|
||||
if row_value:
|
||||
text += f"| {{{{Tag|{self.collection.row_key}|{row_value}}}}}\n"
|
||||
else:
|
||||
text += "|\n"
|
||||
for column_value in self.collection.column_values:
|
||||
current_tags: Tags = dict(self.collection.tags) | {
|
||||
self.collection.row_key: row_value
|
||||
}
|
||||
if column_value:
|
||||
current_tags |= {self.collection.column_key: column_value}
|
||||
icon, _ = SCHEME.get_icon(
|
||||
EXTRACTOR, current_tags, processed, MapConfiguration()
|
||||
)
|
||||
if not icon:
|
||||
print("Icon was not constructed.")
|
||||
text += (
|
||||
"| "
|
||||
f"[[Image:Röntgen {icon.main_icon.get_name()}.svg|32px]]\n"
|
||||
)
|
||||
icons.append(icon.main_icon)
|
||||
|
||||
text += "|}\n"
|
||||
|
||||
return text, icons
|
||||
|
||||
|
||||
class SVGTable:
|
||||
"""SVG table with icon combinations."""
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue