Skip to content

Commit

Permalink
Improvement to zoom-in speed for rasters.
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/branches/Release-0_8_0@6372 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
g_j_m committed Jan 1, 2007
1 parent 780535a commit ac44d8b
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/raster/qgsrasterlayer.cpp
Expand Up @@ -1133,16 +1133,21 @@ __FUNCTION__, __LINE__);
myRasterViewPort->clippedYMinDouble = (myRasterExtent.yMin() - adfGeoTransform[3]) / adfGeoTransform[5];
myRasterViewPort->clippedYMaxDouble = (myRasterExtent.yMax() - adfGeoTransform[3]) / adfGeoTransform[5];

// We do a "+2" for each of the 2 assignments below because:
// + 1 to simulate a ceil() out of static_cast<int> which otherwise is just a truncation.
// + 1 to allow for the fact that the left hand source pixel may be mostly scrolled out of view
// and therefore a fraction of a pixel would "leak" in the right hand side.
// (we could test for this case more explicitly if we wanted to be pedantic, but
// it's easier to just add one pixel "just in case")
myRasterViewPort->clippedWidthInt =
abs(static_cast < int >(myRasterViewPort->clippedXMaxDouble - myRasterViewPort->clippedXMinDouble)) + 2;
myRasterViewPort->clippedHeightInt =
abs(static_cast < int >(myRasterViewPort->clippedYMaxDouble - myRasterViewPort->clippedYMinDouble)) + 2;
// Sometimes the Ymin/Ymax are reversed.
if (myRasterViewPort->clippedYMinDouble > myRasterViewPort->clippedYMaxDouble)
{
double t = myRasterViewPort->clippedYMinDouble;
myRasterViewPort->clippedYMinDouble = myRasterViewPort->clippedYMaxDouble;
myRasterViewPort->clippedYMaxDouble = t;
}

// Set the clipped width and height to encompass all of the source pixels
// that could end up being displayed.
myRasterViewPort->clippedWidthInt =
static_cast<int>(ceil(myRasterViewPort->clippedXMaxDouble) - floor(myRasterViewPort->clippedXMinDouble));

myRasterViewPort->clippedHeightInt =
static_cast<int>(ceil(myRasterViewPort->clippedYMaxDouble) - floor(myRasterViewPort->clippedYMinDouble));

// but make sure the intended SE corner extent doesn't exceed the SE corner
// of the source raster, otherwise GDAL's RasterIO gives an error and returns nothing.
Expand Down

0 comments on commit ac44d8b

Please sign in to comment.