Skip to content
Permalink
Browse files

Rename method to more generic name - it's usable by vector layer outp…

…uts too
  • Loading branch information
nyalldawson committed Jul 8, 2017
1 parent d443bb3 commit febf0a0e6e5b23d1ac9af58542d0469a7da00aa0
@@ -559,9 +559,9 @@ class QgsProcessingAlgorithm
:rtype: QgsRasterLayer
%End

QString parameterAsRasterOutputLayer( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context ) const;
QString parameterAsOutputLayer( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context ) const;
%Docstring
Evaluates the parameter with matching ``name`` to a raster output layer destination.
Evaluates the parameter with matching ``name`` to a output layer destination.
:rtype: str
%End

@@ -508,9 +508,9 @@ class QgsProcessingParameters
:rtype: QgsRasterLayer
%End

static QString parameterAsRasterOutputLayer( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
static QString parameterAsOutputLayer( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
%Docstring
Evaluates the parameter with matching ``definition`` to a raster output layer destination.
Evaluates the parameter with matching ``definition`` to a output layer destination.
:rtype: str
%End

@@ -78,7 +78,7 @@ def processAlgorithm(self, parameters, context, feedback):
inputFile = exportRasterLayer(self.parameterAsRasterLayer(parameters, self.INPUT, context))
zFactor = self.parameterAsDouble(parameters, self.Z_FACTOR, context)

outputFile = self.parameterAsRasterOutputLayer(parameters, self.OUTPUT, context)
outputFile = self.parameterAsOutputLayer(parameters, self.OUTPUT, context)

outputFormat = raster.formatShortNameFromFileName(outputFile)

@@ -518,9 +518,9 @@ QgsRasterLayer *QgsProcessingAlgorithm::parameterAsRasterLayer( const QVariantMa
return QgsProcessingParameters::parameterAsRasterLayer( parameterDefinition( name ), parameters, context );
}

QString QgsProcessingAlgorithm::parameterAsRasterOutputLayer( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context ) const
QString QgsProcessingAlgorithm::parameterAsOutputLayer( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context ) const
{
return QgsProcessingParameters::parameterAsRasterOutputLayer( parameterDefinition( name ), parameters, context );
return QgsProcessingParameters::parameterAsOutputLayer( parameterDefinition( name ), parameters, context );
}

QString QgsProcessingAlgorithm::parameterAsFileOutput( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context ) const
@@ -529,9 +529,9 @@ class CORE_EXPORT QgsProcessingAlgorithm
QgsRasterLayer *parameterAsRasterLayer( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context ) const;

/**
* Evaluates the parameter with matching \a name to a raster output layer destination.
* Evaluates the parameter with matching \a name to a output layer destination.
*/
QString parameterAsRasterOutputLayer( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context ) const;
QString parameterAsOutputLayer( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context ) const;

/**
* Evaluates the parameter with matching \a name to a file based output destination.
@@ -413,7 +413,7 @@ QgsRasterLayer *QgsProcessingParameters::parameterAsRasterLayer( const QgsProces
return qobject_cast< QgsRasterLayer *>( parameterAsLayer( definition, parameters, context ) );
}

QString QgsProcessingParameters::parameterAsRasterOutputLayer( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context )
QString QgsProcessingParameters::parameterAsOutputLayer( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context )
{
QVariant val;
if ( definition )
@@ -543,9 +543,9 @@ class CORE_EXPORT QgsProcessingParameters
static QgsRasterLayer *parameterAsRasterLayer( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );

/**
* Evaluates the parameter with matching \a definition to a raster output layer destination.
* Evaluates the parameter with matching \a definition to a output layer destination.
*/
static QString parameterAsRasterOutputLayer( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
static QString parameterAsOutputLayer( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );

/**
* Evaluates the parameter with matching \a definition to a file based output destination.
@@ -3696,9 +3696,9 @@ void TestQgsProcessing::parameterRasterOut()

QVariantMap params;
params.insert( "non_optional", "test.tif" );
QCOMPARE( QgsProcessingParameters::parameterAsRasterOutputLayer( def.get(), params, context ), QStringLiteral( "test.tif" ) );
QCOMPARE( QgsProcessingParameters::parameterAsOutputLayer( def.get(), params, context ), QStringLiteral( "test.tif" ) );
params.insert( "non_optional", QgsProcessingOutputLayerDefinition( "test.tif" ) );
QCOMPARE( QgsProcessingParameters::parameterAsRasterOutputLayer( def.get(), params, context ), QStringLiteral( "test.tif" ) );
QCOMPARE( QgsProcessingParameters::parameterAsOutputLayer( def.get(), params, context ), QStringLiteral( "test.tif" ) );

QCOMPARE( def->valueAsPythonString( QStringLiteral( "abc" ), context ), QStringLiteral( "'abc'" ) );
QCOMPARE( def->valueAsPythonString( QVariant::fromValue( QgsProcessingOutputLayerDefinition( "abc" ) ), context ), QStringLiteral( "QgsProcessingOutputLayerDefinition('abc')" ) );
@@ -3738,7 +3738,7 @@ void TestQgsProcessing::parameterRasterOut()
QVERIFY( def->checkValueIsAcceptable( QgsProcessingOutputLayerDefinition( "layer1231123" ) ) );

params.insert( "optional", QVariant() );
QCOMPARE( QgsProcessingParameters::parameterAsRasterOutputLayer( def.get(), params, context ), QStringLiteral( "default.tif" ) );
QCOMPARE( QgsProcessingParameters::parameterAsOutputLayer( def.get(), params, context ), QStringLiteral( "default.tif" ) );

code = def->asScriptCode();
QCOMPARE( code, QStringLiteral( "##optional=optional rasterOut default.tif" ) );

0 comments on commit febf0a0

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