Relax checking of raster filetype extensions to cater for filetypes where extension is unpredictable (e.g. grass).

Now I use gdal to quickly check if a file is useable so pretty much anything gdal iscompile with should get through if you have chosen wildcard filter in add raster dialog.


git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@1428 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
timlinux 2004-05-18 22:58:49 +00:00
parent 82ad3f4789
commit f6c018b3ca

View File

@ -1410,13 +1410,40 @@ bool QgisApp::addRasterLayer(QStringList const &theFileNameQStringList)
/** This helper checks to see whether the filename appears to be a valid raster file name */
bool QgisApp::isValidRasterFileName(QString theFileNameQString)
{
QString name = theFileNameQString.lower();
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");
GDALDatasetH myDataset;
GDALAllRegister();
myDataset = GDALOpen( theFileNameQString, GA_ReadOnly );
if( myDataset == NULL )
{
return false;
}
else
{
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.lower();
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");
*/
}
/** Overloaded of the above function provided for convenience that takes a qstring pointer */