mirror of
https://github.com/enzet/map-machine.git
synced 2025-06-09 14:21:50 +02:00
Support tags to skip.
This commit is contained in:
parent
d531d91a65
commit
15ab5e7d62
2 changed files with 45 additions and 15 deletions
|
@ -346,10 +346,11 @@ class Scheme:
|
||||||
self.area_matchers: list[Matcher] = [
|
self.area_matchers: list[Matcher] = [
|
||||||
Matcher(x) for x in content["area_tags"]
|
Matcher(x) for x in content["area_tags"]
|
||||||
]
|
]
|
||||||
self.tags_to_write: list[str] = content["tags_to_write"]
|
self.keys_to_write: list[str] = content["keys_to_write"]
|
||||||
self.prefix_to_write: list[str] = content["prefix_to_write"]
|
self.prefix_to_write: list[str] = content["prefix_to_write"]
|
||||||
self.tags_to_skip: list[str] = content["tags_to_skip"]
|
self.keys_to_skip: list[str] = content["keys_to_skip"]
|
||||||
self.prefix_to_skip: list[str] = content["prefix_to_skip"]
|
self.prefix_to_skip: list[str] = content["prefix_to_skip"]
|
||||||
|
self.tags_to_skip: dict[str, str] = content["tags_to_skip"]
|
||||||
|
|
||||||
# Storage for created icon sets.
|
# Storage for created icon sets.
|
||||||
self.cache: dict[str, tuple[IconSet, int]] = {}
|
self.cache: dict[str, tuple[IconSet, int]] = {}
|
||||||
|
@ -379,34 +380,56 @@ class Scheme:
|
||||||
logging.debug(f"Unknown color `{color}`.")
|
logging.debug(f"Unknown color `{color}`.")
|
||||||
return DEFAULT_COLOR
|
return DEFAULT_COLOR
|
||||||
|
|
||||||
def is_no_drawable(self, key: str) -> bool:
|
def is_no_drawable(self, key: str, value: str) -> bool:
|
||||||
"""
|
"""
|
||||||
Return true if key is specified as no drawable (should not be
|
Return true if key is specified as no drawable (should not be
|
||||||
represented on the map as icon set or as text) by the scheme.
|
represented on the map as icon set or as text) by the scheme.
|
||||||
|
|
||||||
:param key: OpenStreetMap tag key
|
:param key: OpenStreetMap tag key
|
||||||
|
:param value: OpenStreetMap tag value
|
||||||
"""
|
"""
|
||||||
if key in self.tags_to_write or key in self.tags_to_skip:
|
if (
|
||||||
|
key in self.keys_to_write + self.keys_to_skip
|
||||||
|
or key in self.tags_to_skip
|
||||||
|
and self.tags_to_skip[key] == value
|
||||||
|
):
|
||||||
return True
|
return True
|
||||||
for prefix in self.prefix_to_write + self.prefix_to_skip:
|
|
||||||
if key[: len(prefix) + 1] == f"{prefix}:":
|
if ":" in key:
|
||||||
|
prefix: str = key.split(":")[0]
|
||||||
|
if prefix in self.prefix_to_write + self.prefix_to_skip:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def is_writable(self, key: str) -> bool:
|
def is_writable(self, key: str, value: str) -> bool:
|
||||||
"""
|
"""
|
||||||
Return true if key is specified as writable (should be represented on
|
Return true if key is specified as writable (should be represented on
|
||||||
the map as text) by the scheme.
|
the map as text) by the scheme.
|
||||||
|
|
||||||
:param key: OpenStreetMap tag key
|
:param key: OpenStreetMap tag key
|
||||||
|
:param value: OpenStreetMap tag value
|
||||||
"""
|
"""
|
||||||
if key in self.tags_to_skip:
|
if (
|
||||||
|
key in self.keys_to_skip
|
||||||
|
or key in self.tags_to_skip
|
||||||
|
and self.tags_to_skip[key] == value
|
||||||
|
):
|
||||||
return False
|
return False
|
||||||
if key in self.tags_to_write:
|
|
||||||
|
if key in self.keys_to_write:
|
||||||
return True
|
return True
|
||||||
for prefix in self.prefix_to_write:
|
|
||||||
if key[: len(prefix) + 1] == f"{prefix}:":
|
prefix: Optional[str] = None
|
||||||
|
if ":" in key:
|
||||||
|
prefix = key.split(":")[0]
|
||||||
|
|
||||||
|
if prefix in self.prefix_to_skip:
|
||||||
|
return False
|
||||||
|
|
||||||
|
if prefix in self.prefix_to_write:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def get_icon(
|
def get_icon(
|
||||||
|
@ -633,7 +656,11 @@ class Scheme:
|
||||||
:param tags: input tag dictionary
|
:param tags: input tag dictionary
|
||||||
:param processed: processed set
|
:param processed: processed set
|
||||||
"""
|
"""
|
||||||
[processed.add(tag) for tag in tags if self.is_no_drawable(tag)]
|
[
|
||||||
|
processed.add(tag)
|
||||||
|
for tag in tags
|
||||||
|
if self.is_no_drawable(tag, tags[tag])
|
||||||
|
]
|
||||||
|
|
||||||
def get_shape_specification(
|
def get_shape_specification(
|
||||||
self,
|
self,
|
||||||
|
|
|
@ -2207,7 +2207,7 @@ area_tags:
|
||||||
- tags: {power: "compensator"}
|
- tags: {power: "compensator"}
|
||||||
- tags: {power: "substation"}
|
- tags: {power: "substation"}
|
||||||
|
|
||||||
tags_to_write:
|
keys_to_write:
|
||||||
- "STIF:zone"
|
- "STIF:zone"
|
||||||
- "alt_name"
|
- "alt_name"
|
||||||
- "artist_name"
|
- "artist_name"
|
||||||
|
@ -2314,7 +2314,7 @@ prefix_to_write:
|
||||||
- "website"
|
- "website"
|
||||||
- "wikipedia"
|
- "wikipedia"
|
||||||
|
|
||||||
tags_to_skip:
|
keys_to_skip:
|
||||||
- "FIXME"
|
- "FIXME"
|
||||||
- "attribution"
|
- "attribution"
|
||||||
- "building:levels"
|
- "building:levels"
|
||||||
|
@ -2347,3 +2347,6 @@ prefix_to_skip:
|
||||||
- "source"
|
- "source"
|
||||||
- "razed"
|
- "razed"
|
||||||
- "removed"
|
- "removed"
|
||||||
|
|
||||||
|
tags_to_skip:
|
||||||
|
highway: motorway_junction
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue