Skip to content
Permalink
Browse files

[processing][grass] Push feedback object to algorithm methods

  • Loading branch information
nyalldawson committed Apr 9, 2018
1 parent ccccad5 commit c50a0397459b6fd9077c166850760bf6884a91e1
Showing with 243 additions and 243 deletions.
  1. +7 −7 python/plugins/processing/algs/grass7/Grass7Algorithm.py
  2. +2 −2 python/plugins/processing/algs/grass7/ext/i_cca.py
  3. +2 −2 python/plugins/processing/algs/grass7/ext/i_cluster.py
  4. +3 −3 python/plugins/processing/algs/grass7/ext/i_colors_enhance.py
  5. +2 −2 python/plugins/processing/algs/grass7/ext/i_gensig.py
  6. +2 −2 python/plugins/processing/algs/grass7/ext/i_gensigset.py
  7. +1 −1 python/plugins/processing/algs/grass7/ext/i_in_spotvgt.py
  8. +3 −3 python/plugins/processing/algs/grass7/ext/i_landsat_acca.py
  9. +3 −3 python/plugins/processing/algs/grass7/ext/i_landsat_toar.py
  10. +2 −2 python/plugins/processing/algs/grass7/ext/i_maxlik.py
  11. +3 −3 python/plugins/processing/algs/grass7/ext/i_pansharpen.py
  12. +2 −2 python/plugins/processing/algs/grass7/ext/i_segment.py
  13. +2 −2 python/plugins/processing/algs/grass7/ext/i_smap.py
  14. +2 −2 python/plugins/processing/algs/grass7/ext/r_blend_combine.py
  15. +4 −4 python/plugins/processing/algs/grass7/ext/r_blend_rgb.py
  16. +4 −4 python/plugins/processing/algs/grass7/ext/r_category.py
  17. +4 −4 python/plugins/processing/algs/grass7/ext/r_colors.py
  18. +4 −4 python/plugins/processing/algs/grass7/ext/r_colors_stddev.py
  19. +1 −1 python/plugins/processing/algs/grass7/ext/r_horizon.py
  20. +2 −2 python/plugins/processing/algs/grass7/ext/r_li.py
  21. +2 −2 python/plugins/processing/algs/grass7/ext/r_li_cwed.py
  22. +3 −3 python/plugins/processing/algs/grass7/ext/r_li_cwed_ascii.py
  23. +2 −2 python/plugins/processing/algs/grass7/ext/r_li_dominance.py
  24. +3 −3 python/plugins/processing/algs/grass7/ext/r_li_dominance_ascii.py
  25. +2 −2 python/plugins/processing/algs/grass7/ext/r_li_edgedensity.py
  26. +3 −3 python/plugins/processing/algs/grass7/ext/r_li_edgedensity_ascii.py
  27. +2 −2 python/plugins/processing/algs/grass7/ext/r_li_mpa.py
  28. +3 −3 python/plugins/processing/algs/grass7/ext/r_li_mpa_ascii.py
  29. +2 −2 python/plugins/processing/algs/grass7/ext/r_li_mps.py
  30. +3 −3 python/plugins/processing/algs/grass7/ext/r_li_mps_ascii.py
  31. +2 −2 python/plugins/processing/algs/grass7/ext/r_li_padcv.py
  32. +3 −3 python/plugins/processing/algs/grass7/ext/r_li_padcv_ascii.py
  33. +2 −2 python/plugins/processing/algs/grass7/ext/r_li_padrange.py
  34. +3 −3 python/plugins/processing/algs/grass7/ext/r_li_padrange_ascii.py
  35. +2 −2 python/plugins/processing/algs/grass7/ext/r_li_padsd.py
  36. +3 −3 python/plugins/processing/algs/grass7/ext/r_li_padsd_ascii.py
  37. +2 −2 python/plugins/processing/algs/grass7/ext/r_li_patchdensity.py
  38. +3 −3 python/plugins/processing/algs/grass7/ext/r_li_patchdensity_ascii.py
  39. +2 −2 python/plugins/processing/algs/grass7/ext/r_li_patchnum.py
  40. +3 −3 python/plugins/processing/algs/grass7/ext/r_li_patchnum_ascii.py
  41. +2 −2 python/plugins/processing/algs/grass7/ext/r_li_pielou.py
  42. +3 −3 python/plugins/processing/algs/grass7/ext/r_li_pielou_ascii.py
  43. +2 −2 python/plugins/processing/algs/grass7/ext/r_li_renyi.py
  44. +4 −4 python/plugins/processing/algs/grass7/ext/r_li_renyi_ascii.py
  45. +2 −2 python/plugins/processing/algs/grass7/ext/r_li_richness.py
  46. +3 −3 python/plugins/processing/algs/grass7/ext/r_li_richness_ascii.py
  47. +2 −2 python/plugins/processing/algs/grass7/ext/r_li_shannon.py
  48. +3 −3 python/plugins/processing/algs/grass7/ext/r_li_shannon_ascii.py
  49. +2 −2 python/plugins/processing/algs/grass7/ext/r_li_shape.py
  50. +3 −3 python/plugins/processing/algs/grass7/ext/r_li_shape_ascii.py
  51. +2 −2 python/plugins/processing/algs/grass7/ext/r_li_simpson.py
  52. +3 −3 python/plugins/processing/algs/grass7/ext/r_li_simpson_ascii.py
  53. +4 −4 python/plugins/processing/algs/grass7/ext/r_mapcalc.py
  54. +3 −3 python/plugins/processing/algs/grass7/ext/r_mask_rast.py
  55. +3 −3 python/plugins/processing/algs/grass7/ext/r_mask_vect.py
  56. +4 −4 python/plugins/processing/algs/grass7/ext/r_null.py
  57. +1 −1 python/plugins/processing/algs/grass7/ext/r_proj.py
  58. +2 −2 python/plugins/processing/algs/grass7/ext/r_reclass.py
  59. +3 −3 python/plugins/processing/algs/grass7/ext/r_rgb.py
  60. +3 −3 python/plugins/processing/algs/grass7/ext/r_series_interp.py
  61. +2 −2 python/plugins/processing/algs/grass7/ext/r_shade.py
  62. +3 −3 python/plugins/processing/algs/grass7/ext/r_statistics.py
  63. +3 −3 python/plugins/processing/algs/grass7/ext/r_stats_quantile_rast.py
  64. +1 −1 python/plugins/processing/algs/grass7/ext/r_what_color.py
  65. +3 −3 python/plugins/processing/algs/grass7/ext/v_distance.py
  66. +3 −3 python/plugins/processing/algs/grass7/ext/v_edit.py
  67. +2 −2 python/plugins/processing/algs/grass7/ext/v_in_geonames.py
  68. +3 −3 python/plugins/processing/algs/grass7/ext/v_net.py
  69. +3 −3 python/plugins/processing/algs/grass7/ext/v_net_alloc.py
  70. +3 −3 python/plugins/processing/algs/grass7/ext/v_net_allpairs.py
  71. +3 −3 python/plugins/processing/algs/grass7/ext/v_net_bridge.py
  72. +3 −3 python/plugins/processing/algs/grass7/ext/v_net_centrality.py
  73. +3 −3 python/plugins/processing/algs/grass7/ext/v_net_components.py
  74. +3 −3 python/plugins/processing/algs/grass7/ext/v_net_connectivity.py
  75. +3 −3 python/plugins/processing/algs/grass7/ext/v_net_distance.py
  76. +3 −3 python/plugins/processing/algs/grass7/ext/v_net_flow.py
  77. +3 −3 python/plugins/processing/algs/grass7/ext/v_net_iso.py
  78. +3 −3 python/plugins/processing/algs/grass7/ext/v_net_path.py
  79. +3 −3 python/plugins/processing/algs/grass7/ext/v_net_salesman.py
  80. +3 −3 python/plugins/processing/algs/grass7/ext/v_net_spanningtree.py
  81. +3 −3 python/plugins/processing/algs/grass7/ext/v_net_steiner.py
  82. +1 −1 python/plugins/processing/algs/grass7/ext/v_net_visibility.py
  83. +2 −2 python/plugins/processing/algs/grass7/ext/v_proj.py
  84. +3 −3 python/plugins/processing/algs/grass7/ext/v_rast_stats.py
  85. +2 −2 python/plugins/processing/algs/grass7/ext/v_rectify.py
  86. +2 −2 python/plugins/processing/algs/grass7/ext/v_sample.py
  87. +2 −2 python/plugins/processing/algs/grass7/ext/v_to_3d.py
  88. +3 −3 python/plugins/processing/algs/grass7/ext/v_vect_stats.py
  89. +4 −4 python/plugins/processing/algs/grass7/ext/v_voronoi.py
  90. +3 −3 python/plugins/processing/algs/grass7/ext/v_what_rast.py
  91. +3 −3 python/plugins/processing/algs/grass7/ext/v_what_vect.py
@@ -365,9 +365,9 @@ def processAlgorithm(self, parameters, context, feedback):
for fName in ['Inputs', 'Command', 'Outputs']:
fullName = 'process{}'.format(fName)
if self.module and hasattr(self.module, fullName):
getattr(self.module, fullName)(self, parameters, context)
getattr(self.module, fullName)(self, parameters, context, feedback)
else:
getattr(self, fullName)(parameters, context)
getattr(self, fullName)(parameters, context, feedback)

# Run GRASS
loglines = []
@@ -398,7 +398,7 @@ def processAlgorithm(self, parameters, context, feedback):

return outputs

def processInputs(self, parameters, context):
def processInputs(self, parameters, context, feedback):
"""Prepare the GRASS import commands"""
inputs = [p for p in self.parameterDefinitions()
if isinstance(p, (QgsProcessingParameterVectorLayer,
@@ -428,7 +428,7 @@ def processInputs(self, parameters, context):
paramName, parameters, context)
else:
self.loadVectorLayerFromParameter(
paramName, parameters, context, None)
paramName, parameters, context, feedback, None)
# For multiple inputs, process each layer
elif isinstance(param, QgsProcessingParameterMultipleLayers):
layers = self.parameterAsLayerList(parameters, paramName, context)
@@ -474,7 +474,7 @@ def postInputs(self):

QgsMessageLog.logMessage(self.tr('processInputs end. Commands: {}').format(self.commands), 'Grass7', Qgis.Info)

def processCommand(self, parameters, context, delOutputs=False):
def processCommand(self, parameters, context, feedback, delOutputs=False):
"""
Prepare the GRASS algorithm command
:param parameters:
@@ -622,7 +622,7 @@ def vectorOutputType(self, parameters, context):
self.outType = ('auto' if typeidx
is None else self.OUTPUT_TYPES[typeidx])

def processOutputs(self, parameters, context):
def processOutputs(self, parameters, context, feedback):
"""Prepare the GRASS v.out.ogr commands"""
# TODO: support multiple raster formats.
# TODO: support multiple vector formats.
@@ -751,7 +751,7 @@ def exportRasterLayersIntoDirectory(self, name, parameters, context, colorTable=
)
cmd.append("done")

def loadVectorLayerFromParameter(self, name, parameters, context, external=False):
def loadVectorLayerFromParameter(self, name, parameters, context, feedback, external=False):
"""
Creates a dedicated command to load a vector into
the temporary GRASS DB.
@@ -32,7 +32,7 @@ def checkParameterValuesBeforeExecuting(alg, parameters, context):
return verifyRasterNum(alg, parameters, context, 'input', 2, 8)


def processCommand(alg, parameters, context):
def processCommand(alg, parameters, context, feedback):
# Regroup rasters
group, subgroup = regroupRasters(alg, parameters, context,
'input', 'group', 'subgroup')
@@ -42,4 +42,4 @@ def processCommand(alg, parameters, context):
parameters['signature'] = shortSigFile

# Handle other parameters
alg.processCommand(parameters, context)
alg.processCommand(parameters, context, feedback)
@@ -33,15 +33,15 @@ def checkParameterValuesBeforeExecuting(alg, parameters, context):
return verifyRasterNum(alg, parameters, context, 'input', 2)


def processCommand(alg, parameters, context):
def processCommand(alg, parameters, context, feedback):
# We need to extract the basename of the signature file
signatureFile = alg.parameterAsString(parameters, 'signaturefile', context)
shortSigFile = os.path.basename(signatureFile)
parameters['signaturefile'] = shortSigFile

# Regroup rasters
group, subgroup = regroupRasters(alg, parameters, context, 'input', 'group', 'subgroup')
alg.processCommand(parameters, context)
alg.processCommand(parameters, context, feedback)

# Re-add signature files
parameters['signaturefile'] = signatureFile
@@ -28,12 +28,12 @@
from .i import exportInputRasters


def processCommand(alg, parameters, context):
def processCommand(alg, parameters, context, feedback):
# Temporary remove outputs:
alg.processCommand(parameters, context, True)
alg.processCommand(parameters, context, feedback, True)


def processOutputs(alg, parameters, context):
def processOutputs(alg, parameters, context, feedback):
# Input rasters are output rasters
rasterDic = {'red': 'redoutput', 'green': 'greenoutput', 'blue': 'blueoutput'}
exportInputRasters(alg, parameters, context, rasterDic)
@@ -29,15 +29,15 @@
from .i import regroupRasters, exportSigFile


def processCommand(alg, parameters, context):
def processCommand(alg, parameters, context, feedback):
# We need to extract the basename of the signature file
signatureFile = alg.parameterAsString(parameters, 'signaturefile', context)
shortSigFile = os.path.basename(signatureFile)
parameters['signaturefile'] = shortSigFile

# Regroup rasters
group, subgroup = regroupRasters(alg, parameters, context, 'input', 'group', 'subgroup')
alg.processCommand(parameters, context)
alg.processCommand(parameters, context, feedback)

# Re-add signature files
parameters['signaturefile'] = signatureFile
@@ -29,15 +29,15 @@
from .i import regroupRasters, exportSigFile


def processCommand(alg, parameters, context):
def processCommand(alg, parameters, context, feedback):
# We need to extract the basename of the signature file
signatureFile = alg.parameterAsString(parameters, 'signaturefile', context)
shortSigFile = os.path.basename(signatureFile)
parameters['signaturefile'] = shortSigFile

# Regroup rasters
group, subgroup = regroupRasters(alg, parameters, context, 'input', 'group', 'subgroup')
alg.processCommand(parameters, context)
alg.processCommand(parameters, context, feedback)

# Re-add signature files
parameters['signaturefile'] = signatureFile
@@ -26,7 +26,7 @@
__revision__ = '$Format:%H$'


def processInputs(alg, parameters, context):
def processInputs(alg, parameters, context, feedback):
# Here, we apply directly the algorithm
# So we just need to get the projection of the layer !
layer = alg.parameterAsRasterLayer(parameters, 'input', context)
@@ -32,10 +32,10 @@ def checkParameterValuesBeforeExecuting(alg, parameters, context):
return verifyRasterNum(alg, parameters, context, 'rasters', 5, 5)


def processInputs(alg, parameters, context):
def processInputs(alg, parameters, context, feedback):
orderedInput(alg, parameters, context, 'rasters', 'input',
[2, 3, 4, 5, 61])


def processCommand(alg, parameters, context):
alg.processCommand(parameters, context)
def processCommand(alg, parameters, context, feedback):
alg.processCommand(parameters, context, feedback)
@@ -32,10 +32,10 @@ def checkParameterValuesBeforeExecuting(alg, parameters, context):
return verifyRasterNum(alg, parameters, context, 'rasters', 5, 12)


def processInputs(alg, parameters, context):
def processInputs(alg, parameters, context, feedback):
orderedInput(alg, parameters, context, 'rasters', 'input',
[1, 2, 3, 4, 5, 61, 62, 7, 8])


def processCommand(alg, parameters, context):
alg.processCommand(parameters, context)
def processCommand(alg, parameters, context, feedback):
alg.processCommand(parameters, context, feedback)
@@ -28,7 +28,7 @@
from .i import regroupRasters, importSigFile


def processCommand(alg, parameters, context):
def processCommand(alg, parameters, context, feedback):
group, subgroup = regroupRasters(alg, parameters, context,
'input', 'group', 'subgroup')

@@ -38,4 +38,4 @@ def processCommand(alg, parameters, context):
parameters['signaturefile'] = shortSigFile

# Handle other parameters
alg.processCommand(parameters, context)
alg.processCommand(parameters, context, feedback)
@@ -31,16 +31,16 @@
from qgis.core import QgsProcessingParameterString


def processCommand(alg, parameters, context):
def processCommand(alg, parameters, context, feedback):
# Temporary remove outputs and add a virtual output parameter
outputName = 'output_{}'.format(os.path.basename(getTempFilename()))
param = QgsProcessingParameterString('output', 'virtual output',
outputName, False, False)
alg.addParameter(param)
alg.processCommand(parameters, context, True)
alg.processCommand(parameters, context, feedback, True)


def processOutputs(alg, parameters, context):
def processOutputs(alg, parameters, context, feedback):
outputName = alg.parameterAsString(parameters, 'output', context)
createOpt = alg.parameterAsString(parameters, alg.GRASS_RASTER_FORMAT_OPT, context)
metaOpt = alg.parameterAsString(parameters, alg.GRASS_RASTER_FORMAT_META, context)
@@ -28,7 +28,7 @@
from .i import regroupRasters


def processCommand(alg, parameters, context):
def processCommand(alg, parameters, context, feedback):
# Regroup rasters
regroupRasters(alg, parameters, context, 'input', 'group')
alg.processCommand(parameters, context)
alg.processCommand(parameters, context, feedback)
@@ -28,7 +28,7 @@
from .i import regroupRasters, importSigFile


def processCommand(alg, parameters, context):
def processCommand(alg, parameters, context, feedback):
# Regroup rasters
group, subgroup = regroupRasters(alg, parameters, context, 'input', 'group', 'subgroup')

@@ -38,4 +38,4 @@ def processCommand(alg, parameters, context):
parameters['signaturefile'] = shortSigFile

# Handle other parameters
alg.processCommand(parameters, context)
alg.processCommand(parameters, context, feedback)
@@ -26,7 +26,7 @@
__revision__ = '$Format:%H$'


def processInputs(alg, parameters, context):
def processInputs(alg, parameters, context, feedback):
if 'first' and 'second' in alg.exportedLayers:
return

@@ -36,6 +36,6 @@ def processInputs(alg, parameters, context):
alg.postInputs()


def processOutputs(alg, parameters, context):
def processOutputs(alg, parameters, context, feedback):
# Keep color table
alg.exportRasterLayerFromParameter('output', parameters, context)
@@ -30,7 +30,7 @@
from processing.algs.grass7.Grass7Utils import Grass7Utils


def processInputs(alg, parameters, context):
def processInputs(alg, parameters, context, feedback):
if 'first' and 'second' in alg.exportedLayers:
return

@@ -40,12 +40,12 @@ def processInputs(alg, parameters, context):
alg.postInputs()


def processCommand(alg, parameters, context):
def processCommand(alg, parameters, context, feedback):
# We need to remove all outputs
alg.processCommand(parameters, context, True)
alg.processCommand(parameters, context, feedback, True)


def processOutputs(alg, parameters, context):
def processOutputs(alg, parameters, context, feedback):
createOpt = alg.parameterAsString(parameters, alg.GRASS_RASTER_FORMAT_OPT, context)
metaOpt = alg.parameterAsString(parameters, alg.GRASS_RASTER_FORMAT_META, context)

@@ -43,7 +43,7 @@ def checkParameterValuesBeforeExecuting(alg, parameters, context):
return None


def processInputs(alg, parameters, context):
def processInputs(alg, parameters, context, feedback):
# If there is another raster to copy categories from
# we need to import it with r.in.gdal rather than r.external
raster = alg.parameterAsString(parameters, 'raster', context)
@@ -55,7 +55,7 @@ def processInputs(alg, parameters, context):
alg.postInputs()


def processCommand(alg, parameters, context):
def processCommand(alg, parameters, context, feedback):
# Handle inline rules
txtRules = alg.parameterAsString(parameters, 'txtrules', context)
if txtRules:
@@ -68,10 +68,10 @@ def processCommand(alg, parameters, context):
alg.removeParameter('txtrules')
parameters['rules'] = tempRulesName

alg.processCommand(parameters, context, True)
alg.processCommand(parameters, context, feedback, True)


def processOutputs(alg, parameters, context):
def processOutputs(alg, parameters, context, feedback):
# Output results ('map' layer)
createOpt = alg.parameterAsString(parameters, alg.GRASS_RASTER_FORMAT_OPT, context)
metaOpt = alg.parameterAsString(parameters, alg.GRASS_RASTER_FORMAT_META, context)
@@ -39,7 +39,7 @@ def checkParameterValuesBeforeExecuting(alg, parameters, context):
return None


def processInputs(alg, parameters, context):
def processInputs(alg, parameters, context, feedback):
# import all rasters with their color tables (and their bands)
# We need to import all the bands and color tables of the input rasters
rasters = alg.parameterAsLayerList(parameters, 'map', context)
@@ -56,7 +56,7 @@ def processInputs(alg, parameters, context):
alg.postInputs()


def processCommand(alg, parameters, context):
def processCommand(alg, parameters, context, feedback):
# Handle inline rules
txtRules = alg.parameterAsString(parameters, 'txtrules', context)
if txtRules:
@@ -69,10 +69,10 @@ def processCommand(alg, parameters, context):
alg.removeParameter('txtrules')
parameters['rules'] = tempRulesName

alg.processCommand(parameters, context, True)
alg.processCommand(parameters, context, feedback, True)


def processOutputs(alg, parameters, context):
def processOutputs(alg, parameters, context, feedback):
createOpt = alg.parameterAsString(parameters, alg.GRASS_RASTER_FORMAT_OPT, context)
metaOpt = alg.parameterAsString(parameters, alg.GRASS_RASTER_FORMAT_META, context)

@@ -28,7 +28,7 @@
from processing.algs.grass7.Grass7Utils import Grass7Utils


def processInputs(alg, parameters, context):
def processInputs(alg, parameters, context, feedback):
# We need to import all the bands and to preserve color table
if 'map' in alg.exportedLayers:
return
@@ -38,12 +38,12 @@ def processInputs(alg, parameters, context):
alg.postInputs()


def processCommand(alg, parameters, context):
def processCommand(alg, parameters, context, feedback):
# We need to remove output
alg.processCommand(parameters, context, True)
alg.processCommand(parameters, context, feedback, True)


def processOutputs(alg, parameters, context):
def processOutputs(alg, parameters, context, feedback):
createOpt = alg.parameterAsString(parameters, alg.GRASS_RASTER_FORMAT_OPT, context)
metaOpt = alg.parameterAsString(parameters, alg.GRASS_RASTER_FORMAT_META, context)

@@ -40,7 +40,7 @@ def checkParameterValuesBeforeExecuting(alg, parameters, context):
return None


def processOutputs(alg, parameters, context):
def processOutputs(alg, parameters, context, feedback):
# There will be as many outputs as the difference between start and end divided by steps
start = alg.parameterAsDouble(parameters, 'start', context)
end = alg.parameterAsDouble(parameters, 'end', context)
@@ -84,7 +84,7 @@ def checkMovingWindow(alg, parameters, context, outputTxt=False):
return None


def configFile(alg, parameters, context, outputTxt=False):
def configFile(alg, parameters, context, feedback, outputTxt=False):
"""Handle inline configuration
:param parameters:
"""
@@ -125,7 +125,7 @@ def configFile(alg, parameters, context, outputTxt=False):
False, False)
alg.addParameter(param)

alg.processCommand(parameters, context, outputTxt)
alg.processCommand(parameters, context, feedback, outputTxt)

# Remove Config file:
removeConfigFile(alg, parameters, context)

0 comments on commit c50a039

Please sign in to comment.
You can’t perform that action at this time.