aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xwebmap-publish42
1 files changed, 23 insertions, 19 deletions
diff --git a/webmap-publish b/webmap-publish
index a33d56e..c4103ef 100755
--- a/webmap-publish
+++ b/webmap-publish
@@ -482,6 +482,7 @@ if __name__ == '__main__':
raise Exception('Configuration does not specify source dataset')
export_layers = {}
+ mvtconf = {}
for layername, layerdef in common.config.get('layers', {}).items():
exportdef = layerdef.get('publish', None)
if exportdef is None:
@@ -491,11 +492,14 @@ if __name__ == '__main__':
elif isinstance(exportdef, list):
exportdef = { l:{} for l in exportdef }
for export_layername, export_layerdef in exportdef.items():
- if 'target_name' in export_layerdef:
- export_layername = export_layerdef.pop('target_name')
- if export_layername not in export_layers:
- export_layers[export_layername] = []
- export_layers[export_layername].append(export_layerdef)
+ if export_layername in export_layers:
+ raise Exception(f'Duplicate definition for {export_layername}')
+ x = {}
+ for k in ['target_name', 'minzoom', 'maxzoom']:
+ if k in export_layerdef:
+ x[k] = export_layerdef[k]
+ mvtconf[export_layername] = x
+ export_layers[export_layername] = export_layerdef
export_layerdef['__layername-src__'] = layername
if args.destdir != os.curdir:
@@ -546,6 +550,7 @@ if __name__ == '__main__':
'BUFFER': 32,
'TILE_EXTENSION': tile_extension.removeprefix('.'),
'TEMPORARY_DB': Path(tempdir).joinpath('tmp-mvt.db'),
+ 'CONF': json.dumps(mvtconf, ensure_ascii=False, separators=(',',':')),
})
# use a temporary directory for the metadata to avoid messing
@@ -558,25 +563,24 @@ if __name__ == '__main__':
os.chmod(metadata['tempdir'], 0o0755, dir_fd=metadata.get('dirfd', None),
follow_symlinks=False)
nextfid = 0
- for layername, layerdefs in export_layers.items():
+ for layername, layerdef in export_layers.items():
# create destination layer
lyr_dst = ds_dst.CreateLayer(layername, srs=srs, geom_type=ogr.wkbUnknown)
if lyr_dst is None:
raise Exception(f'Could not create destination layer "{layername}"')
- for layerdef in layerdefs:
- lyr_src = getSourceLayer(ds, layerdef, extent=extent)
- try:
- # use the non-dense geometry (a rectangle) for clipping as it's faster
- # and there is no need to reproject (the SRSs match)
- nextfid, count0 = exportLayer(lyr_dst, lyr_src,
- layername=layerdef['__layername-src__'],
- srs=srs, clip=extent_simple,
- coordinate_precision=coordinate_precision,
- nextfid=nextfid, metadata=metadata)
- nFeatures += count0
- finally:
- ds.ReleaseResultSet(lyr_src)
+ lyr_src = getSourceLayer(ds, layerdef, extent=extent)
+ try:
+ # use the non-dense geometry (a rectangle) for clipping as it's faster
+ # and there is no need to reproject (the SRSs match)
+ nextfid, count0 = exportLayer(lyr_dst, lyr_src,
+ layername=layerdef['__layername-src__'],
+ srs=srs, clip=extent_simple,
+ coordinate_precision=coordinate_precision,
+ nextfid=nextfid, metadata=metadata)
+ nFeatures += count0
+ finally:
+ ds.ReleaseResultSet(lyr_src)
lyr_dst = None
# close datasets