Skip to content

Commit

Permalink
Partial fix for bug #632 (size too large error).
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/branches/Release-0_8_0@6755 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
homann committed Mar 3, 2007
1 parent 1834070 commit a1a1173
Showing 1 changed file with 30 additions and 23 deletions.
53 changes: 30 additions & 23 deletions src/raster/qgsrasterlayer.cpp
Expand Up @@ -1176,10 +1176,10 @@ __FUNCTION__, __LINE__);
myRasterViewPort->topLeftPoint = theQgsMapToPixel->transform(myRasterExtent.xMin(), myRasterExtent.yMax());
myRasterViewPort->bottomRightPoint = theQgsMapToPixel->transform(myRasterExtent.xMax(), myRasterExtent.yMin());

myRasterViewPort->drawableAreaXDimInt =
abs(static_cast<int> (myRasterViewPort->clippedWidthInt / theQgsMapToPixel->mapUnitsPerPixel() * adfGeoTransform[1]));
myRasterViewPort->drawableAreaYDimInt =
abs(static_cast<int> (myRasterViewPort->clippedHeightInt / theQgsMapToPixel->mapUnitsPerPixel() * adfGeoTransform[5]));
myRasterViewPort->drawableAreaXDimInt = static_cast<int>
(fabs( (myRasterViewPort->clippedWidthInt / theQgsMapToPixel->mapUnitsPerPixel() * adfGeoTransform[1])) + 0.5);
myRasterViewPort->drawableAreaYDimInt = static_cast<int>
(fabs( (myRasterViewPort->clippedHeightInt / theQgsMapToPixel->mapUnitsPerPixel() * adfGeoTransform[5])) + 0.5);


#ifdef QGISDEBUG
Expand Down Expand Up @@ -1241,14 +1241,6 @@ __FUNCTION__, __LINE__);

// /\/\/\ - added to handle zoomed-in rasters

if ((myRasterViewPort->drawableAreaXDimInt) > 4000 && (myRasterViewPort->drawableAreaYDimInt > 4000))
{
// We have scale one raster pixel to more than 4000 screen pixels. What's the point of showing this layer?
// Instead, we just stop displaying the layer. Prevents allocating the entire world of memory for showing
// The pixel in all its glory.
QgsDebugMsg("Too zoomed out! Raster will not display");
return TRUE;
}

// Provider mode: See if a provider key is specified, and if so use the provider instead

Expand All @@ -1262,9 +1254,15 @@ QgsDebugMsg("QgsRasterLayer::draw: Checking for provider key.");

QImage* image =
dataProvider->draw(
myRasterExtent,
myRasterViewPort->drawableAreaXDimInt,
myRasterViewPort->drawableAreaYDimInt
myRasterExtent,
// Below should calculate to the actual pixel size of the
// part of the layer that's visible.
static_cast<int>( fabs( (myRasterViewPort->clippedXMaxDouble - myRasterViewPort->clippedXMinDouble)
/ theQgsMapToPixel->mapUnitsPerPixel() * adfGeoTransform[1]) + 1),
static_cast<int>( fabs( (myRasterViewPort->clippedYMaxDouble - myRasterViewPort->clippedYMinDouble)
/ theQgsMapToPixel->mapUnitsPerPixel() * adfGeoTransform[5]) + 1)
// myRasterViewPort->drawableAreaXDimInt,
// myRasterViewPort->drawableAreaYDimInt
);

if (!image)
Expand Down Expand Up @@ -1315,15 +1313,24 @@ __FUNCTION__, __LINE__, 1);
}
else
{
// Otherwise use the old-fashioned GDAL direct-drawing style
// TODO: Move into its own GDAL provider.

// \/\/\/ - commented-out to handle zoomed-in rasters
if ((myRasterViewPort->drawableAreaXDimInt) > 4000 && (myRasterViewPort->drawableAreaYDimInt > 4000))
{
// We have scaled one raster pixel to more than 4000 screen pixels. What's the point of showing this layer?
// Instead, we just stop displaying the layer. Prevents allocating the entire world of memory for showing
// very few pixels.
// (Alternatively, we have a very big screen > 2000 x 2000)
QgsDebugMsg("Too zoomed in! Displaying raster requires too much memory. Raster will not display");
} else {
// Otherwise use the old-fashioned GDAL direct-drawing style
// TODO: Move into its own GDAL provider.

// \/\/\/ - commented-out to handle zoomed-in rasters
// draw(theQPainter,myRasterViewPort);
// /\/\/\ - commented-out to handle zoomed-in rasters
// \/\/\/ - added to handle zoomed-in rasters
draw(theQPainter, myRasterViewPort, theQgsMapToPixel);
// /\/\/\ - added to handle zoomed-in rasters
// /\/\/\ - commented-out to handle zoomed-in rasters
// \/\/\/ - added to handle zoomed-in rasters
draw(theQPainter, myRasterViewPort, theQgsMapToPixel);
// /\/\/\ - added to handle zoomed-in rasters
}

}

Expand Down

0 comments on commit a1a1173

Please sign in to comment.