Skip to content
Permalink
Browse files
do not accept band-less dataset as valid (#1040)
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@8693 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
warmerdam committed Jun 30, 2008
1 parent af1e475 commit ce706d10dcc94f3fa7351ff72ca7108e2be849ac
Showing with 16 additions and 22 deletions.
  1. +16 −22 src/core/raster/qgsrasterlayer.cpp
@@ -267,36 +267,20 @@ bool QgsRasterLayer::isValidRasterFileName(QString const & theFileNameQString)
{
return false;
}
else if( GDALGetRasterCount( myDataset ) == 0 )
{
GDALClose( myDataset );
myDataset = NULL;
return false;
}
else
{
GDALClose(myDataset);
return true;
}

/*
* This way is no longer a good idea because it does not
* cater for filetypes such as grass rasters that dont
* have a predictable file extension.
*
QString name = theFileNameQString.toLower();
return (name.endsWith(".adf") ||
name.endsWith(".asc") ||
name.endsWith(".grd") ||
name.endsWith(".img") ||
name.endsWith(".tif") ||
name.endsWith(".png") ||
name.endsWith(".jpg") ||
name.endsWith(".dem") ||
name.endsWith(".ddf")) ||
name.endsWith(".dt0");
*/
}





//////////////////////////////////////////////////////////
//
// Non Static methods now....
@@ -421,6 +405,16 @@ bool QgsRasterLayer::readFile( QString const & fileName )

//check f this file has pyramids
GDALRasterBandH myGDALBand = GDALGetRasterBand( mGdalDataset, 1 ); //just use the first band
if (myGDALBand == NULL)
{
GDALDereferenceDataset(mGdalBaseDataset);
mGdalBaseDataset = NULL;

GDALClose(mGdalDataset);
mGdalDataset = NULL;
mValid = FALSE;
return false;
}
if( GDALGetOverviewCount(myGDALBand) > 0 )
{
hasPyramidsFlag=true;

0 comments on commit ce706d1

Please sign in to comment.