Minor fix
This commit is contained in:
parent
c29cf02d85
commit
a642b9bdaa
@ -76,27 +76,28 @@ def main():
|
||||
layers = processing.run("quickosm:openosmfile", {"FILE": osmfile})
|
||||
|
||||
for osm_name, style_layer_names in names.items():
|
||||
style_name, layer_name = style_layer_names
|
||||
|
||||
# On enregistre le layer dans le gpkg
|
||||
options.layerName = style_layer_names[1]
|
||||
options.layerName = layer_name
|
||||
code, error = QgsVectorFileWriter.writeAsVectorFormat(layers[osm_name], str(workDir / "data.gpkg"), options)
|
||||
if code != 0:
|
||||
QMessageBox.warning(None, 'Erreur', f"Erreur à l'export de la couche {layer.name()} : \n\n{error}")
|
||||
return
|
||||
new_layer = QgsVectorLayer(str(workDir / f"data.gpkg|layername={layer_name}"), layer_name)
|
||||
|
||||
# Les layers suivants seront enregistrés dans le gpkg déjà existant
|
||||
options.actionOnExistingFile = QgsVectorFileWriter.CreateOrOverwriteLayer
|
||||
|
||||
# On charge le nouveau layer
|
||||
style_name, layer_name = style_layer_names
|
||||
new_layer = QgsVectorLayer(str(workDir / f"data.gpkg|layername={layer_name}"), layer_name)
|
||||
project.addMapLayer(new_layer)
|
||||
|
||||
# On charge le style
|
||||
if style_name is not None:
|
||||
stylefile = str((Path(tempdir.name) / style_name).with_suffix('.qml'))
|
||||
processing.run("native:filedownloader", {"URL": styles_url + f"/{style_name}.qml", "OUTPUT": stylefile})
|
||||
processing.run("native:filedownloader", {"URL": styles_url + f"{style_name}.qml", "OUTPUT": stylefile})
|
||||
new_layer.loadNamedStyle(stylefile)
|
||||
|
||||
# On charge le nouveau layer
|
||||
project.addMapLayer(new_layer)
|
||||
|
||||
try:
|
||||
project.removeMapLayer(project.mapLayersByName("OpenStreetMap")[0])
|
||||
except IndexError:
|
||||
|
Loading…
Reference in New Issue
Block a user