mirror of
https://github.com/enzet/map-machine.git
synced 2025-06-09 06:11:54 +02:00
Issue #62: move selector construction.
This commit is contained in:
parent
940df876a1
commit
b4fa039724
1 changed files with 16 additions and 16 deletions
|
@ -120,6 +120,22 @@ class Matcher:
|
|||
|
||||
return matched
|
||||
|
||||
def get_mapcss_selector(self) -> str:
|
||||
"""
|
||||
Construct MapCSS 0.2 selector from the node matcher.
|
||||
|
||||
See https://wiki.openstreetmap.org/wiki/MapCSS/0.2
|
||||
"""
|
||||
def get_selector(key: str, value: str) -> str:
|
||||
"""Get MapCSS 0.2 selector for one key."""
|
||||
if value == "*":
|
||||
return f"[{key}]"
|
||||
if '"' in value:
|
||||
return f"[{key}='{value}']"
|
||||
return f'[{key}="{value}"]'
|
||||
|
||||
return "".join([get_selector(x, y) for (x, y) in self.tags.items()])
|
||||
|
||||
|
||||
class NodeMatcher(Matcher):
|
||||
"""
|
||||
|
@ -158,22 +174,6 @@ 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
|
||||
"""
|
||||
def get_selector(key: str, value: str) -> str:
|
||||
"""Get MapCSS 0.2 selector for one key."""
|
||||
if value == "*":
|
||||
return f"[{key}]"
|
||||
if '"' in value:
|
||||
return f"[{key}='{value}']"
|
||||
return f'[{key}="{value}"]'
|
||||
|
||||
return "".join([get_selector(x, y) for (x, y) in self.tags.items()])
|
||||
|
||||
|
||||
class WayMatcher(Matcher):
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue