Skip to content

Commit

Permalink
Ported WMS fix r6755 from 0.8 to trunk.
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@6759 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
homann committed Mar 4, 2007
1 parent 8a6772b commit 1746d7d
Showing 1 changed file with 27 additions and 20 deletions.
47 changes: 27 additions & 20 deletions src/core/raster/qgsrasterlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1121,14 +1121,6 @@ bool QgsRasterLayer::draw(QPainter * theQPainter,

// /\/\/\ - 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 @@ -1142,10 +1134,16 @@ bool QgsRasterLayer::draw(QPainter * theQPainter,

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 @@ -1195,15 +1193,24 @@ bool QgsRasterLayer::draw(QPainter * theQPainter,
}
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 1746d7d

Please sign in to comment.