aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common.py17
-rw-r--r--config.yml123
-rwxr-xr-xwebmap-download2
3 files changed, 76 insertions, 66 deletions
diff --git a/common.py b/common.py
index 67ab208..3eb8a3e 100644
--- a/common.py
+++ b/common.py
@@ -42,11 +42,18 @@ def load_config(path=None, groupnames=None):
# validate sources
destinations = {}
- for name, layer in layers.items():
- if isinstance(layer, dict):
- layers[name] = layer = [layer]
-
- for sourcedef in layer:
+ for name, layerdefs in layers.items():
+ if isinstance(layerdefs, dict) and 'sources' not in layerdefs:
+ layers[name] = { 'sources': [layerdefs] }
+ for k in ['description', 'create']:
+ if k in layerdefs:
+ layers[name][k] = layerdefs.pop(k)
+ layerdefs = layers[name]
+
+ if 'sources' not in layerdefs:
+ raise Exception(f'Layer "{name}" does not have any source receipe')
+
+ for sourcedef in layerdefs.get('sources', []):
source = sourcedef.get('source', None)
if source is None:
continue
diff --git a/config.yml b/config.yml
index af8d73c..772cb0e 100644
--- a/config.yml
+++ b/config.yml
@@ -1,4 +1,5 @@
---
+# Spatial Reference System and (2D) extent
SRS: 'EPSG:3006' # a.k.a. SWEREF99 TM, cf. https://epsg.io/3006
extent:
# Lantmäteriet uses a tile-scheme where the origin (upper-left corner) is at
@@ -31,41 +32,42 @@ layer-groups:
layers:
-# # Keys are layer names in the output dataset. Values are list of dictionaries
-# # specifying source data and conversion information for these layers. If a
-# # layer has a single source, then it can be inlined instead.
+# # Dictionary of layer names and source receipes in the output dataset.
+# # If a layer has a single source, then the sources singleton can be
+# # inlined.
# layer1_name:
-# - source:
-# download:
-# # source:download:url: URL from where to download the source file.
-# # source:download can be used as an alias when source:download:url is
-# # its only subkey.
-# url: 'https://example.net/path/to/layer.zip'
-# # source:download:max-size: The maximum size to download in bytes. An
-# # error is raised when the payload size exceeds this value.
-# # (Default: 67108864, in other words 64MiB)
-# max-size: 1073741824
-# # source:download:module: Basename of the download module to use for
-# # that layer.
-# module: webmap-download
-# cache:
-# # source:cache:path: Local path (relative to --cachedir) where to
-# # (atomically) save the downloaded file. The same path can be used by
-# # multiple entries as long as their pairs (source:download:url,
-# # source:download:module) match. Any parent directories are created if
-# # needed.
-# # If the path is empty or ends with a '/' character then it treated as a
-# # directory and the last component of source:download:url implicitly
-# # used as filename. In that case an error is raised if no filename can
-# # be derived from the URL.
-# # source:cache can be used as an alias when source:cache:path is its
-# # only subkey.
-# path: path/to/sub/dir/
-# # source:cache:max-age: Maximum age for caching, in number of seconds
-# # ago. If source:cache:path exists and its mtime and/or ctime is newer
-# # than this value then no HTTP query is made.
-# # (Default: 21600, in other words 6h)
-# max-age: 86400
+# sources:
+# - source:
+# download:
+# # source:download:url: URL from where to download the source file.
+# # source:download can be used as an alias when source:download:url is
+# # its only subkey.
+# url: 'https://example.net/path/to/layer.zip'
+# # source:download:max-size: The maximum size to download in bytes. An
+# # error is raised when the payload size exceeds this value.
+# # (Default: 67108864, in other words 64MiB)
+# max-size: 1073741824
+# # source:download:module: Basename of the download module to use for
+# # that layer.
+# module: webmap-download
+# cache:
+# # source:cache:path: Local path (relative to --cachedir) where to
+# # (atomically) save the downloaded file. The same path can be used by
+# # multiple entries as long as their pairs (source:download:url,
+# # source:download:module) match. Any parent directories are created if
+# # needed.
+# # If the path is empty or ends with a '/' character then it treated as a
+# # directory and the last component of source:download:url implicitly
+# # used as filename. In that case an error is raised if no filename can
+# # be derived from the URL.
+# # source:cache can be used as an alias when source:cache:path is its
+# # only subkey.
+# path: path/to/sub/dir/
+# # source:cache:max-age: Maximum age for caching, in number of seconds
+# # ago. If source:cache:path exists and its mtime and/or ctime is newer
+# # than this value then no HTTP query is made.
+# # (Default: 21600, in other words 6h)
+# max-age: 86400
'nvr:TILLTRADESFORBUD':
source:
@@ -172,32 +174,33 @@ layers:
cache: sks/
'sks:UtfordAvverk':
- - source:
- download:
- url: 'https://geodpags.skogsstyrelsen.se/geodataport/data/sksUtfordAvverk-2000-2015.zip'
- max-size: 805306368 # 768MiB
- cache:
- path: sks/
- max-age: 2592000 # 30d
- - source:
- download:
- url: 'https://geodpags.skogsstyrelsen.se/geodataport/data/sksUtfordAvverk-2016-2019.zip'
- max-size: 805306368 # 768MiB
- cache:
- path: sks/
- max-age: 2592000 # 30d
- - source:
- download:
- url: 'https://geodpags.skogsstyrelsen.se/geodataport/data/sksUtfordAvverk-2020-2022.zip'
- max-size: 805306368 # 768MiB
- cache:
- path: sks/
- max-age: 864000 # 10d
- - source:
- download:
- url: 'https://geodpags.skogsstyrelsen.se/geodataport/data/sksUtfordAvverk-2023-.zip'
- max-size: 1073741824 # 1GiB
- cache: sks/
+ sources:
+ - source:
+ download:
+ url: 'https://geodpags.skogsstyrelsen.se/geodataport/data/sksUtfordAvverk-2000-2015.zip'
+ max-size: 805306368 # 768MiB
+ cache:
+ path: sks/
+ max-age: 2592000 # 30d
+ - source:
+ download:
+ url: 'https://geodpags.skogsstyrelsen.se/geodataport/data/sksUtfordAvverk-2016-2019.zip'
+ max-size: 805306368 # 768MiB
+ cache:
+ path: sks/
+ max-age: 2592000 # 30d
+ - source:
+ download:
+ url: 'https://geodpags.skogsstyrelsen.se/geodataport/data/sksUtfordAvverk-2020-2022.zip'
+ max-size: 805306368 # 768MiB
+ cache:
+ path: sks/
+ max-age: 864000 # 10d
+ - source:
+ download:
+ url: 'https://geodpags.skogsstyrelsen.se/geodataport/data/sksUtfordAvverk-2023-.zip'
+ max-size: 1073741824 # 1GiB
+ cache: sks/
'st:betesomraden':
source:
diff --git a/webmap-download b/webmap-download
index 2724951..a4a6413 100755
--- a/webmap-download
+++ b/webmap-download
@@ -162,7 +162,7 @@ if __name__ == '__main__':
sources = []
for name, layerdefs in common.config.get('layers', {}).items():
- for layerdef in layerdefs:
+ for layerdef in layerdefs['sources']:
sourcedef = layerdef.get('source', {})
sourcedef['layername'] = name
sources.append(sourcedef)