Skip to content
Permalink
Browse files
fixes for browser (GDAL rasters) : skip *.aux.xml files ; add suffix …
…to raster file names in browser ; add HDF4 file suffix (.hdf) in buildSupportedRasterFileFilterAndExtensions()
  • Loading branch information
etiennesky authored and jef-n committed Mar 9, 2012
1 parent 3e0fb86 commit a2b80be89b1d183cfeb69bc019e6fcaddb4bb404
Showing with 23 additions and 6 deletions.
  1. +2 −1 src/core/qgsdataitem.cpp
  2. +10 −4 src/providers/gdal/qgsgdaldataitems.cpp
  3. +11 −1 src/providers/gdal/qgsgdalprovider.cpp
@@ -194,7 +194,8 @@ bool QgsDataItem::hasChildren()

void QgsDataItem::addChildItem( QgsDataItem * child, bool refresh )
{
QgsDebugMsg( "mName = " + child->mName );
QgsDebugMsg( QString( "add child #%1 - %2" ).arg( mChildren.size() ).arg( child->mName ) );

int i;
for ( i = 0; i < mChildren.size(); i++ )
{
@@ -79,6 +79,12 @@ QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem )
QgsDebugMsg( "extensions: " + extensions.join( " " ) );
QgsDebugMsg( "wildcards: " + wildcards.join( " " ) );
}
// skip *.aux.xml files (GDAL auxilary metadata files)
// unless that extension is in the list (*.xml might be though)
if ( thePath.right( 8 ) == ".aux.xml" &&
extensions.indexOf( "aux.xml" ) < 0 )
return 0;

if ( extensions.indexOf( info.suffix().toLower() ) < 0 )
{
bool matches = false;
@@ -107,7 +113,8 @@ QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem )

QgsDebugMsg( "GdalDataset opened " + thePath );

QString name = info.completeBaseName();
//extract basename with extension
QString name = info.completeBaseName() + "." + QFileInfo( thePath ).suffix();
QString uri = thePath;

QgsLayerItem * item = new QgsGdalLayerItem( parentItem, name, thePath, uri );
@@ -124,11 +131,10 @@ QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem )
if ( hChildDS )
{
GDALClose( hChildDS );
QgsDebugMsg( QString( "add child #%1 - %2" ).arg( i ).arg( sublayers[i] ) );

QString name = sublayers[i];
name.replace( thePath, QFileInfo( thePath ).completeBaseName() );

//replace full path with basename+extension
name.replace( thePath, QFileInfo( thePath ).completeBaseName() + "." + QFileInfo( thePath ).suffix() );
childItem = new QgsGdalLayerItem( item, name, thePath + "/" + name, sublayers[i] );
if ( childItem )
item->addChildItem( childItem );
@@ -1267,7 +1267,10 @@ QStringList QgsGdalProvider::subLayers( GDALDatasetH dataset )
}
}

QgsDebugMsg( "sublayers:\n " + subLayers.join( "\n " ) );
if ( subLayers.size() > 0 )
{
QgsDebugMsg( "sublayers:\n " + subLayers.join( "\n " ) );
}

return subLayers;
}
@@ -1801,6 +1804,13 @@ void buildSupportedRasterFileFilterAndExtensions( QString & theFileFiltersString
theFileFiltersString += ";;[GDAL] " + myGdalDriverLongName + " (" + glob.toLower() + " " + glob.toUpper() + ")";
theWildcards << "hdr.adf";
}
else if ( myGdalDriverDescription == "HDF4" )
{
// HDF4 extension missing in driver metadata
QString glob = "*.hdf";
theFileFiltersString += ";;[GDAL] " + myGdalDriverLongName + " (" + glob.toLower() + " " + glob.toUpper() + ")";
theExtensions << "hdf";
}
else
{
catchallFilter << QString( GDALGetDescription( myGdalDriver ) );

0 comments on commit a2b80be

Please sign in to comment.