Issue #63: support MapCSS 0.2 for icons.

Support MapCSS 0.2 scheme generation with icons for nodes and areas.
This commit is contained in:
Sergey Vartanov 2021-07-10 19:31:47 +03:00
parent 557cc0cc98
commit 2eeccdb877
2 changed files with 37 additions and 6 deletions

View file

@ -72,10 +72,9 @@ class Matcher:
Tag matching.
"""
def __init__(self, structure: Dict[str, Any]):
self.tags = structure["tags"]
self.exception = None
self.tags: Dict[str, str] = structure["tags"]
self.exception: Dict[str, str] = {}
if "exception" in structure:
self.exception = structure["exception"]
@ -155,6 +154,14 @@ class NodeMatcher(Matcher):
if "with_icon" in structure:
self.with_icon = structure["with_icon"]
def get_mapcss_selector(self) -> str:
"""
Construct MapCSS 0.2 selector from the node matcher.
See https://wiki.openstreetmap.org/wiki/MapCSS/0.2
"""
return "".join([f"[{x}={y}]" for (x, y) in self.tags.items()])
class WayMatcher(Matcher):
"""