Improve display of OSM tagging presets

This commit is contained in:
Edward Betts 2021-05-14 13:54:54 +02:00
parent b61636adc2
commit 664d6c5538
2 changed files with 45 additions and 23 deletions

View file

@ -785,14 +785,27 @@ def get_presets_from_tags(tags):
preset_dir = app.config["ID_PRESET_DIR"]
found = []
for k, v in tags.items():
if k == 'amenity' and v == 'clock' and tags.get('display') == 'sundial':
tag_or_key = f"Tag:{k}={v}"
found.append({"tag_or_key": tag_or_key, "name": "Sundial"})
continue
filename = os.path.join(preset_dir, k, v + ".json")
if not os.path.exists(filename):
filename = os.path.join(preset_dir, k + ".json")
if not os.path.exists(filename):
continue
if os.path.exists(filename):
tag_or_key = f"Tag:{k}={v}"
else:
filename = os.path.join(preset_dir, k, "_" + v + ".json")
if os.path.exists(filename):
tag_or_key = f"Tag:{k}={v}"
else:
filename = os.path.join(preset_dir, k + ".json")
if os.path.exists(filename):
tag_or_key = f"Key:{k}"
else:
continue
data = json.load(open(filename))
name = data["name"]
found.append(name)
found.append({"tag_or_key": tag_or_key, "name": name})
return found