mirror of
https://github.com/enzet/map-machine.git
synced 2025-06-14 08:41:53 +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
|
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
|
@dataclass
|
||||||
class OSMNode(Tagged):
|
class OSMNode(Tagged):
|
||||||
|
|
|
@ -14,7 +14,7 @@ from colour import Color
|
||||||
|
|
||||||
from map_machine.feature.direction import DirectionSet
|
from map_machine.feature.direction import DirectionSet
|
||||||
from map_machine.map_configuration import MapConfiguration, LabelMode
|
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 (
|
from map_machine.pictogram.icon import (
|
||||||
DEFAULT_COLOR,
|
DEFAULT_COLOR,
|
||||||
DEFAULT_SHAPE_ID,
|
DEFAULT_SHAPE_ID,
|
||||||
|
@ -102,7 +102,7 @@ def match_location(restrictions: dict[str, str], country: str) -> bool:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
class Matcher:
|
class Matcher(Tagged):
|
||||||
"""Tag matching."""
|
"""Tag matching."""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
|
@ -126,6 +126,8 @@ class Matcher:
|
||||||
if "location_restrictions" in structure:
|
if "location_restrictions" in structure:
|
||||||
self.location_restrictions = structure["location_restrictions"]
|
self.location_restrictions = structure["location_restrictions"]
|
||||||
|
|
||||||
|
self.verify()
|
||||||
|
|
||||||
def check_zoom_level(self, zoom_level: float) -> bool:
|
def check_zoom_level(self, zoom_level: float) -> bool:
|
||||||
"""Check whether zoom level is matching."""
|
"""Check whether zoom level is matching."""
|
||||||
return (
|
return (
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue