Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix display of raster layer that would sometimes show just garbage
If a raster layer was displayed in a way that it fitted into canvas,
but would be shifted towards left or top edge of canvas, that bug
would be triggered.

By doing extra floating point math where not necessary, small
imprecisions were introduced to extent definition and GDAL provider
would end up requesting a window one pixel taller or wider, which
leads to RasterIO error and results into garbage displayed on canvas
  • Loading branch information
wonder-sk committed Jan 20, 2016
1 parent f0cb706 commit ed1efcb
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/core/raster/qgsrasteriterator.cpp
Expand Up @@ -88,8 +88,10 @@ bool QgsRasterIterator::readNextRasterPart( int bandNumber,
//get subrectangle
QgsRectangle viewPortExtent = mExtent;
double xmin = viewPortExtent.xMinimum() + pInfo.currentCol / static_cast< double >( pInfo.nCols ) * viewPortExtent.width();
double xmax = viewPortExtent.xMinimum() + ( pInfo.currentCol + nCols ) / static_cast< double >( pInfo.nCols ) * viewPortExtent.width();
double ymin = viewPortExtent.yMaximum() - ( pInfo.currentRow + nRows ) / static_cast< double >( pInfo.nRows ) * viewPortExtent.height();
double xmax = pInfo.currentCol + nCols == pInfo.nCols ? viewPortExtent.xMaximum() : // avoid extra FP math if not necessary
viewPortExtent.xMinimum() + ( pInfo.currentCol + nCols ) / static_cast< double >( pInfo.nCols ) * viewPortExtent.width();
double ymin = pInfo.currentRow + nRows == pInfo.nRows ? viewPortExtent.yMinimum() : // avoid extra FP math if not necessary
viewPortExtent.yMaximum() - ( pInfo.currentRow + nRows ) / static_cast< double >( pInfo.nRows ) * viewPortExtent.height();
double ymax = viewPortExtent.yMaximum() - pInfo.currentRow / static_cast< double >( pInfo.nRows ) * viewPortExtent.height();
QgsRectangle blockRect( xmin, ymin, xmax, ymax );

Expand Down

0 comments on commit ed1efcb

Please sign in to comment.