31 nuller->mNoData = mNoData;
32 nuller->mOutputNoData = mOutputNoData;
33 nuller->mHasOutputNoData = mHasOutputNoData;
39 if ( bandNo > mOutputNoData.size() )
41 mOutputNoData.resize( bandNo );
42 mHasOutputNoData.resize( bandNo );
44 mOutputNoData[bandNo - 1] =
noData;
45 mHasOutputNoData[bandNo - 1] =
true;
50 if ( bandNo > mNoData.size() )
52 mNoData.resize( bandNo );
54 mNoData[bandNo - 1] =
noData;
77 std::unique_ptr< QgsRasterBlock > inputBlock(
mInput->block( bandNo,
extent, width, height, feedback ) );
86 return inputBlock.release();
89 auto outputBlock = std::make_unique<QgsRasterBlock>( inputBlock->dataType(), width, height );
90 if ( mHasOutputNoData.value( bandNo - 1 ) || inputBlock->hasNoDataValue() )
93 if ( mHasOutputNoData.value( bandNo - 1 ) )
95 noDataValue = mOutputNoData.value( bandNo - 1 );
99 noDataValue = inputBlock->noDataValue();
101 outputBlock->setNoDataValue( noDataValue );
104 bool isNoData =
false;
105 for (
int i = 0; i < height; i++ )
107 for (
int j = 0; j < width; j++ )
109 const double value = inputBlock->valueAndNoData( i, j, isNoData );
117 outputBlock->setIsNoData( i, j );
121 outputBlock->setValue( i, j, value );
125 return outputBlock.release();
DataType
Raster data types.
@ UnknownDataType
Unknown or unspecified type.
Feedback object tailored for raster block reading.
static bool typeIsColor(Qgis::DataType type)
Returns true if a data type is a color type.
QgsRasterInterface(QgsRasterInterface *input=nullptr)
QgsRasterInterface * mInput
virtual QgsRectangle extent() const
Gets the extent of the interface.
virtual QgsRasterInterface * input() const
Current input.
QgsRasterNuller * clone() const override
Clone itself, create deep copy.
void setNoData(int bandNo, const QgsRasterRangeList &noData)
Qgis::DataType dataType(int bandNo) const override
Returns data type for the band specified by number.
QgsRasterBlock * block(int bandNo, const QgsRectangle &extent, int width, int height, QgsRasterBlockFeedback *feedback=nullptr) override
Read block of data using given extent and size.
void setOutputNoDataValue(int bandNo, double noData)
Sets the output no data value.
QgsRasterNuller(QgsRasterInterface *input=nullptr)
int bandCount() const override
Gets number of bands.
QgsRasterRangeList noData(int bandNo) const
bool contains(double value) const
Returns true if this range contains the specified value.
A rectangle specified with double values.
#define QgsDebugMsgLevel(str, level)
QList< QgsRasterRange > QgsRasterRangeList