Explosion des other_tags et mise à jour des styles
This commit is contained in:
parent
c52ddb0bb3
commit
3093f80066
@ -10,6 +10,7 @@ import tempfile
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from processing.tools import dataobjects
|
||||
|
||||
def main():
|
||||
# Paramètres du projet
|
||||
@ -24,6 +25,8 @@ def main():
|
||||
options = QgsVectorFileWriter.SaveVectorOptions()
|
||||
options.actionOnExistingFile = QgsVectorFileWriter.CreateOrOverwriteFile
|
||||
options.driverName = "GPKG"
|
||||
context = dataobjects.createContext()
|
||||
context.setInvalidGeometryCheck(QgsFeatureRequest.GeometryNoCheck)
|
||||
|
||||
# Correspondances des noms des couches et des styles:
|
||||
# "NOM_DE_LA_COUCHE_OSM": ("nom_du_style", "nom_du_layer")
|
||||
@ -78,11 +81,14 @@ def main():
|
||||
for osm_name, style_layer_names in names.items():
|
||||
style_name, layer_name = style_layer_names
|
||||
|
||||
# On explose les champs
|
||||
layer = processing.run("native:explodehstorefield", parameters={"INPUT": layers[osm_name], "FIELD": "other_tags", "OUTPUT": "memory:"}, context=context)["OUTPUT"]
|
||||
|
||||
# On enregistre le layer dans le gpkg
|
||||
options.layerName = layer_name
|
||||
code, error = QgsVectorFileWriter.writeAsVectorFormat(layers[osm_name], str(workDir / "data.gpkg"), options)
|
||||
code, error = QgsVectorFileWriter.writeAsVectorFormat(layer, str(workDir / "data.gpkg"), options)
|
||||
if code != 0:
|
||||
QMessageBox.warning(None, 'Erreur', f"Erreur à l'export de la couche {layer.name()} : \n\n{error}")
|
||||
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)
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
1657
styles/point.qml
1657
styles/point.qml
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user