add support for raster creation options to QgsNineCellFilter

This commit is contained in:
Alexander Bruy 2025-03-27 16:44:48 +00:00 committed by Nyall Dawson
parent a9fc31921e
commit 0fbaca4ce1
4 changed files with 54 additions and 2 deletions

View File

@ -58,6 +58,24 @@ mOutputFile
double outputNodataValue() const;
void setOutputNodataValue( double value );
void setCreateOptions( const QStringList &list );
%Docstring
Sets a list of data source creation options to use when creating the output raster file.
.. seealso:: :py:func:`createOptions`
.. versionadded:: 3.44
%End
QStringList createOptions() const;
%Docstring
Returns the list of data source creation options which will be used when creating the output raster file.
.. seealso:: :py:func:`setCreateOptions`
.. versionadded:: 3.44
%End
virtual float processNineCellWindow( float *x11, float *x21, float *x31, float *x12, float *x22, float *x32, float *x13, float *x23, float *x33 ) = 0;
%Docstring
Calculates output value from nine input values. The input values and the

View File

@ -58,6 +58,24 @@ mOutputFile
double outputNodataValue() const;
void setOutputNodataValue( double value );
void setCreateOptions( const QStringList &list );
%Docstring
Sets a list of data source creation options to use when creating the output raster file.
.. seealso:: :py:func:`createOptions`
.. versionadded:: 3.44
%End
QStringList createOptions() const;
%Docstring
Returns the list of data source creation options which will be used when creating the output raster file.
.. seealso:: :py:func:`setCreateOptions`
.. versionadded:: 3.44
%End
virtual float processNineCellWindow( float *x11, float *x21, float *x31, float *x12, float *x22, float *x32, float *x13, float *x23, float *x33 ) = 0;
%Docstring
Calculates output value from nine input values. The input values and the

View File

@ -33,7 +33,6 @@
#include <QFileInfo>
#include <iterator>
QgsNineCellFilter::QgsNineCellFilter( const QString &inputFile, const QString &outputFile, const QString &outputFormat )
: mInputFile( inputFile )
, mOutputFile( outputFile )
@ -129,7 +128,7 @@ gdal::dataset_unique_ptr QgsNineCellFilter::openOutputFile( GDALDatasetH inputDa
const int ySize = GDALGetRasterYSize( inputDataset );
//open output file
char **papszOptions = nullptr;
char **papszOptions = QgsGdalUtils::papszFromStringList( mCreateOptions );
gdal::dataset_unique_ptr outputDataset( GDALCreate( outputDriver, mOutputFile.toUtf8().constData(), xSize, ySize, 1, GDT_Float32, papszOptions ) );
if ( !outputDataset )
{

View File

@ -61,6 +61,22 @@ class ANALYSIS_EXPORT QgsNineCellFilter
double outputNodataValue() const { return mOutputNodataValue; }
void setOutputNodataValue( double value ) { mOutputNodataValue = value; }
/**
* Sets a list of data source creation options to use when creating the output raster file.
*
* \see createOptions()
* \since QGIS 3.44
*/
void setCreateOptions( const QStringList &list ) { mCreateOptions = list; }
/**
* Returns the list of data source creation options which will be used when creating the output raster file.
*
* \see setCreateOptions()
* \since QGIS 3.44
*/
QStringList createOptions() const { return mCreateOptions; }
/**
* Calculates output value from nine input values. The input values and the output
* value can be equal to the nodata value if not present or outside of the border.
@ -138,6 +154,7 @@ class ANALYSIS_EXPORT QgsNineCellFilter
QString mInputFile;
QString mOutputFile;
QString mOutputFormat;
QStringList mCreateOptions;
double mCellSizeX = -1.0;
double mCellSizeY = -1.0;