diff options
author | Daniel Schadt <kingdread@gmx.de> | 2022-11-18 23:20:27 +0100 |
---|---|---|
committer | Daniel Schadt <kingdread@gmx.de> | 2022-11-18 23:23:01 +0100 |
commit | 87f248e1783cbf81c6f2c8d8133fda0519513031 (patch) | |
tree | b4345fc22a728140b2df3c615a77e78354b61bcb | |
parent | ff8cbb6817bfa174e14cec0f24f264330fc41426 (diff) | |
download | fietsboek-87f248e1783cbf81c6f2c8d8133fda0519513031.tar.gz fietsboek-87f248e1783cbf81c6f2c8d8133fda0519513031.tar.bz2 fietsboek-87f248e1783cbf81c6f2c8d8133fda0519513031.zip |
split layer extraction into two functions
-rw-r--r-- | fietsboek/views/tileproxy.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/fietsboek/views/tileproxy.py b/fietsboek/views/tileproxy.py index 1c8a054..2a1e6d0 100644 --- a/fietsboek/views/tileproxy.py +++ b/fietsboek/views/tileproxy.py @@ -268,6 +268,12 @@ def extract_tile_layers(settings): :rtype: list[TileSource] """ layers = [] + layers.extend(_extract_thunderforest(settings)) + layers.extend(_extract_user_layers(settings)) + return layers + + +def _extract_thunderforest(settings): # Thunderforest Shortcut! tf_api_key = settings.get("thunderforest.api_key") if tf_api_key: @@ -280,11 +286,13 @@ def extract_tile_layers(settings): for tf_map in settings["thunderforest.maps"]: url = (f"https://tile.thunderforest.com/{tf_map}/" f"{{z}}/{{x}}/{{y}}.png?apikey={tf_api_key}") - layers.append(TileSource( + yield TileSource( f"tf-{tf_map}", f"TF {tf_map.title()}", url, LayerType.BASE, 22, tf_access, tf_attribution, - )) + ) + +def _extract_user_layers(settings): # Any other custom maps for key in settings.keys(): match = re.match("^fietsboek\\.tile_layer\\.([A-Za-z0-9_-]+)$", key) @@ -299,5 +307,4 @@ def extract_tile_layers(settings): attribution = settings.get(f"{key}.attribution", _jb_copy) access = LayerAccess(settings.get(f"{key}.access", "public")) - layers.append(TileSource(provider_id, name, url, layer_type, zoom, access, attribution)) - return layers + yield TileSource(provider_id, name, url, layer_type, zoom, access, attribution) |