Skip to content
Permalink
Browse files

Merge pull request #2517 from rldhont/raster_open_adf

Open adf raster file as a directory
  • Loading branch information
rldhont committed Dec 7, 2015
2 parents 4f0b9dd + 564a063 commit 6035d98b4a2669616a0122c0c94dfbd87770164b
Showing with 17 additions and 11 deletions.
  1. +17 −11 src/app/qgisapp.cpp
@@ -4597,7 +4597,14 @@ bool QgisApp::openLayer( const QString & fileName, bool allowInteractive )
// try to load it as raster
if ( QgsRasterLayer::isValidRasterFileName( fileName ) )
{
ok = addRasterLayer( fileName, fileInfo.completeBaseName() );
// open .adf as a directory
if ( fileName.toLower().endsWith( ".adf" ) )
{
QString dirName = fileInfo.path();
ok = addRasterLayer( dirName, QFileInfo( dirName ).completeBaseName() );
}
else
ok = addRasterLayer( fileName, fileInfo.completeBaseName() );
}
// TODO - should we really call isValidRasterFileName() before addRasterLayer()
// this results in 2 calls to GDALOpen()
@@ -9866,7 +9873,13 @@ QgsRasterLayer* QgisApp::addRasterLayerPrivate(
// XXX ya know QgsRasterLayer can snip out the basename on its own;
// XXX why do we have to pass it in for it?
// ET : we may not be getting "normal" files here, so we still need the baseName argument
if ( providerKey.isEmpty() )
if ( !providerKey.isEmpty() && uri.toLower().endsWith( ".adf" ) )
{
QFileInfo fileInfo( uri );
QString dirName = fileInfo.path();
layer = new QgsRasterLayer( dirName, QFileInfo( dirName ).completeBaseName(), "gdal" );
}
else if ( providerKey.isEmpty() )
layer = new QgsRasterLayer( uri, baseName ); // fi.completeBaseName());
else
layer = new QgsRasterLayer( uri, baseName, providerKey );
@@ -9997,24 +10010,17 @@ bool QgisApp::addRasterLayers( QStringList const &theFileNameQStringList, bool g
if ( QgsRasterLayer::isValidRasterFileName( *myIterator, errMsg ) )
{
QFileInfo myFileInfo( *myIterator );
// get the directory the .adf file was in
QString myDirNameQString = myFileInfo.path();
//extract basename
QString myBaseNameQString = myFileInfo.completeBaseName();
//only allow one copy of a ai grid file to be loaded at a
//time to prevent the user selecting all adfs in 1 dir which
//actually represent 1 coverage,

// try to create the layer
QgsRasterLayer *layer = addRasterLayerPrivate( *myIterator, myBaseNameQString,
QgsRasterLayer *layer = addRasterLayerPrivate( *myIterator, myFileInfo.completeBaseName(),
QString(), guiWarning, true );
if ( layer && layer->isValid() )
{
//only allow one copy of a ai grid file to be loaded at a
//time to prevent the user selecting all adfs in 1 dir which
//actually represent 1 coverate,

if ( myBaseNameQString.toLower().endsWith( ".adf" ) )
if ( myFileInfo.fileName().toLower().endsWith( ".adf" ) )
{
break;
}

0 comments on commit 6035d98

Please sign in to comment.
You can’t perform that action at this time.