Skip to content

Commit

Permalink
do not accept band-less dataset as valid (#1040)
Browse files Browse the repository at this point in the history
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 ce706d1
Showing 1 changed file with 16 additions and 22 deletions.
38 changes: 16 additions & 22 deletions src/core/raster/qgsrasterlayer.cpp
Expand Up @@ -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....
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit ce706d1

Please sign in to comment.