@@ -534,7 +534,12 @@ void QgsGdalProvider::readBlock( int theBandNo, QgsRectangle const & theExtent,
534
534
myMemDsn.sprintf ( " DATAPOINTER = %p" , theBlock );
535
535
QgsDebugMsg ( myMemDsn );
536
536
537
- myMemDsn.sprintf ( " MEM:::DATAPOINTER=%lu,PIXELS=%d,LINES=%d,BANDS=1,DATATYPE=%s,PIXELOFFSET=0,LINEOFFSET=0,BANDOFFSET=0" , ( long )theBlock, thePixelWidth, thePixelHeight, GDALGetDataTypeName (( GDALDataType )mGdalDataType [theBandNo-1 ] ) );
537
+ // myMemDsn.sprintf( "MEM:::DATAPOINTER=%lu,PIXELS=%d,LINES=%d,BANDS=1,DATATYPE=%s,PIXELOFFSET=0,LINEOFFSET=0,BANDOFFSET=0", ( long )theBlock, thePixelWidth, thePixelHeight, GDALGetDataTypeName(( GDALDataType )mGdalDataType[theBandNo-1] ) );
538
+ char szPointer[64 ];
539
+ memset ( szPointer, 0 , sizeof (szPointer) );
540
+ CPLPrintPointer ( szPointer, theBlock, sizeof (szPointer) );
541
+
542
+ myMemDsn.sprintf ( " MEM:::DATAPOINTER=%s,PIXELS=%d,LINES=%d,BANDS=1,DATATYPE=%s,PIXELOFFSET=0,LINEOFFSET=0,BANDOFFSET=0" , szPointer, thePixelWidth, thePixelHeight, GDALGetDataTypeName (( GDALDataType )mGdalDataType [theBandNo-1 ] ) );
538
543
539
544
QgsDebugMsg ( " Open GDAL MEM : " + myMemDsn );
540
545
@@ -560,6 +565,13 @@ void QgsGdalProvider::readBlock( int theBandNo, QgsRectangle const & theExtent,
560
565
561
566
double myGeoTransform[6 ];
562
567
GDALGetGeoTransform ( mGdalDataset , myGeoTransform );
568
+ // TODO:
569
+ // Attention: GDALCreateGenImgProjTransformer failes if source data source
570
+ // is not georeferenced, e.g. matrix 0,1,0,0,0,1/-1
571
+ // as a workaround in such case we have to set some different value - really ugly
572
+ myGeoTransform[0 ] = DBL_MIN;
573
+ GDALSetGeoTransform ( mGdalDataset , myGeoTransform );
574
+
563
575
GDALSetGeoTransform ( myGdalMemDataset, myMemGeoTransform );
564
576
565
577
for ( int i = 0 ; i < 6 ; i++ )
@@ -593,8 +605,24 @@ void QgsGdalProvider::readBlock( int theBandNo, QgsRectangle const & theExtent,
593
605
NULL ,
594
606
FALSE , 0.0 , 1
595
607
);
596
-
597
- CPLAssert ( myWarpOptions->pTransformerArg != NULL );
608
+ /*
609
+ myWarpOptions->pTransformerArg =
610
+ GDALCreateGenImgProjTransformer2(
611
+ mGdalDataset,
612
+ myGdalMemDataset,
613
+ NULL
614
+ );
615
+ */
616
+ if ( !myWarpOptions->pTransformerArg )
617
+ {
618
+ QMessageBox::warning ( 0 , QObject::tr ( " Warning" ),
619
+ QObject::tr ( " Cannot GDALCreateGenImgProjTransformer: " )
620
+ + QString::fromUtf8 ( CPLGetLastErrorMsg () ) );
621
+ return ;
622
+
623
+ };
624
+
625
+ // CPLAssert( myWarpOptions->pTransformerArg != NULL );
598
626
myWarpOptions->pfnTransformer = GDALGenImgProjTransform;
599
627
600
628
myWarpOptions->padfDstNoDataReal = ( double * ) CPLMalloc ( myWarpOptions->nBandCount * sizeof ( double ) );
@@ -616,7 +644,14 @@ void QgsGdalProvider::readBlock( int theBandNo, QgsRectangle const & theExtent,
616
644
617
645
GDALWarpOperation myOperation;
618
646
619
- myOperation.Initialize ( myWarpOptions );
647
+ if ( myOperation.Initialize ( myWarpOptions ) != CE_None )
648
+ {
649
+ QMessageBox::warning ( 0 , QObject::tr ( " Warning" ),
650
+ QObject::tr ( " Cannot inittialize GDALWarpOperation : " )
651
+ + QString::fromUtf8 ( CPLGetLastErrorMsg () ) );
652
+ return ;
653
+
654
+ };
620
655
CPLErrorReset ();
621
656
CPLErr myErr;
622
657
myErr = myOperation.ChunkAndWarpImage ( 0 , 0 , thePixelWidth, thePixelHeight );
0 commit comments