Skip to content

Commit

Permalink
Fix raster file filter so that only the first JPEG2000 driver found i…
Browse files Browse the repository at this point in the history
…s added to the list; this is the one GDAL uses. Use the driver's name rather than "JPEG 2000" so that the user knows which one is being used.

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@5691 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
telwertowski committed Aug 12, 2006
1 parent 085284a commit 2b686f4
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions src/raster/qgsrasterlayer.cpp
Expand Up @@ -156,6 +156,9 @@ static const char *const mSupportedRasterFormats[] =
"GRASS",
"GTiff",
"HFA",
"JP2ECW",
"JP2KAK",
"JP2MrSID",
"JPEG2000",
"MrSID",
"SDTS",
Expand Down Expand Up @@ -201,8 +204,9 @@ void QgsRasterLayer::buildSupportedRasterFileFilter(QString & theFileFiltersStri
QStringList metadataTokens; // essentially the metadata string delimited by '='

QString catchallFilter; // for Any file(*.*), but also for those
// drivers with no specific file
// filter
// drivers with no specific file filter

GDALDriver *jp2Driver = NULL; // first JPEG2000 driver found

// Grind through all the drivers and their respective metadata.
// We'll add a file filter for those drivers that have a file
Expand Down Expand Up @@ -279,6 +283,17 @@ void QgsRasterLayer::buildSupportedRasterFileFilter(QString & theFileFiltersStri
{
// XXX add check for SDTS; in that case we want (*CATD.DDF)
QString glob = "*." + myGdalDriverExtension;
// Add only the first JP2 driver found to the filter list (it's the one GDAL uses)
if (myGdalDriverDescription == "JPEG2000" ||
myGdalDriverDescription.startsWith("JP2")) // JP2ECW, JP2KAK, JP2MrSID
{
if (!jp2Driver)
{
jp2Driver = myGdalDriver; // first JP2 driver found
glob += " *.j2k"; // add alternate extension
}
else break; // skip if already found a JP2 driver
}
theFileFiltersString += myGdalDriverLongName + " (" + glob.lower() + " " + glob.upper() + ");;";

break; // ... to next driver, if any.
Expand Down Expand Up @@ -324,16 +339,6 @@ void QgsRasterLayer::buildSupportedRasterFileFilter(QString & theFileFiltersStri
catchallFilter += QString(myGdalDriver->GetDescription()) + " ";
}
}

// A number of drivers support JPEG 2000. Add it in for those.
if ( myGdalDriverDescription.startsWith("MrSID")
|| myGdalDriverDescription.startsWith("ECW")
|| myGdalDriverDescription.startsWith("JPEG2000")
|| myGdalDriverDescription.startsWith("JP2KAK") )
{
QString glob = "*.jp2 *.j2k";
theFileFiltersString += "JPEG 2000 (" + glob.lower() + " " + glob.upper() + ");;";
}

myGdalDriverExtension = myGdalDriverLongName = ""; // reset for next driver

Expand Down

0 comments on commit 2b686f4

Please sign in to comment.