mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
[processing][API]introduce QgsProcessingOutputFile output and fix gdal2xyz test
This commit is contained in:
parent
79c26c384d
commit
2104b273af
@ -39,6 +39,8 @@ class QgsProcessingOutputDefinition
|
||||
sipType = sipType_QgsProcessingOutputString;
|
||||
else if ( sipCpp->type() == QgsProcessingOutputFolder::typeName() )
|
||||
sipType = sipType_QgsProcessingOutputFolder;
|
||||
else if ( sipCpp->type() == QgsProcessingOutputFile::typeName() )
|
||||
sipType = sipType_QgsProcessingOutputFile;
|
||||
else
|
||||
sipType = nullptr;
|
||||
%End
|
||||
@ -265,6 +267,33 @@ class QgsProcessingOutputFolder : QgsProcessingOutputDefinition
|
||||
|
||||
};
|
||||
|
||||
class QgsProcessingOutputFile : QgsProcessingOutputDefinition
|
||||
{
|
||||
%Docstring
|
||||
A file output for processing algorithms.
|
||||
.. versionadded:: 3.0
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "qgsprocessingoutputs.h"
|
||||
%End
|
||||
public:
|
||||
|
||||
QgsProcessingOutputFile( const QString &name, const QString &description = QString() );
|
||||
%Docstring
|
||||
Constructor for QgsProcessingOutputFile.
|
||||
%End
|
||||
|
||||
static QString typeName();
|
||||
%Docstring
|
||||
Returns the type name for the output class.
|
||||
:rtype: str
|
||||
%End
|
||||
virtual QString type() const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/************************************************************************
|
||||
|
@ -29,7 +29,8 @@ from qgis.core import (QgsProcessing,
|
||||
QgsProcessingParameterRasterLayer,
|
||||
QgsProcessingParameterBand,
|
||||
QgsProcessingParameterBoolean,
|
||||
QgsProcessingParameterFileDestination)
|
||||
QgsProcessingParameterFileDestination,
|
||||
QgsProcessingOutputFile)
|
||||
from processing.algs.gdal.GdalAlgorithm import GdalAlgorithm
|
||||
from processing.algs.gdal.GdalUtils import GdalUtils
|
||||
from processing.tools.system import isWindows
|
||||
@ -57,6 +58,7 @@ class gdal2xyz(GdalAlgorithm):
|
||||
self.addParameter(QgsProcessingParameterFileDestination(self.OUTPUT,
|
||||
self.tr('XYZ ASCII file'),
|
||||
self.tr('CSV files (*.csv)')))
|
||||
self.addOutput(QgsProcessingOutputFile(self.OUTPUT, self.tr('XYZ ASCII file')))
|
||||
|
||||
def name(self):
|
||||
return 'gdal2xyz'
|
||||
|
@ -123,18 +123,18 @@ tests:
|
||||
- 'Band 1 Block=373x5 Type=Float32, ColorInterp=Gray'
|
||||
- ' NoData Value=-99999'
|
||||
|
||||
# - algorithm: gdal:gdal2xyz
|
||||
# name: gdal2xyz
|
||||
# params:
|
||||
# BAND: 1
|
||||
# CSV: false
|
||||
# INPUT:
|
||||
# name: dem.tif
|
||||
# type: raster
|
||||
# results:
|
||||
# OUTPUT:
|
||||
# name: expected/gdal/xyz.csv
|
||||
# type: file
|
||||
- algorithm: gdal:gdal2xyz
|
||||
name: gdal2xyz
|
||||
params:
|
||||
BAND: 1
|
||||
CSV: false
|
||||
INPUT:
|
||||
name: dem.tif
|
||||
type: raster
|
||||
results:
|
||||
OUTPUT:
|
||||
name: expected/gdal/xyz.csv
|
||||
type: file
|
||||
|
||||
- algorithm: gdal:tileindex
|
||||
name: Tile index (gdaltindex)
|
||||
|
@ -57,5 +57,8 @@ QgsProcessingOutputString::QgsProcessingOutputString( const QString &name, const
|
||||
|
||||
QgsProcessingOutputFolder::QgsProcessingOutputFolder( const QString &name, const QString &description )
|
||||
: QgsProcessingOutputDefinition( name, description )
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
QgsProcessingOutputFile::QgsProcessingOutputFile( const QString &name, const QString &description )
|
||||
: QgsProcessingOutputDefinition( name, description )
|
||||
{}
|
||||
|
@ -55,6 +55,8 @@ class CORE_EXPORT QgsProcessingOutputDefinition
|
||||
sipType = sipType_QgsProcessingOutputString;
|
||||
else if ( sipCpp->type() == QgsProcessingOutputFolder::typeName() )
|
||||
sipType = sipType_QgsProcessingOutputFolder;
|
||||
else if ( sipCpp->type() == QgsProcessingOutputFile::typeName() )
|
||||
sipType = sipType_QgsProcessingOutputFile;
|
||||
else
|
||||
sipType = nullptr;
|
||||
SIP_END
|
||||
@ -269,6 +271,30 @@ class CORE_EXPORT QgsProcessingOutputFolder : public QgsProcessingOutputDefiniti
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* \class QgsProcessingOutputFile
|
||||
* \ingroup core
|
||||
* A file output for processing algorithms.
|
||||
* \since QGIS 3.0
|
||||
*/
|
||||
class CORE_EXPORT QgsProcessingOutputFile : public QgsProcessingOutputDefinition
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor for QgsProcessingOutputFile.
|
||||
*/
|
||||
QgsProcessingOutputFile( const QString &name, const QString &description = QString() );
|
||||
|
||||
/**
|
||||
* Returns the type name for the output class.
|
||||
*/
|
||||
static QString typeName() { return QStringLiteral( "outputFile" ); }
|
||||
QString type() const override { return typeName(); }
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // QGSPROCESSINGOUTPUTS_H
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user