Skip to content
Snippets Groups Projects
Commit 1216796a authored by Alexian Masson's avatar Alexian Masson
Browse files

ProfileDialog: Check if topo_bath field is present

parent 1576b976
1 merge request!74ProfileDialog: Check if topo_bath field is present
Pipeline #22438 failed
......@@ -375,6 +375,36 @@ class ProfileDialog(QtWidgets.QDialog, FORM_CLASS):
if self.file is not None and self.file.layer() is not None:
self.file.layer().layerModified.disconnect(self.layer_modified)
# Check if topo_bath field is present
if layer is not None:
if layer.fields().indexFromName("topo_bath") == -1:
self.message_bar.pushMessage(
self.tr("Missing field"),
self.tr(
"The field 'topo_bath' is missing in the layer. "
"Please add it before using this tool."
),
Qgis.MessageLevel.Critical,
duration=5,
)
# Show fieldcalculator algorithm dialog
processing.execAlgorithmDialog(
"native:fieldcalculator",
{
'INPUT': '/app/test/data/input/profiles_lines.geojson',
'FIELD_NAME': 'topo_bath',
'FIELD_TYPE': 2,
'FIELD_LENGTH': 0,
'FIELD_PRECISION': 0,
'FORMULA': "'B' || replace(rpad('', num_points($geometry) - 1, ','), ',', ',B')",
'OUTPUT': 'TEMPORARY_OUTPUT'
}
)
self.layerComboBox.setLayer(None)
return
self.file = PreCourlisFileLine(layer)
self.sectionItemModel.setLayer(layer)
self.sectionComboBox.setCurrentIndex(0)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment