Skip to content
Permalink
Browse files

[processing] drop GdalScriptAlgorithm as it is not used

Also remove OgrAlgorithm base class at it almost completely duplicates
GdalAlgorithm class. All affected algorithms updated accordingly.
  • Loading branch information
alexbruy committed Jan 22, 2016
1 parent ac22e9b commit 9193d8f5a073649d9497e551120e7ee1945827b8
@@ -36,13 +36,14 @@

from processing.core.outputs import OutputRaster

from processing.algs.gdal.OgrAlgorithm import OgrAlgorithm
from processing.algs.gdal.GdalAlgorithm import GdalAlgorithm
from processing.algs.gdal.GdalUtils import GdalUtils

from processing.tools import dataobjects
from processing.tools.vector import ogrConnectionString


class ClipByMask(OgrAlgorithm):
class ClipByMask(GdalAlgorithm):

INPUT = 'INPUT'
OUTPUT = 'OUTPUT'
@@ -114,7 +115,7 @@ def getConsoleCommands(self):
mask = self.getParameterValue(self.MASK)
maskLayer = dataobjects.getObjectFromUri(
self.getParameterValue(self.MASK))
ogrMask = self.ogrConnectionString(mask)[1:-1]
ogrMask = ogrConnectionString(mask)[1:-1]
noData = unicode(self.getParameterValue(self.NO_DATA))
addAlphaBand = self.getParameterValue(self.ALPHA_BAND)
cropToCutline = self.getParameterValue(self.CROP_TO_CUTLINE)
@@ -27,8 +27,9 @@
__revision__ = '$Format:%H$'

import os

from PyQt4.QtGui import QIcon
from processing.script.ScriptAlgorithm import ScriptAlgorithm

from processing.core.GeoAlgorithm import GeoAlgorithm
from processing.algs.gdal.GdalAlgorithmDialog import GdalAlgorithmDialog
from processing.algs.gdal.GdalUtils import GdalUtils
@@ -64,12 +65,3 @@ def commandName(self):
if name.endswith(".py"):
name = name[:-3]
return name


class GdalScriptAlgorithm(ScriptAlgorithm):

def getIcon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdal.png'))

def getCustomParametersDialog(self):
return GdalAlgorithmDialog(self)
@@ -30,8 +30,6 @@

from processing.core.AlgorithmProvider import AlgorithmProvider
from processing.core.ProcessingLog import ProcessingLog
from processing.script.WrongScriptException import WrongScriptException
from processing.algs.gdal.GdalAlgorithm import GdalScriptAlgorithm
from GdalUtils import GdalUtils

from nearblack import nearblack
@@ -95,27 +93,14 @@ class GdalOgrAlgorithmProvider(AlgorithmProvider):
"""This provider incorporates GDAL-based algorithms into the
Processing framework.
Algorithms have been implemented using two different mechanisms,
which should serve as an example of different ways of extending
the processing capabilities of QGIS:
1. when a python script exist for a given process, it has been
adapted as a Processing python script and loaded using the
ScriptAlgorithm class. This algorithms call GDAL using its
Python bindings.
2. Other algorithms are called directly using the command line
interface. These have been implemented individually extending
the GeoAlgorithm class.
Algorithms are called directly using the command line interface.
They implemented individually extending GeoAlgorithm class.
"""

def __init__(self):
AlgorithmProvider.__init__(self)
self.createAlgsList()

def scriptsFolder(self):
"""The folder where script algorithms are stored.
"""
return os.path.dirname(__file__) + '/scripts'

def getDescription(self):
return self.tr('GDAL/OGR')

@@ -147,18 +132,5 @@ def createAlgsList(self):
Ogr2OgrTableToPostGisList(), OgrSql(),
]

# And then we add those that are created as python scripts
folder = self.scriptsFolder()
if os.path.exists(folder):
for descriptionFile in os.listdir(folder):
if descriptionFile.endswith('py'):
try:
fullpath = os.path.join(self.scriptsFolder(),
descriptionFile)
alg = GdalScriptAlgorithm(fullpath)
self.preloadedAlgs.append(alg)
except WrongScriptException as e:
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR, e.msg)

def getSupportedOutputRasterLayerExtensions(self):
return GdalUtils.getSupportedRasterExtensions()

This file was deleted.

@@ -32,10 +32,12 @@
from processing.core.parameters import ParameterSelection
from processing.core.outputs import OutputVector

from processing.algs.gdal.GdalAlgorithm import GdalAlgorithm
from processing.algs.gdal.GdalUtils import GdalUtils

from processing.tools.system import isWindows
from processing.tools.vector import ogrConnectionString, ogrLayerName

from processing.algs.gdal.OgrAlgorithm import OgrAlgorithm
from processing.algs.gdal.GdalUtils import GdalUtils

FORMATS = [
'ESRI Shapefile',
@@ -88,7 +90,7 @@
]


class Ogr2Ogr(OgrAlgorithm):
class Ogr2Ogr(GdalAlgorithm):

OUTPUT_LAYER = 'OUTPUT_LAYER'
INPUT_LAYER = 'INPUT_LAYER'
@@ -110,7 +112,7 @@ def defineCharacteristics(self):

def getConsoleCommands(self):
inLayer = self.getParameterValue(self.INPUT_LAYER)
ogrLayer = self.ogrConnectionString(inLayer)[1:-1]
ogrLayer = ogrConnectionString(inLayer)[1:-1]

output = self.getOutputFromName(self.OUTPUT_LAYER)
outFile = output.value
@@ -136,7 +138,7 @@ def getConsoleCommands(self):

arguments.append(output)
arguments.append(ogrLayer)
arguments.append(self.ogrLayerName(inLayer))
arguments.append(ogrLayerName(inLayer))

commands = []
if isWindows():
@@ -32,13 +32,14 @@
from processing.core.parameters import ParameterTableField
from processing.core.outputs import OutputVector

from processing.tools.system import isWindows

from processing.algs.gdal.OgrAlgorithm import OgrAlgorithm
from processing.algs.gdal.GdalAlgorithm import GdalAlgorithm
from processing.algs.gdal.GdalUtils import GdalUtils

from processing.tools.system import isWindows
from processing.tools.vector import ogrConnectionString, ogrLayerName


class Ogr2OgrBuffer(OgrAlgorithm):
class Ogr2OgrBuffer(GdalAlgorithm):

OUTPUT_LAYER = 'OUTPUT_LAYER'
INPUT_LAYER = 'INPUT_LAYER'
@@ -74,8 +75,8 @@ def defineCharacteristics(self):

def getConsoleCommands(self):
inLayer = self.getParameterValue(self.INPUT_LAYER)
ogrLayer = self.ogrConnectionString(inLayer)[1:-1]
layername = "'" + self.ogrLayerName(inLayer) + "'"
ogrLayer = ogrConnectionString(inLayer)[1:-1]
layername = "'" + ogrLayerName(inLayer) + "'"
geometry = unicode(self.getParameterValue(self.GEOMETRY))
distance = unicode(self.getParameterValue(self.DISTANCE))
dissolveall = self.getParameterValue(self.DISSOLVEALL)
@@ -85,13 +86,13 @@ def getConsoleCommands(self):
output = self.getOutputFromName(self.OUTPUT_LAYER)
outFile = output.value

output = self.ogrConnectionString(outFile)
output = ogrConnectionString(outFile)
options = unicode(self.getParameterValue(self.OPTIONS))

arguments = []
arguments.append(output)
arguments.append(ogrLayer)
arguments.append(self.ogrLayerName(inLayer))
arguments.append(ogrLayerName(inLayer))
if dissolveall or field != 'None':
arguments.append('-dialect sqlite -sql "SELECT ST_Union(ST_Buffer(')
else:
@@ -29,13 +29,14 @@
from processing.core.parameters import ParameterString
from processing.core.outputs import OutputVector

from processing.tools.system import isWindows

from processing.algs.gdal.OgrAlgorithm import OgrAlgorithm
from processing.algs.gdal.GdalAlgorithm import GdalAlgorithm
from processing.algs.gdal.GdalUtils import GdalUtils

from processing.tools.system import isWindows
from processing.tools.vector import ogrConnectionString, ogrLayerName


class Ogr2OgrClip(OgrAlgorithm):
class Ogr2OgrClip(GdalAlgorithm):

OUTPUT_LAYER = 'OUTPUT_LAYER'
INPUT_LAYER = 'INPUT_LAYER'
@@ -57,27 +58,27 @@ def defineCharacteristics(self):

def getConsoleCommands(self):
inLayer = self.getParameterValue(self.INPUT_LAYER)
ogrLayer = self.ogrConnectionString(inLayer)[1:-1]
ogrLayer = ogrConnectionString(inLayer)[1:-1]
clipLayer = self.getParameterValue(self.CLIP_LAYER)
ogrClipLayer = self.ogrConnectionString(clipLayer)[1:-1]
ogrClipLayer = ogrConnectionString(clipLayer)[1:-1]

output = self.getOutputFromName(self.OUTPUT_LAYER)
outFile = output.value

output = self.ogrConnectionString(outFile)
output = ogrConnectionString(outFile)
options = unicode(self.getParameterValue(self.OPTIONS))

arguments = []
arguments.append('-clipsrc')
arguments.append(ogrClipLayer)
arguments.append("-clipsrclayer")
arguments.append(self.ogrLayerName(clipLayer))
arguments.append(ogrLayerName(clipLayer))
if len(options) > 0:
arguments.append(options)

arguments.append(output)
arguments.append(ogrLayer)
arguments.append(self.ogrLayerName(inLayer))
arguments.append(ogrLayerName(inLayer))

commands = []
if isWindows():

0 comments on commit 9193d8f

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