Commit 1800ad10 authored by PIERSON Julie's avatar PIERSON Julie
Browse files

retrieving layer and table values works !

parent 9346e020
......@@ -131,15 +131,17 @@ class BandTableWidget(BASE, WIDGET):
if ok:
item.setText(2, str(d))
def reliefColors(self):
colors = []
def bandNames(self):
band_names = []
for i in range(self.bandClassTree.topLevelItemCount()):
item = self.bandClassTree.topLevelItem(i)
if item:
c = QgsRelief.ReliefColor(float(item.text(0)),
float(item.text(1)))
colors.append(c)
return colors
row = [item.text(0), item.text(1), item.text(2)]
band_names.append(row)
return band_names
def layerName(self):
pass
def setLayer(self, layer):
QMessageBox.information(None, self.tr('tralala'), self.tr('coucou'))
......@@ -163,11 +165,11 @@ class BandTableWidget(BASE, WIDGET):
self.bandClassTree.addTopLevelItem(item)
def value(self):
rColors = self.reliefColors()
colors = ''
for c in rColors:
colors += '{:f}, {:f};'.format(c.minElevation, c.maxElevation)
return colors[:-1]
allValues = self.cmbLayers.currentLayer().source()
allValues += ';'
for b in self.bandNames():
allValues += '{0}, {1}, {2};'.format(b[0], b[1], b[2])
return allValues[:-1]
class BandTableWidgetWrapper(WidgetWrapper):
......
......@@ -57,8 +57,21 @@ class ParameterBandTable(QgsProcessingParameterDefinition):
return 'Input parameters'
def clone(self):
return ParameterBandTable(self.name(), self.description(), self.parent,
self.flags())
return ParameterBandTable(self.name(), self.description(), self.parent, self.flags())
# getting output values as a list, 1st element for layer then one element for each row :
# ['/path/to/layer.tif', 'band 1, red, green', 'band 2, blue, red', 'bande 3, green, blue']
@staticmethod
def tableValuesAsList(value):
if value is None:
return None
if value == '':
return None
else:
return value.split(';')
class TableWidget(WidgetWrapper):
......@@ -111,7 +124,6 @@ class MergeAndRenameAlgorithm(QgsProcessingAlgorithm):
ParameterBandTable(
self.INPUT,
self.tr('Input parameters'),
self.INPUT,
False # True if optional
)
)
......@@ -131,7 +143,9 @@ class MergeAndRenameAlgorithm(QgsProcessingAlgorithm):
"""
# RETRIEVE INPUTS AND OUTPUT
input_param = self.parameterAsRasterLayer(parameters, self.INPUT, context)
#input_param = self.parameterAsRasterLayer(parameters, self.INPUT, context)
#bandData = ParameterBandTable.parseValue(parameters[self.INPUT])
band_data = ParameterBandTable.tableValuesAsList(parameters[self.INPUT])
output_raster_path = self.parameterAsOutputLayer(parameters, self.OUTPUT, context)
# # GETTING USEFUL PARAMETERS
......@@ -187,7 +201,8 @@ class MergeAndRenameAlgorithm(QgsProcessingAlgorithm):
# RETURNING RESULTS
# Return the results of the algorithm as a dictionary
return {self.OUTPUT: output_raster_path}
#return {self.OUTPUT: output_raster_path}
return {'band data' : band_data}
def name(self):
"""
......
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