Skip to content
Permalink
Browse files

Merge pull request #5426 from medspx/ProcessingPortGrass72

[Processing] Port GRASS 7.2 algorithm provider
  • Loading branch information
nyalldawson committed Nov 8, 2017
2 parents e1ffb28 + da90477 commit cab807dc309067dcb72b6b052f0608c88755af91
Showing 393 changed files with 4,324 additions and 3,545 deletions.
@@ -61,6 +61,7 @@ class GdalUtils(object):
GDAL_HELP_PATH = 'GDAL_HELP_PATH'

supportedRasters = None
supportedOutputRasters = None

@staticmethod
def runGdal(commands, feedback=None):
@@ -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:
@@ -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']
@@ -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]

0 comments on commit cab807d

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