Skip to content
Permalink
Browse files

Merge branch 'processing_parameters_refactoring' of https://github.co…

…m/volaya/QGIS into processing_parameters_refactoring
  • Loading branch information
alexbruy committed Oct 10, 2016
2 parents 6d2ab9e + fba87f7 commit 4292c46ca9ad35efbf5f3ed7052867c6a5fa3723
Showing with 2,263 additions and 3,050 deletions.
  1. +1 −5 python/plugins/processing/algs/gdal/GdalAlgorithmDialog.py
  2. +1 −1 python/plugins/processing/algs/gdal/GdalUtils.py
  3. +1 −1 python/plugins/processing/algs/gdal/gdal2tiles.py
  4. +6 −7 python/plugins/processing/algs/grass/GrassAlgorithm.py
  5. +2 −6 python/plugins/processing/algs/grass7/Grass7Algorithm.py
  6. +1 −1 python/plugins/processing/algs/grass7/ext/i.py
  7. +1 −1 python/plugins/processing/algs/grass7/ext/v_net.py
  8. +1 −1 python/plugins/processing/algs/help/__init__.py
  9. +1 −1 python/plugins/processing/algs/lidar/fusion/ClipData.py
  10. +2 −2 python/plugins/processing/algs/lidar/lastools/lasquery.py
  11. +2 −1 python/plugins/processing/algs/otb/OTBAlgorithm.py
  12. +1 −0 python/plugins/processing/algs/otb/maintenance/parsing.py
  13. +1 −1 python/plugins/processing/algs/qgis/ConcaveHull.py
  14. +1 −0 python/plugins/processing/algs/qgis/Delaunay.py
  15. +13 −9 python/plugins/processing/algs/qgis/DeleteColumn.py
  16. +1 −1 python/plugins/processing/algs/qgis/DeleteDuplicateGeometries.py
  17. +1 −0 python/plugins/processing/algs/qgis/Difference.py
  18. +3 −3 python/plugins/processing/algs/qgis/Dissolve.py
  19. +1 −0 python/plugins/processing/algs/qgis/ExtractByLocation.py
  20. +0 −5 python/plugins/processing/algs/qgis/FieldsCalculator.py
  21. +0 −8 python/plugins/processing/algs/qgis/FieldsMapper.py
  22. +1 −1 python/plugins/processing/algs/qgis/GridLine.py
  23. +1 −1 python/plugins/processing/algs/qgis/GridPolygon.py
  24. +1 −0 python/plugins/processing/algs/qgis/HubDistanceLines.py
  25. +1 −0 python/plugins/processing/algs/qgis/HubDistancePoints.py
  26. +1 −1 python/plugins/processing/algs/qgis/HypsometricCurves.py
  27. +1 −0 python/plugins/processing/algs/qgis/Intersection.py
  28. +1 −0 python/plugins/processing/algs/qgis/LinesIntersection.py
  29. +1 −1 python/plugins/processing/algs/qgis/MeanCoords.py
  30. +1 −0 python/plugins/processing/algs/qgis/NearestNeighbourAnalysis.py
  31. +1 −0 python/plugins/processing/algs/qgis/PointDistance.py
  32. +2 −1 python/plugins/processing/algs/qgis/PointsDisplacement.py
  33. +1 −1 python/plugins/processing/algs/qgis/PointsToPaths.py
  34. +1 −1 python/plugins/processing/algs/qgis/RandomExtract.py
  35. +1 −0 python/plugins/processing/algs/qgis/RandomPointsAlongLines.py
  36. +1 −1 python/plugins/processing/algs/qgis/RandomPointsExtent.py
  37. +1 −0 python/plugins/processing/algs/qgis/RandomPointsLayer.py
  38. +1 −2 python/plugins/processing/algs/qgis/RandomSelection.py
  39. +0 −1 python/plugins/processing/algs/qgis/RandomSelectionWithinSubsets.py
  40. +1 −1 python/plugins/processing/algs/qgis/RegularPoints.py
  41. +1 −0 python/plugins/processing/algs/qgis/SelectByAttributeSum.py
  42. +1 −0 python/plugins/processing/algs/qgis/SelectByLocation.py
  43. +0 −1 python/plugins/processing/algs/qgis/SetVectorStyle.py
  44. +1 −0 python/plugins/processing/algs/qgis/SplitLinesWithLines.py
  45. +1 −0 python/plugins/processing/algs/qgis/SumLines.py
  46. +1 −0 python/plugins/processing/algs/qgis/Union.py
  47. +1 −1 python/plugins/processing/algs/qgis/VectorGridPolygons.py
  48. +2 −1 python/plugins/processing/algs/qgis/VoronoiPolygons.py
  49. +4 −0 python/plugins/processing/algs/qgis/fieldsmapping.py
  50. +0 −144 python/plugins/processing/algs/qgis/ui/FieldsMapperDialogs.py
  51. +37 −4 python/plugins/processing/algs/qgis/ui/FieldsMappingPanel.py
  52. +1 −0 python/plugins/processing/algs/qgis/voronoi.py
  53. +11 −122 python/plugins/processing/algs/r/RAlgorithm.py
  54. +1 −1 python/plugins/processing/algs/saga/SagaAlgorithm212.py
  55. +18 −101 python/plugins/processing/core/GeoAlgorithm.py
  56. +0 −1 python/plugins/processing/core/Processing.py
  57. +1 −1 python/plugins/processing/core/ProcessingLog.py
  58. +125 −39 python/plugins/processing/core/outputs.py
  59. +583 −120 python/plugins/processing/core/parameters.py
  60. +19 −105 python/plugins/processing/gui/AlgorithmDialog.py
  61. +8 −2 python/plugins/processing/gui/AlgorithmDialogBase.py
  62. +16 −9 python/plugins/processing/gui/BatchAlgorithmDialog.py
  63. +41 −20 python/plugins/processing/gui/BatchInputSelectionPanel.py
  64. +0 −2 python/plugins/processing/gui/BatchOutputSelectionPanel.py
  65. +41 −146 python/plugins/processing/gui/BatchPanel.py
  66. +4 −2 python/plugins/processing/gui/CrsSelectionPanel.py
  67. +10 −9 python/plugins/processing/gui/ExtentSelectionPanel.py
  68. +10 −1 python/plugins/processing/gui/InputLayerSelectorPanel.py
  69. +1 −1 python/plugins/processing/gui/LexerR.py
  70. +0 −153 python/plugins/processing/gui/NumberInputDialog.py
  71. +72 −97 python/plugins/processing/gui/NumberInputPanel.py
  72. +9 −46 python/plugins/processing/gui/OutputSelectionPanel.py
  73. +28 −350 python/plugins/processing/gui/ParametersPanel.py
  74. +2 −2 python/plugins/processing/gui/ProcessingToolbox.py
  75. +1 −1 python/plugins/processing/gui/ScriptEditorDialog.py
  76. +74 −0 python/plugins/processing/gui/StringInputPanel.py
  77. +867 −0 python/plugins/processing/gui/wrappers.py
  78. +0 −145 python/plugins/processing/modeler/CalculatorModelerAlgorithm.py
  79. +48 −133 python/plugins/processing/modeler/ModelerAlgorithm.py
  80. +1 −1 python/plugins/processing/modeler/ModelerAlgorithmProvider.py
  81. +8 −4 python/plugins/processing/modeler/ModelerDialog.py
  82. +0 −61 python/plugins/processing/modeler/ModelerOnlyAlgorithmProvider.py
  83. +90 −145 python/plugins/processing/modeler/ModelerParameterDefinitionDialog.py
  84. +29 −435 python/plugins/processing/modeler/ModelerParametersDialog.py
  85. +8 −5 python/plugins/processing/modeler/ModelerScene.py
  86. +0 −66 python/plugins/processing/modeler/RasterLayerBoundsAlgorithm.py
  87. +0 −51 python/plugins/processing/modeler/RasterLayerCrsAlgorithm.py
  88. +0 −66 python/plugins/processing/modeler/VectorLayerBoundsAlgorithm.py
  89. +0 −51 python/plugins/processing/modeler/VectorLayerCrsAlgorithm.py
  90. +2 −2 python/plugins/processing/preconfigured/PreconfiguredAlgorithm.py
  91. +5 −2 python/plugins/processing/preconfigured/PreconfiguredAlgorithmDialog.py
  92. +3 −212 python/plugins/processing/script/ScriptAlgorithm.py
  93. +1 −1 python/plugins/processing/script/ScriptSelector.py
  94. +6 −5 python/plugins/processing/tests/AlgorithmsTestBase.py
  95. +1 −58 python/plugins/processing/tests/ParametersTest.py
  96. +8 −0 python/plugins/processing/tools/dataobjects.py
  97. +1 −1 python/plugins/processing/tools/translation.py
  98. +0 −58 python/plugins/processing/ui/widgetNumberSelector.ui
@@ -41,8 +41,7 @@ def __init__(self, alg):

self.alg = alg

self.mainWidget = GdalParametersPanel(self, alg)
self.setMainWidget()
self.setMainWidget(GdalParametersPanel(self, alg))

cornerWidget = QWidget()
layout = QVBoxLayout()
@@ -56,9 +55,6 @@ def __init__(self, alg):

self.mainWidget.parametersHaveChanged()

QgsMapLayerRegistry.instance().layerWasAdded.connect(self.mainWidget.layerAdded)
QgsMapLayerRegistry.instance().layersWillBeRemoved.connect(self.mainWidget.layersWillBeRemoved)


class GdalParametersPanel(ParametersPanel):

@@ -155,7 +155,7 @@ def getVectorDriverFromFileName(filename):
return 'ESRI Shapefile'

formats = QgsVectorFileWriter.supportedFiltersAndFormats()
for k, v in formats.items():
for k, v in list(formats.items()):
if ext in k:
return v
return 'ESRI Shapefile'
@@ -168,7 +168,7 @@ def getConsoleCommands(self):

parameters = {self.TITLE: '-t', self.COPYRIGHT: '-c',
self.GOOGLEKEY: '-g', self.BINGKEY: '-b'}
for arg, parameter in parameters.items():
for arg, parameter in list(parameters.items()):
if self.getParameterValue(arg):
arguments.append(parameter)
arguments.append(self.getParameterValue(arg))
@@ -34,6 +34,7 @@
import uuid
import importlib
import re
import traceback

from qgis.PyQt.QtCore import QCoreApplication
from qgis.PyQt.QtGui import QIcon
@@ -145,18 +146,14 @@ def defineCharacteristicsFromFile(self):
line = line.strip('\n').strip()
if line.startswith('Hardcoded'):
self.hardcodedStrings.append(line[len('Hardcoded|'):])
elif line.startswith('Parameter'):
parameter = getParameterFromString(line)
parameter = getParameterFromString(line)
if parameter is not None:
self.addParameter(parameter)
if isinstance(parameter, ParameterVector):
hasVectorInput = True
if isinstance(parameter, ParameterMultipleInput) \
and parameter.datatype < 3:
hasVectorInput = True
elif line.startswith('*Parameter'):
param = getParameterFromString(line[1:])
param.isAdvanced = True
self.addParameter(param)
else:
output = getOutputFromString(line)
self.addOutput(output)
@@ -169,9 +166,11 @@ def defineCharacteristicsFromFile(self):
" (raw output)", "txt"))
line = lines.readline().strip('\n').strip()
except Exception as e:

ProcessingLog.addToLog(
ProcessingLog.LOG_ERROR,
self.tr('Could not open GRASS algorithm: %s.\n%s' % (self.descriptionFile, line)))
traceback.format_exc())
#self.tr('Could not open GRASS algorithm: %s.\n%s' % (self.descriptionFile, line)))
raise e
lines.close()

@@ -177,18 +177,14 @@ def defineCharacteristicsFromFile(self):
line = line.strip('\n').strip()
if line.startswith('Hardcoded'):
self.hardcodedStrings.append(line[len('Hardcoded|'):])
elif line.startswith('Parameter'):
parameter = getParameterFromString(line)
parameter = getParameterFromString(line)
if parameter is not None:
self.addParameter(parameter)
if isinstance(parameter, ParameterVector):
hasVectorInput = True
if isinstance(parameter, ParameterMultipleInput) \
and parameter.datatype < 3:
hasVectorInput = True
elif line.startswith('*Parameter'):
param = getParameterFromString(line[1:])
param.isAdvanced = True
self.addParameter(param)
else:
output = getOutputFromString(line)
self.addOutput(output)
@@ -174,7 +174,7 @@ def exportInputRasters(alg, rasterDic):
{ 'inputName1': 'outputName1', 'inputName2': 'outputName2'}
"""
# Get inputs and outputs
for inputName, outputName in rasterDic.items():
for inputName, outputName in list(rasterDic.items()):
inputRaster = alg.getParameterValue(inputName)
outputRaster = alg.getOutputFromName(outputName)
command = 'r.out.gdal -c -t -f --overwrite createopt="TFW=YES,COMPRESS=LZW" input={} output=\"{}\"'.format(
@@ -87,7 +87,7 @@ def variableOutput(alg, params, nocats=True):
"""

# Build the v.out.ogr commands
for outputName, typeList in params.items():
for outputName, typeList in list(params.items()):
if not isinstance(typeList, list):
continue

@@ -50,7 +50,7 @@ def replace(s):
return s.replace("{qgisdocs}", "https://docs.qgis.org/%s/%s/docs" % (version, locale))
else:
return None
h = {k: replace(v) for k, v in h.items()}
h = {k: replace(v) for k, v in list(h.items())}
return h


@@ -52,7 +52,7 @@ def defineCharacteristics(self):
self.group, self.i18n_group = self.trAlgorithm('Points')
self.addParameter(ParameterFile(
self.INPUT, self.tr('Input LAS layer')))
self.addParameter(ParameterExtent(self.EXTENT, self.tr('Extent')))
self.addParameter(ParameterExtent(self.EXTENT, self.tr('Extent'), optional=False))
self.addParameter(ParameterSelection(
self.SHAPE, self.tr('Shape'), ['Rectangle', 'Circle']))
self.addOutput(OutputFile(
@@ -45,7 +45,7 @@ def defineCharacteristics(self):
self.name, self.i18n_name = self.trAlgorithm('lasquery')
self.group, self.i18n_group = self.trAlgorithm('LAStools')
self.addParametersVerboseGUI()
self.addParameter(ParameterExtent(self.AOI, self.tr('area of interest')))
self.addParameter(ParameterExtent(self.AOI, self.tr('area of interest'), optional=False))
self.addParametersAdditionalGUI()

def processAlgorithm(self, progress):
@@ -61,7 +61,7 @@ def processAlgorithm(self, progress):
layers = QgsMapLayerRegistry.instance().mapLayers()

# loop over layers
for name, layer in layers.items():
for name, layer in list(layers.items()):
layerType = layer.type()
if layerType == QgsMapLayer.VectorLayer:
shp_file_name = layer.source()
@@ -22,6 +22,7 @@
* *
***************************************************************************
"""
from builtins import next
from future import standard_library
standard_library.install_aliases()
from builtins import map
@@ -307,7 +308,7 @@ def processAlgorithm(self, progress):
OTBUtils.executeOtb(helperCommands, progress)

if self.roiRasters:
supportRaster = next(iter(self.roiRasters.values()))
supportRaster = next(iter(list(self.roiRasters.values())))
for roiInput, roiFile in list(self.roiVectors.items()):
helperCommands = [
"otbcli_VectorDataExtractROIApplication",
@@ -17,6 +17,7 @@
* *
***************************************************************************
"""
from builtins import next
from builtins import str
from builtins import range
__author__ = 'Julien Malik, Oscar Picas'
@@ -89,7 +89,7 @@ def processAlgorithm(self, progress):
counter = 50. / len(edges)
i = 0
ids = []
for id, max_len in edges.items():
for id, max_len in list(edges.items()):
if max_len > alpha * max_length:
ids.append(id)
progress.setPercentage(50 + i * counter)
@@ -16,6 +16,7 @@
* *
***************************************************************************
"""
from builtins import next

__author__ = 'Victor Olaya'
__date__ = 'August 2012'
@@ -36,7 +36,7 @@
class DeleteColumn(GeoAlgorithm):

INPUT = 'INPUT'
COLUMN = 'COLUMN'
COLUMNS = 'COLUMN'
OUTPUT = 'OUTPUT'

def defineCharacteristics(self):
@@ -45,17 +45,20 @@ def defineCharacteristics(self):

self.addParameter(ParameterVector(self.INPUT,
self.tr('Input layer')))
self.addParameter(ParameterTableField(self.COLUMN,
self.tr('Field to delete'), self.INPUT))
self.addOutput(OutputVector(self.OUTPUT, self.tr('Deleted column')))
self.addParameter(ParameterTableField(self.COLUMNS,
self.tr('Fields to delete'), self.INPUT, multiple=True))
self.addOutput(OutputVector(self.OUTPUT, self.tr('Output layer')))

def processAlgorithm(self, progress):
layer = dataobjects.getObjectFromUri(
self.getParameterValue(self.INPUT))
idx = layer.fields().lookupField(self.getParameterValue(self.COLUMN))
layer = dataobjects.getObjectFromUri(self.getParameterValue(self.INPUT))

toDelete = self.getParameterValue(self.COLUMNS)
fields = layer.fields()
fields.remove(idx)
idxs = []
for f in toDelete:
idx = layer.fieldNameIndex()
fields.remove(idx)
idxs.append[idx]

writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(fields,
layer.wkbType(), layer.crs())
@@ -67,7 +70,8 @@ def processAlgorithm(self, progress):
for current, f in enumerate(features):
feat.setGeometry(f.geometry())
attributes = f.attributes()
del attributes[idx]
for idx in idxs:
del attributes[idx]
feat.setAttributes(attributes)
writer.addFeature(feat)

@@ -64,7 +64,7 @@ def processAlgorithm(self, progress):

cleaned = dict(geoms)

for i, g in geoms.items():
for i, g in list(geoms.items()):
for j in list(cleaned.keys()):
if i == j or i not in cleaned:
continue
@@ -16,6 +16,7 @@
* *
***************************************************************************
"""
from builtins import next

__author__ = 'Victor Olaya'
__date__ = 'August 2012'
@@ -37,7 +37,7 @@
from processing.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
from processing.core.parameters import ParameterVector
from processing.core.parameters import ParameterBoolean
from processing.core.parameters import ParameterTableMultipleField
from processing.core.parameters import ParameterTableField
from processing.core.outputs import OutputVector
from processing.tools import vector, dataobjects

@@ -62,8 +62,8 @@ def defineCharacteristics(self):
[dataobjects.TYPE_VECTOR_POLYGON, dataobjects.TYPE_VECTOR_LINE]))
self.addParameter(ParameterBoolean(Dissolve.DISSOLVE_ALL,
self.tr('Dissolve all (do not use fields)'), True))
self.addParameter(ParameterTableMultipleField(Dissolve.FIELD,
self.tr('Unique ID fields'), Dissolve.INPUT, optional=True))
self.addParameter(ParameterTableField(Dissolve.FIELD,
self.tr('Unique ID fields'), Dissolve.INPUT, optional=True, multiple=True))
self.addOutput(OutputVector(Dissolve.OUTPUT, self.tr('Dissolved')))

def processAlgorithm(self, progress):
@@ -16,6 +16,7 @@
* *
***************************************************************************
"""
from builtins import next

__author__ = 'Victor Olaya'
__date__ = 'August 2012'
@@ -89,11 +89,6 @@ def processAlgorithm(self, progress):

output = self.getOutputFromName(self.OUTPUT_LAYER)

if output.value == '':
ext = output.getDefaultFileExtension(self)
output.value = system.getTempFilenameInTempFolder(
output.name + '.' + ext)

fields = layer.fields()
if newField:
fields.append(QgsField(fieldName, fieldType, '', width, precision))
@@ -37,8 +37,6 @@
from processing.tools import dataobjects, vector

from .fieldsmapping import ParameterFieldsMapping
from .ui.FieldsMapperDialogs import (FieldsMapperParametersDialog,
FieldsMapperModelerParametersDialog)


class FieldsMapper(GeoAlgorithm):
@@ -151,9 +149,3 @@ def processAlgorithm(self, progress):
raise GeoAlgorithmExecutionException(
self.tr('An error occurred while evaluating the calculation'
' string:\n') + error)

def getCustomParametersDialog(self):
return FieldsMapperParametersDialog(self)

def getCustomModelerParametersDialog(self, modelAlg, algName=None):
return FieldsMapperModelerParametersDialog(self, modelAlg, algName)
@@ -57,7 +57,7 @@ def defineCharacteristics(self):
self.group, self.i18n_group = self.trAlgorithm('Vector creation tools')

self.addParameter(ParameterExtent(self.EXTENT,
self.tr('Grid extent')))
self.tr('Grid extent'), optional=False))
self.addParameter(ParameterNumber(self.HSPACING,
self.tr('Horizontal spacing'), default=10.0))
self.addParameter(ParameterNumber(self.VSPACING,
@@ -65,7 +65,7 @@ def defineCharacteristics(self):
self.addParameter(ParameterSelection(self.TYPE,
self.tr('Grid type'), self.types))
self.addParameter(ParameterExtent(self.EXTENT,
self.tr('Grid extent')))
self.tr('Grid extent'), optional=False))
self.addParameter(ParameterNumber(self.HSPACING,
self.tr('Horizontal spacing'), default=10.0))
self.addParameter(ParameterNumber(self.VSPACING,
@@ -16,6 +16,7 @@
* *
***************************************************************************
"""
from builtins import next

__author__ = 'Michael Minn'
__date__ = 'May 2010'
@@ -16,6 +16,7 @@
* *
***************************************************************************
"""
from builtins import next

__author__ = 'Michael Minn'
__date__ = 'May 2010'
@@ -197,7 +197,7 @@ def calculateHypsometry(self, fid, fName, progress, data, pX, pY,
else:
multiplier = pX * pY

for k, v in out.items():
for k, v in list(out.items()):
out[k] = v * multiplier

prev = None
@@ -16,6 +16,7 @@
* *
***************************************************************************
"""
from builtins import next

__author__ = 'Victor Olaya'
__date__ = 'August 2012'
@@ -16,6 +16,7 @@
* *
***************************************************************************
"""
from builtins import next

__author__ = 'Victor Olaya'
__date__ = 'August 2012'
@@ -124,7 +124,7 @@ def processAlgorithm(self, progress):

current = 0
total = 100.0 / len(means)
for (clazz, values) in means.items():
for (clazz, values) in list(means.items()):
outFeat = QgsFeature()
cx = values[0] / values[2]
cy = values[1] / values[2]
@@ -16,6 +16,7 @@
* *
***************************************************************************
"""
from builtins import next
from builtins import str

__author__ = 'Victor Olaya'

0 comments on commit 4292c46

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