Docker-in-Docker (DinD) capabilities of public runners deactivated. More info

Commit 3fa10398 authored by PIERSON Julie's avatar PIERSON Julie
Browse files

launching from history ok even when some layers are not loaded

parent 87347d2a
...@@ -149,20 +149,27 @@ class MergeBandTableWidget(BASE, WIDGET): ...@@ -149,20 +149,27 @@ class MergeBandTableWidget(BASE, WIDGET):
# when launching alg from history in processing, setting parameters # when launching alg from history in processing, setting parameters
def setValue(self, value): def setValue(self, value):
QMessageBox.information(None, self.tr('window name'), self.tr('message'))
self.bandClassTree.clear() self.bandClassTree.clear()
# getting raster names # getting raster names
param = value.split(';') param = value.split(';')
param = [i.split(',') for i in param] param = [i.split(',') for i in param]
rasterNames = [i[0] for i in param] rasterNames = [i[0] for i in param]
QMessageBox.information(None, self.tr('hop'), self.tr(str(param))) # keeping only loaded layers
rasterNames = [i for i in rasterNames if len(QgsProject.instance().mapLayersByName(i)) != 0]
# checking items in combobox # checking items in combobox
self.multiLayers.setCheckedItems(rasterNames) self.multiLayers.setCheckedItems(rasterNames)
# populating second column in table with band future name # clearing table since rasters may not have been added in right order when checking items
bandNames = [i[1] for i in param] self.bandClassTree.clear()
root = self.bandClassTree.invisibleRootItem() # for each raster
for i in range(len(bandNames)): for r in param:
item = item = root.child(i) # if a raster is loaded
item.setText(1, bandNames[i]) if r[0] in rasterNames:
# populate columns in table
item = QTreeWidgetItem()
item.setText(0, r[0])
item.setText(1, r[1])
self.bandClassTree.addTopLevelItem(item)
# return a list each element for a table row # return a list each element for a table row
# ['band 1, new name 1', 'band 2, new name 2'] # ['band 1, new name 1', 'band 2, new name 2']
......
...@@ -114,9 +114,6 @@ class MergeAndRenameAlgorithm(QgsProcessingAlgorithm): ...@@ -114,9 +114,6 @@ class MergeAndRenameAlgorithm(QgsProcessingAlgorithm):
input_param = ParameterMergeBandTable.tableValuesAsList(parameters[self.INPUT]) input_param = ParameterMergeBandTable.tableValuesAsList(parameters[self.INPUT])
output_raster_path = self.parameterAsOutputLayer(parameters, self.OUTPUT, context) output_raster_path = self.parameterAsOutputLayer(parameters, self.OUTPUT, context)
message = 'input_param : ' + str(input_param)
feedback.pushInfo(QCoreApplication.translate('merge and rename', message))
# GETTING USEFUL PARAMETERS # GETTING USEFUL PARAMETERS
# number of rows in table = number of bands to merge # number of rows in table = number of bands to merge
...@@ -135,9 +132,7 @@ class MergeAndRenameAlgorithm(QgsProcessingAlgorithm): ...@@ -135,9 +132,7 @@ class MergeAndRenameAlgorithm(QgsProcessingAlgorithm):
rasterLayers = [QgsProject.instance().mapLayersByName(i)[0] for i in rasterNames] rasterLayers = [QgsProject.instance().mapLayersByName(i)[0] for i in rasterNames]
rasterPaths = [i.source() for i in rasterLayers] rasterPaths = [i.source() for i in rasterLayers]
# MERGING BANDS # MERGING BANDS
merge_param = { merge_param = {
'INPUT' : rasterPaths, 'INPUT' : rasterPaths,
'SEPARATE' : True, 'SEPARATE' : True,
...@@ -159,7 +154,6 @@ class MergeAndRenameAlgorithm(QgsProcessingAlgorithm): ...@@ -159,7 +154,6 @@ class MergeAndRenameAlgorithm(QgsProcessingAlgorithm):
new_name = band_table[band_number][index_oldname] new_name = band_table[band_number][index_oldname]
band.SetDescription(new_name) band.SetDescription(new_name)
# RETURNING RESULTS # RETURNING RESULTS
# Return the results of the algorithm as a dictionary # Return the results of the algorithm as a dictionary
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment