Skip to content
Permalink
Browse files

Improve input detection and add new algorithms

  • Loading branch information
Médéric RIBREUX
Médéric RIBREUX committed Nov 5, 2017
1 parent d10aaf4 commit da9047712190af99ea75dd5a68d7b37c8f1735d8
@@ -194,6 +194,7 @@ def defineCharacteristicsFromFile(self):
line = lines.readline().strip('\n').strip()
self._group = QCoreApplication.translate("GrassAlgorithm", line)
hasRasterOutput = False
hasRasterInput = False
hasVectorInput = False
vectorOutputs = False
# Then you have parameters/output definition
@@ -208,9 +209,13 @@ def defineCharacteristicsFromFile(self):
self.params.append(parameter)
if isinstance(parameter, QgsProcessingParameterVectorLayer):
hasVectorInput = True
elif isinstance(parameter, QgsProcessingParameterMultipleLayers) \
and parameter.layerType() < 3:
hasVectorInput = True
elif isinstance(parameter, QgsProcessingParameterRasterLayer):
hasRasterInput = True
elif isinstance(parameter, QgsProcessingParameterMultipleLayers):
if parameter.layerType() < 3 or parameter.layerType() == 5:
hasVectorInput = True
elif parameter.layerType() == 3:
hasRasterInput = True
elif isinstance(parameter, QgsProcessingParameterVectorDestination):
vectorOutputs = True
elif isinstance(parameter, QgsProcessingParameterRasterDestination):
@@ -228,7 +233,7 @@ def defineCharacteristicsFromFile(self):
param.setFlags(param.flags() | QgsProcessingParameterDefinition.FlagAdvanced)
self.params.append(param)

if hasRasterOutput:
if hasRasterOutput or hasRasterInput:
# Add a cellsize parameter
param = QgsProcessingParameterNumber(
self.GRASS_REGION_CELLSIZE_PARAMETER,
@@ -239,6 +244,7 @@ def defineCharacteristicsFromFile(self):
param.setFlags(param.flags() | QgsProcessingParameterDefinition.FlagAdvanced)
self.params.append(param)

if hasRasterOutput:
# Add a createopt parameter for format export
param = QgsProcessingParameterString(
self.GRASS_RASTER_FORMAT_OPT,
@@ -0,0 +1,11 @@
r.out.ascii
Export a raster layer into a GRASS ASCII text file
Raster (r.*)
QgsProcessingParameterRasterLayer|input|Input raster|None|False
QgsProcessingParameterNumber|precision|Number of significant digits|QgsProcessingParameterNumber.Integer|2|False|0|None
QgsProcessingParameterNumber|width|Number of values printed before wrapping a line (only SURFER or MODFLOW format)|QgsProcessingParameterNumber.Integer|None|False|0|None
QgsProcessingParameterString|null_value|String to represent null cell (GRASS grid only)|*|False|True
*QgsProcessingParameterBoolean|-s|Write SURFER (Golden Software) ASCII grid|False|True
*QgsProcessingParameterBoolean|-m|Write MODFLOW (USGS) ASCII array|False|True
*QgsProcessingParameterBoolean|-i|Force output of integer values|False|True
QgsProcessingParameterFileDestination|output|GRASS Ascii|Txt files (*.txt)|None|False
@@ -1,9 +1,9 @@
r.out.mpeg
Converts raster map series to MPEG movie
Raster (r.*)
QgsProcessingParameterMultipleLayers|view1|Name of input raster map(s) for view no.1|5|None|False
QgsProcessingParameterMultipleLayers|view2|Name of input raster map(s) for view no.2|5|None|True
QgsProcessingParameterMultipleLayers|view3|Name of input raster map(s) for view no.3|5|None|True
QgsProcessingParameterMultipleLayers|view4|Name of input raster map(s) for view no.4|5|None|True
QgsProcessingParameterMultipleLayers|view1|Name of input raster map(s) for view no.1|3|None|False
QgsProcessingParameterMultipleLayers|view2|Name of input raster map(s) for view no.2|3|None|True
QgsProcessingParameterMultipleLayers|view3|Name of input raster map(s) for view no.3|3|None|True
QgsProcessingParameterMultipleLayers|view4|Name of input raster map(s) for view no.4|3|None|True
QgsProcessingParameterNumber|quality|Quality factor (1 = highest quality, lowest compression)|QgsProcessingParameterNumber.Integer|3|True|1|5
QgsProcessingParameterFileDestination|output|MPEG file|MPEG files (*.mpeg;*.mpg)|None|False
@@ -0,0 +1,8 @@
r.out.png
Export a GRASS raster map as a non-georeferenced PNG image
Raster (r.*)
QgsProcessingParameterRasterLayer|input|Input raster|None|False
QgsProcessingParameterNumber|compression|Compression level of PNG file (0 = none, 1 = fastest, 9 = best)|QgsProcessingParameterNumber.Integer|6|True|0|9
*QgsProcessingParameterBoolean|-t|Make NULL cells transparent|False|True
*QgsProcessingParameterBoolean|-w|Output world file|False|True
QgsProcessingParameterFileDestination|output|PNG File|PNG files (*.png)|None|False
@@ -0,0 +1,7 @@
r.out.xyz
Exports a raster map to a text file as x,y,z values based on cell centers
Raster (r.*)
QgsProcessingParameterMultipleLayers|input|Input raster(s)|3|None|False
QgsProcessingParameterString|separator|Field separator|pipe|False|True
*QgsProcessingParameterBoolean|-i|Include no data values|False|True
QgsProcessingParameterFileDestination|output|XYZ File|XYZ files (*.xyz *.txt)|None|False

0 comments on commit da90477

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