Skip to content
Permalink
Browse files

ECW identify() fix conditional for ECW driver and GDAL < 1.9.2

  • Loading branch information
blazek committed Sep 3, 2012
1 parent d2f08c6 commit ff7b21d54573e2cab4b926fdf98ed536ea179e76
Showing with 23 additions and 12 deletions.
  1. +23 −12 src/providers/gdal/qgsgdalprovider.cpp
@@ -847,23 +847,34 @@ bool QgsGdalProvider::identify( const QgsPoint & point, QMap<int, QString>& resu
GDALRasterBandH gdalBand = GDALGetRasterBand( mGdalDataset, i );
double data[4];

// GDAL ECW driver reads whole row if single pixel (nYSize == 1) is requested
// and it makes identify very slow -> use 2x2 matrix
int r = 0;
int c = 0;
if ( col == mWidth - 1 && mWidth > 1 )
int width = 1;
int height = 1;

// GDAL ECW driver in GDAL < 1.9.2 read whole row if single pixel (nYSize == 1)
// was requested which made identify very slow -> use 2x2 matrix
// but other drivers may be optimised for 1x1 -> conditional
#if !defined(GDAL_VERSION_NUM) || GDAL_VERSION_NUM < 1920
if ( strcmp( GDALGetDriverShortName( GDALGetDatasetDriver( mGdalDataset ) ), "ECW" ) == 0 )
{
col--;
c++;
}
if ( row == mHeight - 1 && mHeight > 1 )
{
row--;
r++;
width = 2;
height = 2;
if ( col == mWidth - 1 && mWidth > 1 )
{
col--;
c++;
}
if ( row == mHeight - 1 && mHeight > 1 )
{
row--;
r++;
}
}
#endif

CPLErr err = GDALRasterIO( gdalBand, GF_Read, col, row, 2, 2,
data, 2, 2, GDT_Float64, 0, 0 );
CPLErr err = GDALRasterIO( gdalBand, GF_Read, col, row, width, height,
data, width, height, GDT_Float64, 0, 0 );

if ( err != CPLE_None )
{

0 comments on commit ff7b21d

Please sign in to comment.
You can’t perform that action at this time.