aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Schadt <kingdread@gmx.de>2022-11-17 23:01:50 +0100
committerDaniel Schadt <kingdread@gmx.de>2022-11-17 23:01:50 +0100
commit45e6b84b818b1d729e558e811a3020d8fd3ca3b9 (patch)
tree62b929dc1814856a3dec9a1fd75f2a5d63007096
parent5607aa64cac1f67169e742d397c2ac8d9c9057a8 (diff)
downloadfietsboek-45e6b84b818b1d729e558e811a3020d8fd3ca3b9.tar.gz
fietsboek-45e6b84b818b1d729e558e811a3020d8fd3ca3b9.tar.bz2
fietsboek-45e6b84b818b1d729e558e811a3020d8fd3ca3b9.zip
add a shortcut for Thunderforest maps
Now, we can add Thunderforest maps with thunderforest.api_key = ... thunderforest.maps = cycling ...
-rw-r--r--fietsboek/__init__.py2
-rw-r--r--fietsboek/views/tileproxy.py18
2 files changed, 20 insertions, 0 deletions
diff --git a/fietsboek/__init__.py b/fietsboek/__init__.py
index 21674f5..7aede7b 100644
--- a/fietsboek/__init__.py
+++ b/fietsboek/__init__.py
@@ -72,6 +72,8 @@ def main(global_config, **settings):
settings.get('available_locales', 'en'))
settings['fietsboek.pages'] = aslist(
settings.get('fietsboek.pages', ''))
+ settings['thunderforest.maps'] = aslist(
+ settings.get('thunderforest.maps', ''))
settings['fietsboek.default_tile_layers'] = aslist(
settings.get('fietsboek.default_tile_layers',
'osm satellite osmde opentopo topplusopen opensea cycling hiking'))
diff --git a/fietsboek/views/tileproxy.py b/fietsboek/views/tileproxy.py
index 42e1a67..ff68e30 100644
--- a/fietsboek/views/tileproxy.py
+++ b/fietsboek/views/tileproxy.py
@@ -263,6 +263,24 @@ def extract_tile_layers(settings):
:rtype: list[TileSource]
"""
layers = []
+ # Thunderforest Shortcut!
+ tf_api_key = settings.get("thunderforest.api_key")
+ if tf_api_key:
+ tf_access = LayerAccess(settings.get("thunderforest.access", "restricted"))
+ tf_attribution = ' | '.join([
+ _jb_copy,
+ _href("https://www.thunderforest.com/", "Thunderforest"),
+ _href("https://www.openstreetmap.org/", "OpenStreetMap"),
+ ])
+ 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(
+ f"tf-{tf_map}", f"TF {tf_map.title()}", url,
+ LayerType.BASE, 22, tf_access, tf_attribution,
+ ))
+
+ # Any other custom maps
for key in settings.keys():
match = re.match("^fietsboek\\.tile_layer\\.([A-Za-z0-9_-]+)$", key)
if not match: