Skip to content

Commit ff7b21d

Browse files
committed
ECW identify() fix conditional for ECW driver and GDAL < 1.9.2
1 parent d2f08c6 commit ff7b21d

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

src/providers/gdal/qgsgdalprovider.cpp

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -847,23 +847,34 @@ bool QgsGdalProvider::identify( const QgsPoint & point, QMap<int, QString>& resu
847847
GDALRasterBandH gdalBand = GDALGetRasterBand( mGdalDataset, i );
848848
double data[4];
849849

850-
// GDAL ECW driver reads whole row if single pixel (nYSize == 1) is requested
851-
// and it makes identify very slow -> use 2x2 matrix
852850
int r = 0;
853851
int c = 0;
854-
if ( col == mWidth - 1 && mWidth > 1 )
852+
int width = 1;
853+
int height = 1;
854+
855+
// GDAL ECW driver in GDAL < 1.9.2 read whole row if single pixel (nYSize == 1)
856+
// was requested which made identify very slow -> use 2x2 matrix
857+
// but other drivers may be optimised for 1x1 -> conditional
858+
#if !defined(GDAL_VERSION_NUM) || GDAL_VERSION_NUM < 1920
859+
if ( strcmp( GDALGetDriverShortName( GDALGetDatasetDriver( mGdalDataset ) ), "ECW" ) == 0 )
855860
{
856-
col--;
857-
c++;
858-
}
859-
if ( row == mHeight - 1 && mHeight > 1 )
860-
{
861-
row--;
862-
r++;
861+
width = 2;
862+
height = 2;
863+
if ( col == mWidth - 1 && mWidth > 1 )
864+
{
865+
col--;
866+
c++;
867+
}
868+
if ( row == mHeight - 1 && mHeight > 1 )
869+
{
870+
row--;
871+
r++;
872+
}
863873
}
874+
#endif
864875

865-
CPLErr err = GDALRasterIO( gdalBand, GF_Read, col, row, 2, 2,
866-
data, 2, 2, GDT_Float64, 0, 0 );
876+
CPLErr err = GDALRasterIO( gdalBand, GF_Read, col, row, width, height,
877+
data, width, height, GDT_Float64, 0, 0 );
867878

868879
if ( err != CPLE_None )
869880
{

0 commit comments

Comments
 (0)