Skip to content

Commit

Permalink
Rename method to more generic name - it's usable by vector layer outp…
Browse files Browse the repository at this point in the history
…uts too
  • Loading branch information
nyalldawson committed Jul 8, 2017
1 parent d443bb3 commit febf0a0
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions python/core/processing/qgsprocessingalgorithm.sip
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions python/core/processing/qgsprocessingparameters.sip
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/qgis/Aspect.py
Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions src/core/processing/qgsprocessingalgorithm.cpp
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/core/processing/qgsprocessingalgorithm.h
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/core/processing/qgsprocessingparameters.cpp
Expand Up @@ -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 )
Expand Down
4 changes: 2 additions & 2 deletions src/core/processing/qgsprocessingparameters.h
Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions tests/src/core/testqgsprocessing.cpp
Expand Up @@ -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')" ) );
Expand Down Expand Up @@ -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" ) );
Expand Down

0 comments on commit febf0a0

Please sign in to comment.