mirror of
https://github.com/enzet/map-machine.git
synced 2025-06-05 12:21:54 +02:00
Add tag verification.
This commit is contained in:
parent
6580b8f899
commit
9188e99d50
2 changed files with 18 additions and 2 deletions
|
@ -107,6 +107,20 @@ class Tagged:
|
|||
|
||||
return None
|
||||
|
||||
def verify(self) -> bool:
|
||||
"""Check key and value types."""
|
||||
is_well_formed: bool = True
|
||||
|
||||
for value, key in self.tags.items():
|
||||
if not isinstance(key, str):
|
||||
logging.warning(f"Not string key {key}.")
|
||||
is_well_formed = False
|
||||
if not isinstance(value, str):
|
||||
logging.warning(f"Not string value {value}.")
|
||||
is_well_formed = False
|
||||
|
||||
return is_well_formed
|
||||
|
||||
|
||||
@dataclass
|
||||
class OSMNode(Tagged):
|
||||
|
|
|
@ -14,7 +14,7 @@ from colour import Color
|
|||
|
||||
from map_machine.feature.direction import DirectionSet
|
||||
from map_machine.map_configuration import MapConfiguration, LabelMode
|
||||
from map_machine.osm.osm_reader import Tags
|
||||
from map_machine.osm.osm_reader import Tagged, Tags
|
||||
from map_machine.pictogram.icon import (
|
||||
DEFAULT_COLOR,
|
||||
DEFAULT_SHAPE_ID,
|
||||
|
@ -102,7 +102,7 @@ def match_location(restrictions: dict[str, str], country: str) -> bool:
|
|||
return True
|
||||
|
||||
|
||||
class Matcher:
|
||||
class Matcher(Tagged):
|
||||
"""Tag matching."""
|
||||
|
||||
def __init__(
|
||||
|
@ -126,6 +126,8 @@ class Matcher:
|
|||
if "location_restrictions" in structure:
|
||||
self.location_restrictions = structure["location_restrictions"]
|
||||
|
||||
self.verify()
|
||||
|
||||
def check_zoom_level(self, zoom_level: float) -> bool:
|
||||
"""Check whether zoom level is matching."""
|
||||
return (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue