Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix rounding for WMS stripes
git-svn-id: http://svn.osgeo.org/qgis/trunk@13308 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Apr 14, 2010
1 parent 44091ae commit df47f65
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/core/raster/qgsrasterlayer.cpp
Expand Up @@ -364,7 +364,7 @@ void QgsRasterLayer::buildSupportedRasterFileFilter( QString & theFileFiltersStr
if ( !( myGdalDriverExtension.isEmpty() || myGdalDriverLongName.isEmpty() ) )
{
// XXX add check for SDTS; in that case we want (*CATD.DDF)
QString glob = "*." + myGdalDriverExtension.replace("/", " *.");
QString glob = "*." + myGdalDriverExtension.replace( "/", " *." );
// Add only the first JP2 driver found to the filter list (it's the one GDAL uses)
if ( myGdalDriverDescription == "JPEG2000" ||
myGdalDriverDescription.startsWith( "JP2" ) ) // JP2ECW, JP2KAK, JP2MrSID
Expand Down Expand Up @@ -1558,14 +1558,23 @@ bool QgsRasterLayer::draw( QgsRenderContext& rendererContext )

int currentPixelOffsetY = 0; //top y-coordinate of current raster part
//the width of a WMS image part
int pixelWidth = ( myRasterExtent.xMaximum() - myRasterExtent.xMinimum() ) / theQgsMapToPixel.mapUnitsPerPixel();
int pixelWidth = ( myRasterExtent.xMaximum() - myRasterExtent.xMinimum() ) / theQgsMapToPixel.mapUnitsPerPixel() + 0.5;
for ( int i = 0; i < numParts; ++i )
{
//fetch a small overlap of 2 pixels between two adjacent tiles to avoid white stripes
QgsRectangle rasterPartRect( myRasterExtent.xMinimum(), myRasterExtent.yMaximum() - ( currentPixelOffsetY + numRowsPerPart + 2 ) * theQgsMapToPixel.mapUnitsPerPixel(),
myRasterExtent.xMaximum(), myRasterExtent.yMaximum() - currentPixelOffsetY * theQgsMapToPixel.mapUnitsPerPixel() );

int pixelHeight = rasterPartRect.height() / theQgsMapToPixel.mapUnitsPerPixel();
int pixelHeight = rasterPartRect.height() / theQgsMapToPixel.mapUnitsPerPixel() + 0.5;

/*
QgsDebugMsg( "**********WMS tile parameter***************" );
QgsDebugMsg( "pixelWidth: " + QString::number( pixelWidth ) );
QgsDebugMsg( "pixelHeight: " + QString::number( pixelHeight ) );
QgsDebugMsg( "mapWidth: " + QString::number( rasterPartRect.width() ) );
QgsDebugMsg( "mapHeight: " + QString::number( rasterPartRect.height(), 'f', 8 ) );
QgsDebugMsg( "mapUnitsPerPixel: " + QString::number( theQgsMapToPixel.mapUnitsPerPixel() ) );*/

QImage* image = mDataProvider->draw( rasterPartRect, pixelWidth, pixelHeight );

if ( !image )
Expand Down

0 comments on commit df47f65

Please sign in to comment.