Skip to content

Commit

Permalink
Merge pull request #5426 from medspx/ProcessingPortGrass72
Browse files Browse the repository at this point in the history
[Processing] Port GRASS 7.2 algorithm provider
  • Loading branch information
nyalldawson committed Nov 8, 2017
2 parents e1ffb28 + da90477 commit cab807d
Show file tree
Hide file tree
Showing 393 changed files with 4,324 additions and 3,545 deletions.
36 changes: 31 additions & 5 deletions python/plugins/processing/algs/gdal/GdalUtils.py
Expand Up @@ -61,6 +61,7 @@ class GdalUtils(object):
GDAL_HELP_PATH = 'GDAL_HELP_PATH'

supportedRasters = None
supportedOutputRasters = None

@staticmethod
def runGdal(commands, feedback=None):
Expand Down Expand Up @@ -135,7 +136,10 @@ def getSupportedRasters():
gdal.AllRegister()

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

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

# ===================================================================
# if gdal.DCAP_CREATE not in metadata \
# or metadata[gdal.DCAP_CREATE] != 'YES':
# continue
# ===================================================================
if gdal.DMD_EXTENSION in metadata:
extensions = metadata[gdal.DMD_EXTENSION].split('/')
if extensions:
GdalUtils.supportedRasters[shortName] = extensions
# Only creatable rasters can be referenced in output rasters
if ((gdal.DCAP_CREATE in metadata
and metadata[gdal.DCAP_CREATE] == 'YES')
or (gdal.DCAP_CREATECOPY in metadata
and metadata[gdal.DCAP_CREATECOPY] == 'YES')):
GdalUtils.supportedOutputRasters[shortName] = extensions

return GdalUtils.supportedRasters

@staticmethod
def getSupportedOutputRasters():
if not gdalAvailable:
return {}

if GdalUtils.supportedOutputRasters is not None:
return GdalUtils.supportedOutputRasters
else:
GdalUtils.getSupportedRasters()

return GdalUtils.supportedOutputRasters

@staticmethod
def getSupportedRasterExtensions():
allexts = ['tif']
Expand All @@ -167,6 +184,15 @@ def getSupportedRasterExtensions():
allexts.append(ext)
return allexts

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

@staticmethod
def getVectorDriverFromFileName(filename):
ext = os.path.splitext(filename)[1]
Expand Down

0 comments on commit cab807d

Please sign in to comment.