23 , mMaximumTileWidth( DEFAULT_MAXIMUM_TILE_WIDTH )
24 , mMaximumTileHeight( DEFAULT_MAXIMUM_TILE_HEIGHT )
49 removePartInfo( bandNumber );
57 mRasterPartInfos.insert( bandNumber, pInfo );
62 return readNextRasterPartInternal( bandNumber, columns, rows,
nullptr, topLeftColumn, topLeftRow, &blockExtent );
66 int &nCols,
int &nRows,
68 int &topLeftCol,
int &topLeftRow )
71 std::unique_ptr< QgsRasterBlock > nextBlock;
72 bool result =
readNextRasterPart( bandNumber, nCols, nRows, nextBlock, topLeftCol, topLeftRow );
74 *block = nextBlock.release();
80 return readNextRasterPartInternal( bandNumber, nCols, nRows, &block, topLeftCol, topLeftRow, blockExtent );
83 bool QgsRasterIterator::readNextRasterPartInternal(
int bandNumber,
int &nCols,
int &nRows, std::unique_ptr<QgsRasterBlock> *block,
int &topLeftCol,
int &topLeftRow,
QgsRectangle *blockExtent )
89 QMap<int, RasterPartInfo>::iterator partIt = mRasterPartInfos.find( bandNumber );
90 if ( partIt == mRasterPartInfos.end() )
95 RasterPartInfo &pInfo = partIt.value();
98 if ( 0 == pInfo.nCols || 0 == pInfo.nRows )
106 if ( pInfo.currentCol == pInfo.nCols && pInfo.currentRow == pInfo.nRows )
112 nCols =
static_cast< int >( std::min(
static_cast< qgssize >( mMaximumTileWidth ), pInfo.nCols - pInfo.currentCol ) );
113 nRows =
static_cast< int >( std::min(
static_cast< qgssize >( mMaximumTileHeight ), pInfo.nRows - pInfo.currentRow ) );
114 QgsDebugMsgLevel( QStringLiteral(
"nCols = %1 nRows = %2" ).arg( nCols ).arg( nRows ), 4 );
118 double xmin = viewPortExtent.
xMinimum() + pInfo.currentCol /
static_cast< double >( pInfo.nCols ) * viewPortExtent.
width();
119 double xmax = pInfo.currentCol + nCols == pInfo.nCols ? viewPortExtent.
xMaximum() :
120 viewPortExtent.
xMinimum() + ( pInfo.currentCol + nCols ) /
static_cast< double >( pInfo.nCols ) * viewPortExtent.
width();
121 double ymin = pInfo.currentRow + nRows == pInfo.nRows ? viewPortExtent.
yMinimum() :
122 viewPortExtent.
yMaximum() - ( pInfo.currentRow + nRows ) /
static_cast< double >( pInfo.nRows ) * viewPortExtent.
height();
123 double ymax = viewPortExtent.
yMaximum() - pInfo.currentRow /
static_cast< double >( pInfo.nRows ) * viewPortExtent.
height();
127 *blockExtent = blockRect;
130 block->reset( mInput->
block( bandNumber, blockRect, nCols, nRows, mFeedback ) );
131 topLeftCol = pInfo.currentCol;
132 topLeftRow = pInfo.currentRow;
134 pInfo.currentCol += nCols;
135 if ( pInfo.currentCol == pInfo.nCols && pInfo.currentRow + nRows == pInfo.nRows )
137 pInfo.currentRow = pInfo.nRows;
139 else if ( pInfo.currentCol == pInfo.nCols )
141 pInfo.currentCol = 0;
142 pInfo.currentRow += nRows;
150 removePartInfo( bandNumber );
153 void QgsRasterIterator::removePartInfo(
int bandNumber )
155 auto partIt = mRasterPartInfos.constFind( bandNumber );
156 if ( partIt != mRasterPartInfos.constEnd() )
158 mRasterPartInfos.remove( bandNumber );