Skip to content
Permalink
Browse files

Merge pull request #3918 from alexbruy/processing-providers

Processing providers updates
  • Loading branch information
alexbruy committed Jan 5, 2017
2 parents 52b004a + c5835e9 commit 12ab928e4b4bb218ef69feca730e009bd6e926ab
Showing with 466 additions and 442 deletions.
  1. +4 −3 python/plugins/processing/algs/gdal/{GdalOgrAlgorithmProvider.py → GdalAlgorithmProvider.py}
  2. +4 −0 python/plugins/processing/algs/gdal/GdalUtils.py
  3. +1 −1 python/plugins/processing/algs/gdal/GridAverage.py
  4. +1 −1 python/plugins/processing/algs/gdal/GridDataMetrics.py
  5. +1 −1 python/plugins/processing/algs/gdal/GridInvDist.py
  6. +1 −1 python/plugins/processing/algs/gdal/GridNearest.py
  7. +1 −1 python/plugins/processing/algs/gdal/gdal2tiles.py
  8. +1 −1 python/plugins/processing/algs/gdal/gdaladdo.py
  9. +1 −1 python/plugins/processing/algs/gdal/information.py
  10. +3 −0 python/plugins/processing/algs/gdal/ogrinfo.py
  11. +1 −1 python/plugins/processing/algs/gdal/polygonize.py
  12. +1 −1 python/plugins/processing/algs/gdal/proximity.py
  13. +1 −1 python/plugins/processing/algs/gdal/rasterize.py
  14. +1 −1 python/plugins/processing/algs/gdal/rasterize_over.py
  15. +1 −1 python/plugins/processing/algs/gdal/retile.py
  16. +1 −1 python/plugins/processing/algs/gdal/translate.py
  17. +3 −2 python/plugins/processing/algs/grass7/Grass7AlgorithmProvider.py
  18. +38 −5 python/plugins/processing/algs/grass7/Grass7Utils.py
  19. +2 −1 python/plugins/processing/algs/otb/OTBAlgorithmProvider.py
  20. +1 −1 python/plugins/processing/algs/qgis/QGISAlgorithmProvider.py
  21. +3 −3 python/plugins/processing/algs/saga/SagaAlgorithmProvider.py
  22. +1 −1 python/plugins/processing/algs/saga/SagaUtils.py
  23. +1 −1 python/plugins/processing/core/Processing.py
  24. +17 −17 python/plugins/processing/gui/algnames.txt
  25. +31 −31 python/plugins/processing/gui/menus.py
  26. +1 −1 python/plugins/processing/tests/AlgorithmsTestBase.py
  27. +334 −19 python/plugins/processing/tests/testdata/gdal_algorithm_tests.yaml
  28. +0 −342 python/plugins/processing/tests/testdata/qgis_algorithm_tests.yaml
  29. +10 −2 tests/testdata/landsat_4326.tif.aux.xml
@@ -86,7 +86,7 @@
os.path.split(os.path.dirname(__file__))[0], os.pardir))


class GdalOgrAlgorithmProvider(AlgorithmProvider):
class GdalAlgorithmProvider(AlgorithmProvider):

"""This provider incorporates GDAL-based algorithms into the
Processing framework.
@@ -100,10 +100,11 @@ def __init__(self):
self.createAlgsList()

def getDescription(self):
return self.tr('GDAL/OGR')
version = GdalUtils.readableVersion()
return 'GDAL ({})'.format(version)

def getName(self):
return 'gdalogr'
return 'gdal'

def getIcon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdal.svg'))
@@ -186,3 +186,7 @@ def escapeAndJoin(strList):
@staticmethod
def version():
return int(gdal.VersionInfo('VERSION_NUM'))

@staticmethod
def readableVersion():
return gdal.VersionInfo('RELEASE_NAME')
@@ -60,7 +60,7 @@ def getIcon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'grid.png'))

def commandLineName(self):
return "gdalogr:gridaverage"
return "gdal:gridaverage"

def defineCharacteristics(self):
self.name, self.i18n_name = self.trAlgorithm('Grid (Moving average)')
@@ -65,7 +65,7 @@ def getIcon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'grid.png'))

def commandLineName(self):
return "gdalogr:griddatametrics"
return "gdal:griddatametrics"

def defineCharacteristics(self):
self.name, self.i18n_name = self.trAlgorithm('Grid (Data metrics)')
@@ -64,7 +64,7 @@ def getIcon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'grid.png'))

def commandLineName(self):
return "gdalogr:gridinvdist"
return "gdal:gridinvdist"

def defineCharacteristics(self):
self.name, self.i18n_name = self.trAlgorithm('Grid (Inverse distance to a power)')
@@ -60,7 +60,7 @@ def getIcon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'grid.png'))

def commandLineName(self):
return "gdalogr:gridnearestneighbor"
return "gdal:gridnearestneighbor"

def defineCharacteristics(self):
self.name, self.i18n_name = self.trAlgorithm('Grid (Nearest neighbor)')
@@ -61,7 +61,7 @@ class gdal2tiles(GdalAlgorithm):
WEBVIEWERS = ['all', 'google', 'openlayers', 'leaflet', 'none']

def commandLineName(self):
return "gdalogr:gdal2tiles"
return "gdal:gdal2tiles"

def defineCharacteristics(self):
self.name, self.i18n_name = self.trAlgorithm('gdal2tiles')
@@ -67,7 +67,7 @@ def getIcon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'raster-overview.png'))

def commandLineName(self):
return "gdalogr:overviews"
return "gdal:overviews"

def defineCharacteristics(self):
self.name, self.i18n_name = self.trAlgorithm('Build overviews (pyramids)')
@@ -50,7 +50,7 @@ def getIcon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'raster-info.png'))

def commandLineName(self):
return "gdalorg:rasterinfo"
return "gdal:gdalinfo"

def defineCharacteristics(self):
self.name, self.i18n_name = self.trAlgorithm('Information')
@@ -43,6 +43,9 @@ class OgrInfo(GdalAlgorithm):
SUMMARY_ONLY = 'SUMMARY_ONLY'
OUTPUT = 'OUTPUT'

def commandLineName(self):
return "gdal:ogrinfo"

def defineCharacteristics(self):
self.name, self.i18n_name = self.trAlgorithm('Information')
self.group, self.i18n_group = self.trAlgorithm('[OGR] Miscellaneous')
@@ -50,7 +50,7 @@ def getIcon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'polygonize.png'))

def commandLineName(self):
return "gdalogr:polygonize"
return "gdal:polygonize"

def defineCharacteristics(self):
self.name, self.i18n_name = self.trAlgorithm('Polygonize (raster to vector)')
@@ -61,7 +61,7 @@ def getIcon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'proximity.png'))

def commandLineName(self):
return "gdalogr:proximity"
return "gdal:proximity"

def defineCharacteristics(self):
self.name, self.i18n_name = self.trAlgorithm('Proximity (raster distance)')
@@ -74,7 +74,7 @@ def getIcon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'rasterize.png'))

def commandLineName(self):
return "gdalogr:rasterize"
return "gdal:rasterize"

def defineCharacteristics(self):
self.name, self.i18n_name = self.trAlgorithm('Rasterize (vector to raster)')
@@ -52,7 +52,7 @@ def getIcon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'rasterize.png'))

def commandLineName(self):
return "gdalogr:rasterize_over"
return "gdal:rasterize_over"

def defineCharacteristics(self):
self.name, self.i18n_name = self.trAlgorithm('Rasterize (write over existing raster)')
@@ -61,7 +61,7 @@ class retile(GdalAlgorithm):
ALGO = ['near', 'bilinear', 'cubic', 'cubicspline', 'lanczos']

def commandLineName(self):
return "gdalogr:retile"
return "gdal:retile"

def commandName(self):
return "gdal_retile"
@@ -73,7 +73,7 @@ def getIcon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'translate.png'))

def commandLineName(self):
return "gdalogr:translate"
return "gdal:translate"

def defineCharacteristics(self):
self.name, self.i18n_name = self.trAlgorithm('Translate (convert format)')
@@ -92,10 +92,11 @@ def _loadAlgorithms(self):
self.algs = self.preloadedAlgs

def getDescription(self):
return self.tr('GRASS GIS 7 commands')
version = Grass7Utils.installedVersion()
return 'GRASS GIS ({})'.format(version) if version is not None else "GRASS GIS"

def getName(self):
return 'grass70'
return 'grass7'

def getIcon(self):
return QIcon(os.path.join(pluginPath, 'images', 'grass.svg'))
@@ -35,6 +35,7 @@
from qgis.PyQt.QtCore import QCoreApplication
from processing.core.ProcessingConfig import ProcessingConfig
from processing.core.ProcessingLog import ProcessingLog
from processing.core.SilentProgress import SilentProgress
from processing.tools.system import userFolder, isWindows, isMac, tempFolder, mkdir
from processing.tests.TestData import points

@@ -56,6 +57,8 @@ class Grass7Utils(object):

isGrass7Installed = False

version = None

@staticmethod
def grassBatchJobFilename():
'''This is used in Linux. This is the batch job that we assign to
@@ -74,11 +77,41 @@ def grassScriptFilename():
filename = os.path.join(userFolder(), filename)
return filename

#~ @staticmethod
#~ def installedVersion():
#~ out = Grass7Utils.executeGrass7("grass -v")
#~ # FIXME: I do not know if this should be removed or let the user enter it
#~ # or something like that... This is just a temporary thing
#~ return '7.0.0'


@staticmethod
def getGrassVersion():
# FIXME: I do not know if this should be removed or let the user enter it
# or something like that... This is just a temporary thing
return '7.0.0'
def installedVersion(run=False):
if Grass7Utils.isGrass7Installed and not run:
return Grass7Utils.version

if Grass7Utils.grassPath() is None:
return None
commands = ["grass70 -v"]
with subprocess.Popen(
commands,
shell=True,
stdout=subprocess.PIPE,
stdin=subprocess.DEVNULL,
stderr=subprocess.STDOUT,
universal_newlines=True,
) as proc:
try:
lines = proc.stdout.readlines()
for line in lines:
if "GRASS GIS " in line:
Grass7Utils.version = line.split(" ")[-1].strip()
break
except:
pass

return Grass7Utils.version


@staticmethod
def grassPath():
@@ -140,7 +173,7 @@ def createGrass7Script(commands):
output.write('if "%GRASS_ADDON_PATH%"=="" set PATH=%WINGISBASE%\\bin;%WINGISBASE%\\lib;%PATH%\n')
output.write('if not "%GRASS_ADDON_PATH%"=="" set PATH=%WINGISBASE%\\bin;%WINGISBASE%\\lib;%GRASS_ADDON_PATH%;%PATH%\n')
output.write('\n')
output.write('set GRASS_VERSION=' + Grass7Utils.getGrassVersion() + '\n')
output.write('set GRASS_VERSION=' + Grass7Utils.installedVersion() + '\n')
output.write('if not "%LANG%"=="" goto langset\n')
output.write('FOR /F "usebackq delims==" %%i IN (`"%WINGISBASE%\\etc\\winlocale"`) DO @set LANG=%%i\n')
output.write(':langset\n')
@@ -48,7 +48,8 @@ def __init__(self):
self.activate = True

def getDescription(self):
return self.tr("Orfeo Toolbox (Image analysis)")
version = OTBUtils.getInstalledVersion()
return "Orfeo ToolBox ({})".format(version) if version is not None else "Orfeo ToolBox"

def getName(self):
return "otb"
@@ -300,7 +300,7 @@ def getName(self):
return 'qgis'

def getDescription(self):
return self.tr('QGIS geoalgorithms')
return 'QGIS'

def getIcon(self):
return self._icon
@@ -86,7 +86,7 @@ def unload(self):

def _loadAlgorithms(self):
self.algs = []
version = SagaUtils.getSagaInstalledVersion(True)
version = SagaUtils.getInstalledVersion(True)
if version is None:
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
self.tr('Problem with SAGA installation: SAGA was not found or is not correctly installed'))
@@ -121,8 +121,8 @@ def _loadAlgorithm(self, descriptionFile, version):
self.tr('Could not open SAGA algorithm: %s\n%s' % (descriptionFile, str(e))))

def getDescription(self):
version = SagaUtils.getSagaInstalledVersion()
return 'SAGA (%s)' % version if version is not None else 'SAGA'
version = SagaUtils.getInstalledVersion()
return 'SAGA ({})'.format(version) if version is not None else 'SAGA'

def getName(self):
return 'saga'
@@ -112,7 +112,7 @@ def createSagaBatchJobFileFromSagaCommands(commands):
_installedVersionFound = False


def getSagaInstalledVersion(runSaga=False):
def getInstalledVersion(runSaga=False):
global _installedVersion
global _installedVersionFound

@@ -57,7 +57,7 @@
from processing.algs.qgis.QGISAlgorithmProvider import QGISAlgorithmProvider
from processing.algs.grass7.Grass7AlgorithmProvider import Grass7AlgorithmProvider
from processing.algs.lidar.LidarToolsAlgorithmProvider import LidarToolsAlgorithmProvider
from processing.algs.gdal.GdalOgrAlgorithmProvider import GdalOgrAlgorithmProvider
from processing.algs.gdal.GdalAlgorithmProvider import GdalAlgorithmProvider
from processing.algs.otb.OTBAlgorithmProvider import OTBAlgorithmProvider
from processing.algs.r.RAlgorithmProvider import RAlgorithmProvider
from processing.algs.saga.SagaAlgorithmProvider import SagaAlgorithmProvider
@@ -1,20 +1,20 @@
gdalogr:executesql,Execute SQL on vector layer
gdalogr:rasterinfo,Raster layer information
gdalogr:merge,Merge raster layers
gdalogr:ogr2ogr,Export vector layer
gdalogr:vectorinfo,Vector layer information
gdalogr:pcttorgb,PCT to RGB
gdalogr:rgbtopct,RGB to PCT
gdalogr:sieve,Remove small pixel clumps (nearest neighbour)
gdalogr:translate,Export raster layer
gdalogr:warpreproject,Reproject raster layer
gdalogr:polygonize,Vectorize raster layer
gdalogr:gridrasterize,Rasterize vector layer
gdalogr:gridnearestneighbor,Interpolate (Nearest Neighbor)
gdalogr:griddatametrics,Interpolate (Data metrics)
gdalogr:gridinvdist,Interpolate (Inverse distance weighting)
gdalogr:gridaverage,Interpolate (Average)
gdalogr:contour,Contour lines
gdal:executesql,Execute SQL on vector layer
gdal:rasterinfo,Raster layer information
gdal:merge,Merge raster layers
gdal:ogr2ogr,Export vector layer
gdal:vectorinfo,Vector layer information
gdal:pcttorgb,PCT to RGB
gdal:rgbtopct,RGB to PCT
gdal:sieve,Remove small pixel clumps (nearest neighbour)
gdal:translate,Export raster layer
gdal:warpreproject,Reproject raster layer
gdal:polygonize,Vectorize raster layer
gdal:gridrasterize,Rasterize vector layer
gdal:gridnearestneighbor,Interpolate (Nearest Neighbor)
gdal:griddatametrics,Interpolate (Data metrics)
gdal:gridinvdist,Interpolate (Inverse distance weighting)
gdal:gridaverage,Interpolate (Average)
gdal:contour,Contour lines
qgis:creategrid,Create graticule
saga:changegridvalues,Reclassify (simple)
saga:creategraticule,Create graticule from extent

0 comments on commit 12ab928

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