[QGIS Commit] r15005 - in branches/raster-providers/src: core core/raster providers/gdal providers/grass providers/wms

svn_qgis at osgeo.org svn_qgis at osgeo.org
Sat Jan 8 11:35:21 EST 2011


Author: rblazek
Date: 2011-01-08 08:35:21 -0800 (Sat, 08 Jan 2011)
New Revision: 15005

Modified:
   branches/raster-providers/src/core/qgsrasterdataprovider.h
   branches/raster-providers/src/core/raster/qgsrasterlayer.cpp
   branches/raster-providers/src/core/raster/qgsrasterviewport.h
   branches/raster-providers/src/providers/gdal/qgsgdalprovider.cpp
   branches/raster-providers/src/providers/gdal/qgsgdalprovider.h
   branches/raster-providers/src/providers/grass/qgsgrassrasterprovider.cpp
   branches/raster-providers/src/providers/grass/qgsgrassrasterprovider.h
   branches/raster-providers/src/providers/wms/qgswmsprovider.cpp
   branches/raster-providers/src/providers/wms/qgswmsprovider.h
Log:
enabled source CRS overwriting

Modified: branches/raster-providers/src/core/qgsrasterdataprovider.h
===================================================================
--- branches/raster-providers/src/core/qgsrasterdataprovider.h	2011-01-07 16:56:07 UTC (rev 15004)
+++ branches/raster-providers/src/core/qgsrasterdataprovider.h	2011-01-08 16:35:21 UTC (rev 15005)
@@ -298,7 +298,7 @@
     virtual void readBlock( int bandNo, int xBlock, int yBlock, void *data ){}
 
     /** read block of data using give extent and size */
-    virtual void readBlock( int bandNo, QgsRectangle  const & viewExtent, int width, int height, QgsCoordinateReferenceSystem theDestCRS, void *data ) {};
+    virtual void readBlock( int bandNo, QgsRectangle  const & viewExtent, int width, int height, QgsCoordinateReferenceSystem theSrcCRS, QgsCoordinateReferenceSystem theDestCRS, void *data ) {};
 
     /** value representing null data */
     virtual double noDataValue() const { return 0; }

Modified: branches/raster-providers/src/core/raster/qgsrasterlayer.cpp
===================================================================
--- branches/raster-providers/src/core/raster/qgsrasterlayer.cpp	2011-01-07 16:56:07 UTC (rev 15004)
+++ branches/raster-providers/src/core/raster/qgsrasterlayer.cpp	2011-01-08 16:35:21 UTC (rev 15005)
@@ -877,8 +877,10 @@
   myRasterViewPort->mDrawnExtent = myRasterExtent;
   if ( rendererContext.coordinateTransform() ) 
   {
+    myRasterViewPort->mSrcCRS = crs();
     myRasterViewPort->mDestCRS = rendererContext.coordinateTransform()->destCRS();
   } else {
+    myRasterViewPort->mSrcCRS = QgsCoordinateReferenceSystem(); // will be invalid
     myRasterViewPort->mDestCRS = QgsCoordinateReferenceSystem(); // will be invalid
   }
 
@@ -4707,7 +4709,7 @@
       viewPort->mDrawnExtent.xMaximum(), 
       viewPort->mDrawnExtent.yMaximum() 
     );
-    mDataProvider->readBlock ( bandNo, partExtent, viewPort->drawableAreaXDim, viewPort->drawableAreaYDim, QgsCoordinateReferenceSystem(), data );
+    mDataProvider->readBlock ( bandNo, partExtent, viewPort->drawableAreaXDim, viewPort->drawableAreaYDim, QgsCoordinateReferenceSystem(), QgsCoordinateReferenceSystem(), data );
   }
   return data;
 }
@@ -5088,7 +5090,7 @@
   QgsRectangle myPartExtent ( mViewPort->mDrawnExtent.xMinimum(), yMin,
                             mViewPort->mDrawnExtent.xMaximum(), yMax );
   QgsDebugMsg( "myPartExtent is " + myPartExtent.toString() );
-  mDataProvider->readBlock ( mBandNo, myPartExtent, xSize, ySize, mViewPort->mDestCRS, mCurrentGDALData );
+  mDataProvider->readBlock ( mBandNo, myPartExtent, xSize, ySize, mViewPort->mSrcCRS, mViewPort->mDestCRS, mCurrentGDALData );
 
   
   // TODO - error check - throw exception

Modified: branches/raster-providers/src/core/raster/qgsrasterviewport.h
===================================================================
--- branches/raster-providers/src/core/raster/qgsrasterviewport.h	2011-01-07 16:56:07 UTC (rev 15004)
+++ branches/raster-providers/src/core/raster/qgsrasterviewport.h	2011-01-08 16:35:21 UTC (rev 15005)
@@ -86,6 +86,9 @@
   // intersection of current map extent and layer extent
   QgsRectangle mDrawnExtent;
 
+  // Source coordinate system
+  QgsCoordinateReferenceSystem mSrcCRS;
+
   // Target coordinate system
   QgsCoordinateReferenceSystem mDestCRS;
 };

Modified: branches/raster-providers/src/providers/gdal/qgsgdalprovider.cpp
===================================================================
--- branches/raster-providers/src/providers/gdal/qgsgdalprovider.cpp	2011-01-07 16:56:07 UTC (rev 15004)
+++ branches/raster-providers/src/providers/gdal/qgsgdalprovider.cpp	2011-01-08 16:35:21 UTC (rev 15005)
@@ -464,12 +464,13 @@
   GDALReadBlock( myGdalBand, xBlock, yBlock, block );
 }
 
-void QgsGdalProvider::readBlock( int theBandNo, QgsRectangle  const & theExtent, int thePixelWidth, int thePixelHeight, QgsCoordinateReferenceSystem theDestCRS, void *theBlock )
+void QgsGdalProvider::readBlock( int theBandNo, QgsRectangle  const & theExtent, int thePixelWidth, int thePixelHeight, QgsCoordinateReferenceSystem theSrcCRS, QgsCoordinateReferenceSystem theDestCRS, void *theBlock )
 {
   QgsDebugMsg( "thePixelWidth = "  + QString::number( thePixelWidth ) );
   QgsDebugMsg( "thePixelHeight = "  + QString::number( thePixelHeight ) );
   QgsDebugMsg( "theExtent: " + theExtent.toString() );
   QgsDebugMsg( "crs(): " + crs().toWkt() );
+  QgsDebugMsg( "theSrcCRS: " + theDestCRS.toWkt() );
   QgsDebugMsg( "theDestCRS: " + theDestCRS.toWkt() );
 
 
@@ -538,7 +539,8 @@
   myWarpOptions->nBandCount = 1;
   myWarpOptions->panSrcBands = 
     (int *) CPLMalloc(sizeof(int) * myWarpOptions->nBandCount );
-  myWarpOptions->panSrcBands[0] = 1;
+  //myWarpOptions->panSrcBands[0] = 1;
+  myWarpOptions->panSrcBands[0] = theBandNo;
   myWarpOptions->panDstBands = 
     (int *) CPLMalloc(sizeof(int) * myWarpOptions->nBandCount );
   myWarpOptions->panDstBands[0] = 1;
@@ -551,12 +553,14 @@
   myWarpOptions->pTransformerArg = 
       GDALCreateGenImgProjTransformer( 
         mGdalDataset, 
-        GDALGetProjectionRef(mGdalDataset), 
         //mySrcCRSChar, 
+        //GDALGetProjectionRef(mGdalDataset), 
+        theSrcCRS.toWkt().toAscii().constData(),
         myGdalMemDataset,
         GDALGetProjectionRef(myGdalMemDataset), 
         FALSE, 0.0, 1 
       );
+
   CPLAssert( myWarpOptions->pTransformerArg  != NULL); 
   myWarpOptions->pfnTransformer = GDALGenImgProjTransform;
 
@@ -567,6 +571,7 @@
   myWarpOptions->padfDstNoDataReal = (double *) CPLMalloc( myWarpOptions->nBandCount * sizeof(double));
   myWarpOptions->padfDstNoDataImag = (double *) CPLMalloc( myWarpOptions->nBandCount * sizeof(double));
 
+  /*
   for  ( int i = 0; i < myWarpOptions->nBandCount; i++ )
   {
     
@@ -578,13 +583,22 @@
                         myWarpOptions->padfDstNoDataReal[i] );
 
   }
+  */
+  myWarpOptions->padfDstNoDataReal[0] = mNoDataValue;
+  myWarpOptions->padfDstNoDataImag[0] = 0.0;
 
+  GDALSetRasterNoDataValue( GDALGetRasterBand( myGdalMemDataset, 
+                      myWarpOptions->panDstBands[0] ),
+                      myWarpOptions->padfDstNoDataReal[0] );
+
   // TODO optimize somehow to avoid no data init if not necessary 
   // i.e. no projection, but there is also the problem with margine
-  //myWarpOptions->papszWarpOptions = 
-  //  CSLSetNameValue(myWarpOptions->papszWarpOptions,"INIT_DEST", "NO_DATA" );
+  myWarpOptions->papszWarpOptions = 
+    CSLSetNameValue(myWarpOptions->papszWarpOptions,"INIT_DEST", "NO_DATA" );
 
+  myWarpOptions->eResampleAlg = GRA_NearestNeighbour;
 
+
   GDALWarpOperation myOperation;
 
   myOperation.Initialize( myWarpOptions );

Modified: branches/raster-providers/src/providers/gdal/qgsgdalprovider.h
===================================================================
--- branches/raster-providers/src/providers/gdal/qgsgdalprovider.h	2011-01-07 16:56:07 UTC (rev 15004)
+++ branches/raster-providers/src/providers/gdal/qgsgdalprovider.h	2011-01-08 16:35:21 UTC (rev 15005)
@@ -200,7 +200,7 @@
 
 
     void readBlock( int bandNo, int xBlock, int yBlock, void *data );
-    void readBlock( int bandNo, QgsRectangle  const & viewExtent, int width, int height, QgsCoordinateReferenceSystem theDestCRS,  void *data );
+    void readBlock( int bandNo, QgsRectangle  const & viewExtent, int width, int height, QgsCoordinateReferenceSystem theSrcCRS, QgsCoordinateReferenceSystem theDestCRS,  void *data );
 
     double noDataValue() const;
     void computeMinMax(int bandNo);

Modified: branches/raster-providers/src/providers/grass/qgsgrassrasterprovider.cpp
===================================================================
--- branches/raster-providers/src/providers/grass/qgsgrassrasterprovider.cpp	2011-01-07 16:56:07 UTC (rev 15004)
+++ branches/raster-providers/src/providers/grass/qgsgrassrasterprovider.cpp	2011-01-08 16:35:21 UTC (rev 15005)
@@ -201,7 +201,7 @@
   memcpy( block, data.data(), size );
 }
 
-void QgsGrassRasterProvider::readBlock( int bandNo, QgsRectangle  const & viewExtent, int pixelWidth, int pixelHeight, QgsCoordinateReferenceSystem theDestCRS, void *block )
+void QgsGrassRasterProvider::readBlock( int bandNo, QgsRectangle  const & viewExtent, int pixelWidth, int pixelHeight, QgsCoordinateReferenceSystem theSrcCRS, QgsCoordinateReferenceSystem theDestCRS, void *block )
 {
   QgsDebugMsg( "Entered" );
   QgsDebugMsg( "pixelWidth = "  + QString::number( pixelWidth ) );

Modified: branches/raster-providers/src/providers/grass/qgsgrassrasterprovider.h
===================================================================
--- branches/raster-providers/src/providers/grass/qgsgrassrasterprovider.h	2011-01-07 16:56:07 UTC (rev 15004)
+++ branches/raster-providers/src/providers/grass/qgsgrassrasterprovider.h	2011-01-08 16:35:21 UTC (rev 15005)
@@ -191,7 +191,7 @@
 
 
     void readBlock( int bandNo, int xBlock, int yBlock, void *data );
-    void readBlock( int bandNo, QgsRectangle  const & viewExtent, int width, int height, QgsCoordinateReferenceSystem theDestCRS, void *data );
+    void readBlock( int bandNo, QgsRectangle  const & viewExtent, int width, int height, QgsCoordinateReferenceSystem theSrcCRS, QgsCoordinateReferenceSystem theDestCRS, void *data );
 
     double noDataValue() const;
     double minimumValue(int bandNo)const;

Modified: branches/raster-providers/src/providers/wms/qgswmsprovider.cpp
===================================================================
--- branches/raster-providers/src/providers/wms/qgswmsprovider.cpp	2011-01-07 16:56:07 UTC (rev 15004)
+++ branches/raster-providers/src/providers/wms/qgswmsprovider.cpp	2011-01-08 16:35:21 UTC (rev 15005)
@@ -678,7 +678,7 @@
   return cachedImage;
 }
 
-void QgsWmsProvider::readBlock( int bandNo, QgsRectangle  const & viewExtent, int pixelWidth, int pixelHeight, QgsCoordinateReferenceSystem theDestCRS, void *block )
+void QgsWmsProvider::readBlock( int bandNo, QgsRectangle  const & viewExtent, int pixelWidth, int pixelHeight, QgsCoordinateReferenceSystem theSrcCRS, QgsCoordinateReferenceSystem theDestCRS, void *block )
 {
   QgsDebugMsg( "Entered" );
   // TODO: optimize to avoid writing to QImage

Modified: branches/raster-providers/src/providers/wms/qgswmsprovider.h
===================================================================
--- branches/raster-providers/src/providers/wms/qgswmsprovider.h	2011-01-07 16:56:07 UTC (rev 15004)
+++ branches/raster-providers/src/providers/wms/qgswmsprovider.h	2011-01-08 16:35:21 UTC (rev 15005)
@@ -459,7 +459,7 @@
      */
     QImage *draw( QgsRectangle const &  viewExtent, int pixelWidth, int pixelHeight );
 
-    void readBlock( int bandNo, QgsRectangle  const & viewExtent, int width, int height,  QgsCoordinateReferenceSystem theDestCRS, void *data );
+    void readBlock( int bandNo, QgsRectangle  const & viewExtent, int width, int height, QgsCoordinateReferenceSystem theSrcCRS, QgsCoordinateReferenceSystem theDestCRS, void *data );
 
 
     /** Return the extent for this data layer



More information about the QGIS-commit mailing list