Skip to content

Commit

Permalink
Restore gdal algorithm support
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Aug 13, 2017
1 parent 7768f06 commit 014833a
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions python/plugins/processing/algs/gdal/GdalAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@
import os
import re

from qgis.PyQt.QtCore import QUrl
from qgis.PyQt.QtCore import QUrl, QCoreApplication

from qgis.core import (QgsApplication,
QgsVectorFileWriter,
QgsProcessingUtils,
QgsProcessingAlgorithm,
QgsProject)

from processing.core.GeoAlgorithm import GeoAlgorithm
Expand All @@ -44,25 +45,28 @@
os.path.split(os.path.dirname(__file__))[0], os.pardir))


class GdalAlgorithm(GeoAlgorithm):
class GdalAlgorithm(QgsProcessingAlgorithm):

def __init__(self):
GeoAlgorithm.__init__(self)
super().__init__()

def icon(self):
return QgsApplication.getThemeIcon("/providerGdal.svg")

def svgIconPath(self):
return QgsApplication.iconPath("providerGdal.svg")

def createInstance(self, config={}):
return self.__class__()

def createCustomParametersWidget(self, parent):
return GdalAlgorithmDialog(self)

def getConsoleCommands(self, parameters):
return None

def processAlgorithm(self, parameters, context, feedback):
commands = self.getConsoleCommands(parameters)
commands = self.getConsoleCommands(parameters, context, feedback)
layers = QgsProcessingUtils.compatibleVectorLayers(QgsProject.instance())
supported = QgsVectorFileWriter.supportedFormatExtensions()
for i, c in enumerate(commands):
Expand All @@ -80,6 +84,12 @@ def processAlgorithm(self, parameters, context, feedback):
commands[i] = c
GdalUtils.runGdal(commands, feedback)

# auto generate outputs
results = {}
for o in self.outputDefinitions():
results[o.name()] = parameters[o.name()]
return results

def helpUrl(self):
helpPath = GdalUtils.gdalHelpPath()
if helpPath == '':
Expand All @@ -100,3 +110,8 @@ def commandName(self):
if name.endswith(".py"):
name = name[:-3]
return name

def tr(self, string, context=''):
if context == '':
context = self.__class__.__name__
return QCoreApplication.translate(context, string)

0 comments on commit 014833a

Please sign in to comment.