Skip to content

Commit

Permalink
Merge pull request #41814 from agiudiceandrea/fix-gdalprovider-output…
Browse files Browse the repository at this point in the history
…rasterext

[processing] Fix output raster extensions list for GdalAlgorithmProvider
  • Loading branch information
nyalldawson authored and github-actions[bot] committed Feb 26, 2021
1 parent d7ff585 commit de8e368
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
Expand Up @@ -209,7 +209,7 @@ def loadAlgorithms(self):
self.addAlgorithm(a)

def supportedOutputRasterLayerExtensions(self):
return GdalUtils.getSupportedRasterExtensions()
return GdalUtils.getSupportedOutputRasterExtensions()

def supportsNonFileBasedOutput(self):
"""
Expand Down
20 changes: 12 additions & 8 deletions python/plugins/processing/algs/gdal/GdalUtils.py
Expand Up @@ -137,8 +137,8 @@ def getSupportedRasters():

GdalUtils.supportedRasters = {}
GdalUtils.supportedOutputRasters = {}
GdalUtils.supportedRasters['GTiff'] = ['tif']
GdalUtils.supportedOutputRasters['GTiff'] = ['tif']
GdalUtils.supportedRasters['GTiff'] = ['tif', 'tiff']
GdalUtils.supportedOutputRasters['GTiff'] = ['tif', 'tiff']

for i in range(gdal.GetDriverCount()):
driver = gdal.GetDriver(i)
Expand All @@ -150,8 +150,8 @@ def getSupportedRasters():
or metadata[gdal.DCAP_RASTER] != 'YES':
continue

if gdal.DMD_EXTENSION in metadata:
extensions = metadata[gdal.DMD_EXTENSION].split('/')
if gdal.DMD_EXTENSIONS in metadata:
extensions = metadata[gdal.DMD_EXTENSIONS].split(' ')
if extensions:
GdalUtils.supportedRasters[shortName] = extensions
# Only creatable rasters can be referenced in output rasters
Expand All @@ -177,20 +177,24 @@ def getSupportedOutputRasters():

@staticmethod
def getSupportedRasterExtensions():
allexts = ['tif']
allexts = []
for exts in list(GdalUtils.getSupportedRasters().values()):
for ext in exts:
if ext not in allexts and ext != '':
if ext not in allexts and ext not in ['', 'tif', 'tiff']:
allexts.append(ext)
allexts.sort()
allexts[0:0] = ['tif', 'tiff']
return allexts

@staticmethod
def getSupportedOutputRasterExtensions():
allexts = ['tif']
allexts = []
for exts in list(GdalUtils.getSupportedOutputRasters().values()):
for ext in exts:
if ext not in allexts and ext != '':
if ext not in allexts and ext not in ['', 'tif', 'tiff']:
allexts.append(ext)
allexts.sort()
allexts[0:0] = ['tif', 'tiff']
return allexts

@staticmethod
Expand Down

0 comments on commit de8e368

Please sign in to comment.