23 , mMaximumTileWidth( DEFAULT_MAXIMUM_TILE_WIDTH )
24 , mMaximumTileHeight( DEFAULT_MAXIMUM_TILE_HEIGHT )
49 removePartInfo( bandNumber );
57 mRasterPartInfos.insert( bandNumber, pInfo );
61 int &nCols,
int &nRows,
63 int &topLeftCol,
int &topLeftRow )
66 std::unique_ptr< QgsRasterBlock > nextBlock;
67 bool result =
readNextRasterPart( bandNumber, nCols, nRows, nextBlock, topLeftCol, topLeftRow );
69 *block = nextBlock.release();
78 QMap<int, RasterPartInfo>::iterator partIt = mRasterPartInfos.find( bandNumber );
79 if ( partIt == mRasterPartInfos.end() )
84 RasterPartInfo &pInfo = partIt.value();
87 if ( 0 == pInfo.nCols || 0 == pInfo.nRows )
95 if ( pInfo.currentCol == pInfo.nCols && pInfo.currentRow == pInfo.nRows )
101 nCols = std::min( mMaximumTileWidth, pInfo.nCols - pInfo.currentCol );
102 nRows = std::min( mMaximumTileHeight, pInfo.nRows - pInfo.currentRow );
103 QgsDebugMsgLevel( QStringLiteral(
"nCols = %1 nRows = %2" ).arg( nCols ).arg( nRows ), 4 );
107 double xmin = viewPortExtent.
xMinimum() + pInfo.currentCol /
static_cast< double >( pInfo.nCols ) * viewPortExtent.
width();
108 double xmax = pInfo.currentCol + nCols == pInfo.nCols ? viewPortExtent.
xMaximum() :
109 viewPortExtent.
xMinimum() + ( pInfo.currentCol + nCols ) / static_cast< double >( pInfo.nCols ) * viewPortExtent.
width();
110 double ymin = pInfo.currentRow + nRows == pInfo.nRows ? viewPortExtent.
yMinimum() :
111 viewPortExtent.
yMaximum() - ( pInfo.currentRow + nRows ) / static_cast< double >( pInfo.nRows ) * viewPortExtent.
height();
112 double ymax = viewPortExtent.
yMaximum() - pInfo.currentRow /
static_cast< double >( pInfo.nRows ) * viewPortExtent.
height();
116 *blockExtent = blockRect;
118 block.reset( mInput->
block( bandNumber, blockRect, nCols, nRows, mFeedback ) );
119 topLeftCol = pInfo.currentCol;
120 topLeftRow = pInfo.currentRow;
122 pInfo.currentCol += nCols;
123 if ( pInfo.currentCol == pInfo.nCols && pInfo.currentRow + nRows == pInfo.nRows )
125 pInfo.currentRow = pInfo.nRows;
127 else if ( pInfo.currentCol == pInfo.nCols )
129 pInfo.currentCol = 0;
130 pInfo.currentRow += nRows;
138 removePartInfo( bandNumber );
141 void QgsRasterIterator::removePartInfo(
int bandNumber )
143 auto partIt = mRasterPartInfos.constFind( bandNumber );
144 if ( partIt != mRasterPartInfos.constEnd() )
146 mRasterPartInfos.remove( bandNumber );
A rectangle specified with double values.
double yMaximum() const
Returns the y maximum value (top side of rectangle).
QgsRasterIterator(QgsRasterInterface *input)
Constructor for QgsRasterIterator, iterating over the specified input raster source.
virtual QgsRasterInterface * input() const
Current input.
virtual int stepWidth() const
Step width for raster iterations.
double yMinimum() const
Returns the y minimum value (bottom side of rectangle).
double xMaximum() const
Returns the x maximum value (right side of rectangle).
#define QgsDebugMsgLevel(str, level)
virtual QgsRasterBlock * block(int bandNo, const QgsRectangle &extent, int width, int height, QgsRasterBlockFeedback *feedback=nullptr)=0
Read block of data using given extent and size.
bool readNextRasterPart(int bandNumber, int &nCols, int &nRows, QgsRasterBlock **block, int &topLeftCol, int &topLeftRow)
Fetches next part of raster data, caller takes ownership of the block and caller should delete the bl...
Base class for processing filters like renderers, reprojector, resampler etc.
void stopRasterRead(int bandNumber)
Cancels the raster iteration and resets the iterator.
virtual int stepHeight() const
Step height for raster iterations.
double width() const
Returns the width of the rectangle.
Feedback object tailored for raster block reading.
double xMinimum() const
Returns the x minimum value (left side of rectangle).
void startRasterRead(int bandNumber, int nCols, int nRows, const QgsRectangle &extent, QgsRasterBlockFeedback *feedback=nullptr)
Start reading of raster band.
double height() const
Returns the height of the rectangle.
Base class for raster data providers.