diff options
Diffstat (limited to 'webmap-publish')
-rwxr-xr-x | webmap-publish | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/webmap-publish b/webmap-publish index 13b432e..8db920b 100755 --- a/webmap-publish +++ b/webmap-publish @@ -45,9 +45,7 @@ import common from common import ( format_bytes, gdalSetOpenExArgs, - gdalVersionMin, - gdalGetMetadataItem, - escapeIdentifier + escape_identifier ) # Open and return source dataset. @@ -58,7 +56,7 @@ def openSourceDS(def_dict): if 'open-options' not in def_dict: def_dict['open-options'] = {} def_dict['open-options'] |= opts2 - kwargs, _ = gdalSetOpenExArgs(def_dict, flags=GDAL_OF_READONLY|GDAL_OF_VERBOSE_ERROR) + kwargs, _ = gdalSetOpenExArgs(gdal, def_dict, flags=GDAL_OF_READONLY|GDAL_OF_VERBOSE_ERROR) path = def_dict['path'] logging.debug('OpenEx(%s, %s)', path, str(kwargs)) @@ -98,7 +96,7 @@ def createMVT(basedir, options=None): 'tiling-scheme': 'TILING_SCHEME', 'extent': 'EXTENT', } - defaults_options = common.config.get('vector-tiles', None) + defaults_options = config.get('vector-tiles', None) if defaults_options is not None: for k, v in defaults_options.items(): if k not in defaults_map: @@ -152,7 +150,7 @@ def getSourceLayer(ds_src, layerdef, extent=None): logging.warning('Source layer "%s" has %d != 1 geometry fields', lyr_src.GetName(), geomFieldCount) geomField = defn.GetGeomFieldDefn(0) geomType = geomField.GetType() - geomFieldName_esc = escapeIdentifier(geomField.GetName()) + geomFieldName_esc = escape_identifier(geomField.GetName()) # transform extent to source SRS if extent is None or extent.GetSpatialReference().IsSame(srs_src): @@ -179,7 +177,7 @@ def getSourceLayer(ds_src, layerdef, extent=None): fldType = fld.GetType() if fld.GetName().lower() in reserved_fields: raise Exception(f'Invalid column name "{fld.GetName()}"') - fldName_esc = escapeIdentifier(fld.GetName()) + fldName_esc = escape_identifier(fld.GetName()) column = 'm.' + fldName_esc # for date/time/datetime fields, we let the RDBMS engine do the formatting if possible if fldType == ogr.OFTDate: @@ -221,7 +219,7 @@ def getSourceLayer(ds_src, layerdef, extent=None): else: raise Exception(f'Unsupported geometry transformation: {transform_geometry}') - query = 'SELECT ' + ', '.join(columns) + ' FROM ' + escapeIdentifier(lyr_src.GetName()) + ' m' + query = 'SELECT ' + ', '.join(columns) + ' FROM ' + escape_identifier(lyr_src.GetName()) + ' m' # add WHERE clauses and spatial filter; for GPKG/SQlite3, the query # is too complex and the driver can't use ExecuteSQL()'s spatialFilter @@ -475,15 +473,15 @@ if __name__ == '__main__': logging.error('Could not infer --name value') exit(1) - common.load_config(groupnames=None if args.groupname == [] else args.groupname) + config = common.get_config(groupnames=None if args.groupname == [] else args.groupname) # validate configuration - if 'dataset' not in common.config: + if 'dataset' not in config: raise Exception('Configuration does not specify source dataset') export_layers = {} mvtconf = {} - for layername, layerdef in common.config.get('layers', {}).items(): + for layername, layerdef in config.get('layers', {}).items(): exportdef = layerdef.get('publish', None) if exportdef is None: raise Exception(f'Layer "{layername}" has no publication definition') @@ -495,7 +493,7 @@ if __name__ == '__main__': if export_layername in export_layers: raise Exception(f'Duplicate definition for {export_layername}') x = {} - for k in ['target_name', 'minzoom', 'maxzoom']: + for k in ('target_name', 'minzoom', 'maxzoom'): if k in export_layerdef: x[k] = export_layerdef[k] mvtconf[export_layername] = x @@ -509,13 +507,13 @@ if __name__ == '__main__': pass # open source DS - ds = openSourceDS(common.config['dataset']) + ds = openSourceDS(config['dataset']) # get configured Spatial Reference System and extent; force traditional GIS order # on the target SRS since it's what MVT and JSON export are expecting - srs = common.getSRS(common.config.get('SRS', None)) + srs = common.getSRS(osr, config.get('SRS', None)) srs.SetAxisMappingStrategy(osr.OAMS_TRADITIONAL_GIS_ORDER) - extent, extent_simple = common.getExtent(common.config.get('extent', None), srs=srs) + extent, extent_simple = common.getExtent(config.get('extent', None), srs=srs) if srs.IsProjected(): # will export with centimeter precision |