[QGIS Commit] r12904 - trunk/qgis/src/core/raster

svn_qgis at osgeo.org svn_qgis at osgeo.org
Tue Feb 9 03:02:54 EST 2010


Author: mhugent
Date: 2010-02-09 03:02:48 -0500 (Tue, 09 Feb 2010)
New Revision: 12904

Modified:
   trunk/qgis/src/core/raster/qgsrasterlayer.cpp
Log:
Fix for small raster shift introduced by my raster memory handling improvements

Modified: trunk/qgis/src/core/raster/qgsrasterlayer.cpp
===================================================================
--- trunk/qgis/src/core/raster/qgsrasterlayer.cpp	2010-02-08 23:48:21 UTC (rev 12903)
+++ trunk/qgis/src/core/raster/qgsrasterlayer.cpp	2010-02-09 08:02:48 UTC (rev 12904)
@@ -1118,7 +1118,7 @@
   int myWidth = mWidth;
   int myHeight = mHeight;
   int myDivisor = 2;
-  
+
   if ( mDataProvider ) return mPyramidList;
 
   GDALRasterBandH myGDALBand = GDALGetRasterBand( mGdalDataset, 1 ); //just use the first band
@@ -3227,7 +3227,7 @@
           mDrawingStyle = MultiBandColor;  //sensible default
 
           // Setup source CRS
-          if ( mProviderKey == "wms" ) 
+          if ( mProviderKey == "wms" )
           {
             *mCRS = QgsCoordinateReferenceSystem();
             mCRS->createFromOgcWmsCrs( crs );
@@ -5417,7 +5417,8 @@
 
   if ( mLastModified < QgsRasterLayer::lastModified( source() ) )
   {
-    if ( !usesProvider() ) {
+    if ( !usesProvider() )
+    {
       QgsDebugMsg( "Outdated -> reload" );
       closeDataset();
       return readFile( source() );
@@ -5600,9 +5601,25 @@
       }
       else
       {
-        double xLeft = mViewPort->topLeftPoint.x();
-        double yTop = mViewPort->topLeftPoint.y() + fabs( mGeoTransform[5] ) * mCurrentPartRasterMin / mMapToPixel->mapUnitsPerPixel();
-        mPainter->drawImage( QPointF( xLeft, yTop + 0.5 ), *mCurrentImage );
+        int paintXoffset = static_cast<int>(
+                             ( mViewPort->rectXOffsetFloat -
+                               mViewPort->rectXOffset )
+                             / mMapToPixel->mapUnitsPerPixel()
+                             * fabs( mGeoTransform[1] )
+                           );
+
+        int paintYoffset = static_cast<int>(
+                             ( mViewPort->rectYOffsetFloat -
+                               mViewPort->rectYOffset )
+                             / mMapToPixel->mapUnitsPerPixel()
+                             * fabs( mGeoTransform[5] )
+                           );
+
+        mPainter->drawImage( static_cast<int>( mViewPort->topLeftPoint.x() + 0.5 ),
+                             static_cast<int>( mViewPort->topLeftPoint.y() + 0.5 +  fabs( mGeoTransform[5] ) * mCurrentPartRasterMin / mMapToPixel->mapUnitsPerPixel() ),
+                             *mCurrentImage,
+                             paintXoffset,
+                             paintYoffset );
       }
     }
   }



More information about the QGIS-commit mailing list