Skip to content

Commit e407cee

Browse files
author
telwertowski
committed
Fix raster file filter so that only the first JPEG2000 driver found is 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@5691 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent d94c4bb commit e407cee

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

src/raster/qgsrasterlayer.cpp

+17-12
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,9 @@ static const char *const mSupportedRasterFormats[] =
156156
"GRASS",
157157
"GTiff",
158158
"HFA",
159+
"JP2ECW",
160+
"JP2KAK",
161+
"JP2MrSID",
159162
"JPEG2000",
160163
"MrSID",
161164
"SDTS",
@@ -201,8 +204,9 @@ void QgsRasterLayer::buildSupportedRasterFileFilter(QString & theFileFiltersStri
201204
QStringList metadataTokens; // essentially the metadata string delimited by '='
202205

203206
QString catchallFilter; // for Any file(*.*), but also for those
204-
// drivers with no specific file
205-
// filter
207+
// drivers with no specific file filter
208+
209+
GDALDriver *jp2Driver = NULL; // first JPEG2000 driver found
206210

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

284299
break; // ... to next driver, if any.
@@ -324,16 +339,6 @@ void QgsRasterLayer::buildSupportedRasterFileFilter(QString & theFileFiltersStri
324339
catchallFilter += QString(myGdalDriver->GetDescription()) + " ";
325340
}
326341
}
327-
328-
// A number of drivers support JPEG 2000. Add it in for those.
329-
if ( myGdalDriverDescription.startsWith("MrSID")
330-
|| myGdalDriverDescription.startsWith("ECW")
331-
|| myGdalDriverDescription.startsWith("JPEG2000")
332-
|| myGdalDriverDescription.startsWith("JP2KAK") )
333-
{
334-
QString glob = "*.jp2 *.j2k";
335-
theFileFiltersString += "JPEG 2000 (" + glob.lower() + " " + glob.upper() + ");;";
336-
}
337342

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

0 commit comments

Comments
 (0)