Skip to content
Permalink
Browse files

[processing] refactoring to move common functions to tools package

  • Loading branch information
volaya committed Sep 12, 2013
1 parent 4d9832c commit 807ffaa5e63ae09a510e85664afcf1613d1bb4d0
Showing with 1,177 additions and 1,345 deletions.
  1. +20 −23 python/plugins/processing/ProcessingPlugin.py
  2. +7 −5 python/plugins/processing/__init__.py
  3. +2 −2 python/plugins/processing/admintools/CreateMosaicDatastore.py
  4. +2 −2 python/plugins/processing/admintools/ImportIntoPostGIS.py
  5. +4 −4 python/plugins/processing/admintools/ImportVectorIntoGeoServer.py
  6. +2 −2 python/plugins/processing/admintools/geoserver/support.py
  7. +3 −3 python/plugins/processing/algs/AddTableField.py
  8. +3 −3 python/plugins/processing/algs/AutoincrementalField.py
  9. +2 −2 python/plugins/processing/algs/BarPlot.py
  10. +2 −2 python/plugins/processing/algs/CreateConstantRaster.py
  11. +3 −3 python/plugins/processing/algs/EquivalentNumField.py
  12. +3 −3 python/plugins/processing/algs/Explode.py
  13. +3 −3 python/plugins/processing/algs/FieldPyculator.py
  14. +3 −3 python/plugins/processing/algs/FieldsCalculator.py
  15. +5 −5 python/plugins/processing/algs/JoinAttributes.py
  16. +2 −2 python/plugins/processing/algs/MeanAndStdDevPlot.py
  17. +3 −3 python/plugins/processing/algs/PointsLayerFromTable.py
  18. +2 −2 python/plugins/processing/algs/PolarPlot.py
  19. +3 −3 python/plugins/processing/algs/Polygonize.py
  20. +2 −2 python/plugins/processing/algs/RasterLayerHistogram.py
  21. +2 −2 python/plugins/processing/algs/RasterLayerStatistics.py
  22. +4 −4 python/plugins/processing/algs/SaveSelectedFeatures.py
  23. +3 −3 python/plugins/processing/algs/StatisticsByCategories.py
  24. +2 −2 python/plugins/processing/algs/VectorLayerHistogram.py
  25. +2 −2 python/plugins/processing/algs/VectorLayerScatterplot.py
  26. +3 −9 python/plugins/processing/algs/ftools/BasicStatisticsNumbers.py
  27. +3 −9 python/plugins/processing/algs/ftools/BasicStatisticsStrings.py
  28. +20 −47 python/plugins/processing/algs/ftools/Buffer.py
  29. +3 −11 python/plugins/processing/algs/ftools/Centroids.py
  30. +17 −42 python/plugins/processing/algs/ftools/Clip.py
  31. +5 −11 python/plugins/processing/algs/ftools/ConvexHull.py
  32. +3 −15 python/plugins/processing/algs/ftools/Delaunay.py
  33. +3 −3 python/plugins/processing/algs/ftools/DensifyGeometries.py
  34. +3 −3 python/plugins/processing/algs/ftools/DensifyGeometriesInterval.py
  35. +4 −4 python/plugins/processing/algs/ftools/Difference.py
  36. +5 −5 python/plugins/processing/algs/ftools/Dissolve.py
  37. +7 −5 python/plugins/processing/algs/ftools/ExportGeometryInfo.py
  38. +3 −3 python/plugins/processing/algs/ftools/ExtentFromLayer.py
  39. +3 −3 python/plugins/processing/algs/ftools/ExtractNodes.py
  40. +2 −2 python/plugins/processing/algs/ftools/FixedDistanceBuffer.py
  41. +4 −4 python/plugins/processing/algs/ftools/Intersection.py
  42. +4 −4 python/plugins/processing/algs/ftools/LinesIntersection.py
  43. +3 −3 python/plugins/processing/algs/ftools/LinesToPolygons.py
  44. +3 −3 python/plugins/processing/algs/ftools/MeanCoords.py
  45. +3 −3 python/plugins/processing/algs/ftools/MultipartToSingleparts.py
  46. +3 −3 python/plugins/processing/algs/ftools/NearestNeighbourAnalysis.py
  47. +4 −4 python/plugins/processing/algs/ftools/PointsInPolygon.py
  48. +4 −4 python/plugins/processing/algs/ftools/PointsInPolygonUnique.py
  49. +4 −4 python/plugins/processing/algs/ftools/PointsInPolygonWeighted.py
  50. +3 −3 python/plugins/processing/algs/ftools/PolygonsToLines.py
  51. +2 −2 python/plugins/processing/algs/ftools/RandomSelection.py
  52. +3 −3 python/plugins/processing/algs/ftools/RandomSelectionWithinSubsets.py
  53. +3 −3 python/plugins/processing/algs/ftools/ReprojectLayer.py
  54. +4 −4 python/plugins/processing/algs/ftools/SelectByLocation.py
  55. +3 −3 python/plugins/processing/algs/ftools/SimplifyGeometries.py
  56. +4 −4 python/plugins/processing/algs/ftools/SinglePartsToMultiparts.py
  57. +4 −4 python/plugins/processing/algs/ftools/SumLines.py
  58. +5 −5 python/plugins/processing/algs/ftools/Union.py
  59. +2 −2 python/plugins/processing/algs/ftools/UniqueValues.py
  60. +2 −2 python/plugins/processing/algs/ftools/VariableDistanceBuffer.py
  61. +3 −3 python/plugins/processing/algs/ftools/VoronoiPolygons.py
  62. +23 −23 python/plugins/processing/algs/mmqgisx/MMQGISXAlgorithms.py
  63. +5 −4 python/plugins/processing/commander/CommanderWindow.py
  64. +14 −14 python/plugins/processing/core/GeoAlgorithm.py
  65. +0 −136 python/plugins/processing/core/LayerExporter.py
  66. +5 −12 python/plugins/processing/core/Processing.py
  67. +3 −3 python/plugins/processing/core/ProcessingConfig.py
  68. +2 −3 python/plugins/processing/core/ProcessingLog.py
  69. +0 −97 python/plugins/processing/core/ProcessingUtils.py
  70. +0 −263 python/plugins/processing/core/QGisLayers.py
  71. +4 −4 python/plugins/processing/exampleprovider/ExampleAlgorithm.py
  72. +0 −2 python/plugins/processing/gdal/GdalUtils.py
  73. +2 −2 python/plugins/processing/gdal/OgrAlgorithm.py
  74. +2 −2 python/plugins/processing/gdal/merge.py
  75. +2 −2 python/plugins/processing/gdal/pct2rgb.py
  76. +2 −2 python/plugins/processing/gdal/polygonize.py
  77. +2 −2 python/plugins/processing/gdal/rgb2pct.py
  78. +17 −19 python/plugins/processing/grass/GrassAlgorithm.py
  79. +3 −3 python/plugins/processing/grass/GrassAlgorithmProvider.py
  80. +11 −11 python/plugins/processing/grass/GrassUtils.py
  81. +5 −5 python/plugins/processing/grass/nviz.py
  82. +4 −7 python/plugins/processing/gui/AlgorithmExecutionDialog.py
  83. +19 −13 python/plugins/processing/gui/AlgorithmExecutor.py
  84. +2 −2 python/plugins/processing/gui/BatchProcessingDialog.py
  85. +9 −8 python/plugins/processing/gui/ExtentSelectionPanel.py
  86. +2 −2 python/plugins/processing/gui/FileSelectionPanel.py
  87. +2 −2 python/plugins/processing/gui/Help2Html.py
  88. +3 −3 python/plugins/processing/gui/MultipleInputPanel.py
  89. +6 −5 python/plugins/processing/gui/NumberInputDialog.py
  90. +11 −11 python/plugins/processing/gui/ParametersPanel.py
  91. +2 −2 python/plugins/processing/gui/Postprocessing.py
  92. +4 −5 python/plugins/processing/gui/ProcessingToolbox.py
  93. +2 −2 python/plugins/processing/gui/RenderingStyles.py
  94. +5 −5 python/plugins/processing/gui/TestTools.py
  95. +12 −8 python/plugins/processing/gui/UnthreadedAlgorithmExecutor.py
  96. +1 −0 python/plugins/processing/interface.py
  97. +3 −3 python/plugins/processing/lidar/LidarToolsAlgorithmProvider.py
  98. +2 −2 python/plugins/processing/lidar/fusion/FusionUtils.py
  99. +3 −3 python/plugins/processing/modeler/ModelerAlgorithm.py
  100. +2 −2 python/plugins/processing/modeler/ModelerDialog.py
  101. +2 −2 python/plugins/processing/modeler/ModelerUtils.py
  102. +2 −2 python/plugins/processing/modeler/RasterLayerBoundsAlgorithm.py
  103. +2 −2 python/plugins/processing/modeler/VectorLayerBoundsAlgorithm.py
  104. +3 −3 python/plugins/processing/otb/OTBAlgorithm.py
  105. +5 −5 python/plugins/processing/otb/OTBUtils.py
  106. +2 −2 python/plugins/processing/outputs/Output.py
  107. +4 −4 python/plugins/processing/outputs/OutputRaster.py
  108. +2 −2 python/plugins/processing/outputs/OutputTable.py
  109. +4 −4 python/plugins/processing/outputs/OutputVector.py
  110. +2 −2 python/plugins/processing/parameters/ParameterDataObject.py
  111. +10 −10 python/plugins/processing/parameters/ParameterMultipleInput.py
  112. +6 −6 python/plugins/processing/parameters/ParameterRaster.py
  113. +5 −5 python/plugins/processing/parameters/ParameterTable.py
  114. +6 −6 python/plugins/processing/parameters/ParameterVector.py
  115. +2 −2 python/plugins/processing/r/EditRScriptDialog.py
  116. +2 −2 python/plugins/processing/r/RAlgorithm.py
  117. +3 −3 python/plugins/processing/r/RAlgorithmProvider.py
  118. +6 −6 python/plugins/processing/r/RUtils.py
  119. +23 −23 python/plugins/processing/saga/SagaAlgorithm.py
  120. +3 −3 python/plugins/processing/saga/SagaAlgorithmProvider.py
  121. +9 −9 python/plugins/processing/saga/SagaUtils.py
  122. +4 −4 python/plugins/processing/saga/SplitRGBBands.py
  123. +3 −3 python/plugins/processing/script/ScriptUtils.py
  124. +1 −1 python/plugins/processing/script/scripts/Create_tiling_from_vector_layer.py
  125. +1 −1 python/plugins/processing/script/scripts/Hex_grid_from_layer_bounds.py
  126. +3 −3 python/plugins/processing/script/scripts/Number_of_unique_values_in_classes.py
  127. +2 −2 python/plugins/processing/script/scripts/Save_selected_features.py
  128. +2 −2 python/plugins/processing/script/scripts/Split_vector_layer_by_attribute.py
  129. +2 −2 python/plugins/processing/script/scripts/Summarize.py
  130. +1 −1 python/plugins/processing/taudem/TauDEMAlgorithm.py
  131. +3 −3 python/plugins/processing/taudem/TauDEMUtils.py
  132. +1 −1 python/plugins/processing/taudem/dinfdistdown.py
  133. +1 −1 python/plugins/processing/taudem/dinfdistup.py
  134. +1 −1 python/plugins/processing/taudem/dinftranslimaccum.py
  135. +1 −1 python/plugins/processing/taudem/dinftranslimaccum2.py
  136. +1 −1 python/plugins/processing/taudem/dropanalysis.py
  137. +1 −1 python/plugins/processing/taudem/gridnet.py
  138. +1 −1 python/plugins/processing/taudem/lengtharea.py
  139. +1 −1 python/plugins/processing/taudem/peukerdouglas.py
  140. +1 −1 python/plugins/processing/taudem/slopearea.py
  141. +8 −8 python/plugins/processing/tests/GdalTest.py
  142. +5 −5 python/plugins/processing/tests/GeoAlgorithmTest.py
  143. +7 −7 python/plugins/processing/tests/ModelerAlgorithmTest.py
  144. +9 −9 python/plugins/processing/tests/ProcessingToolsTest.py
  145. +91 −91 python/plugins/processing/tests/QgisAlgsTest.py
  146. +5 −5 python/plugins/processing/tests/RunAlgTest.py
  147. +10 −10 python/plugins/processing/tests/SagaTest.py
  148. +5 −5 python/plugins/processing/tests/ScriptTest.py
  149. +10 −10 python/plugins/processing/tests/TestData.py
  150. +305 −0 python/plugins/processing/tools/dataobjects.py
  151. +2 −19 python/plugins/processing/tools/general.py
  152. +1 −1 python/plugins/processing/tools/help.py
  153. +88 −0 python/plugins/processing/tools/system.py
  154. +58 −15 python/plugins/processing/tools/vector.py
@@ -16,6 +16,7 @@
* *
***************************************************************************
"""
from processing import interface

__author__ = 'Victor Olaya'
__date__ = 'August 2012'
@@ -24,44 +25,40 @@
__revision__ = '$Format:%H$'

import shutil
import os, sys
import inspect
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from qgis.core import *
from PyQt4 import QtGui
from processing.commander.CommanderWindow import CommanderWindow
from processing.core.Processing import Processing
from processing.core.QGisLayers import QGisLayers
from processing.core.ProcessingUtils import ProcessingUtils
from processing.tools import dataobjects
from processing.tools.system import *
from processing.gui.ProcessingToolbox import ProcessingToolbox
from processing.gui.HistoryDialog import HistoryDialog
from processing.gui.ConfigDialog import ConfigDialog
from processing.gui.ResultsDialog import ResultsDialog
from processing.modeler.ModelerDialog import ModelerDialog
import processing.resources_rc


cmd_folder = os.path.split(inspect.getfile( inspect.currentframe() ))[0]
if cmd_folder not in sys.path:
sys.path.insert(0, cmd_folder)

class ProcessingPlugin:

def __init__(self, iface):
self.iface = iface
QGisLayers.setInterface(iface)
Processing.initialize()
Processing.setInterface(iface)
Processing.setPlugin(self)
interface.iface = iface
Processing.initialize()

def initGui(self):
self.commander = None
self.toolbox = ProcessingToolbox(self.iface)
self.iface.addDockWidget(Qt.RightDockWidgetArea, self.toolbox)
self.toolbox = ProcessingToolbox()
interface.iface.addDockWidget(Qt.RightDockWidgetArea, self.toolbox)
self.toolbox.hide()
Processing.addAlgListListener(self.toolbox)

self.menu = QMenu(self.iface.mainWindow())
self.menu = QMenu(interface.iface.mainWindow())
self.menu.setTitle(QCoreApplication.translate("Processing", "Processing"))

self.toolboxAction = self.toolbox.toggleViewAction()
@@ -71,51 +68,51 @@ def initGui(self):

self.modelerAction = QAction(QIcon(":/processing/images/model.png"),
QCoreApplication.translate("Processing", "Graphical modeler"),
self.iface.mainWindow())
interface.iface.mainWindow())
self.modelerAction.triggered.connect(self.openModeler)
self.menu.addAction(self.modelerAction)

self.historyAction = QAction(QIcon(":/processing/images/history.gif"),
QCoreApplication.translate("Processing", "History and log"),
self.iface.mainWindow())
interface.iface.mainWindow())
self.historyAction.triggered.connect(self.openHistory)
self.menu.addAction(self.historyAction)

self.configAction = QAction(QIcon(":/processing/images/config.png"),
QCoreApplication.translate("Processing", "Options and configuration"),
self.iface.mainWindow())
interface.iface.mainWindow())
self.configAction.triggered.connect(self.openConfig)
self.menu.addAction(self.configAction)

self.resultsAction = QAction(QIcon(":/processing/images/results.png"),
QCoreApplication.translate("Processing", "&Results viewer"),
self.iface.mainWindow())
interface.iface.mainWindow())
self.resultsAction.triggered.connect(self.openResults)
self.menu.addAction(self.resultsAction)

menuBar = self.iface.mainWindow().menuBar()
menuBar.insertMenu(self.iface.firstRightStandardMenu().menuAction(), self.menu)
menuBar = interface.iface.mainWindow().menuBar()
menuBar.insertMenu(interface.iface.firstRightStandardMenu().menuAction(), self.menu)

self.commanderAction = QAction(QIcon(":/processing/images/commander.png"),
QCoreApplication.translate("Processing", "&Commander"),
self.iface.mainWindow())
interface.iface.mainWindow())
self.commanderAction.triggered.connect(self.openCommander)
self.menu.addAction(self.commanderAction)
self.iface.registerMainWindowAction(self.commanderAction, "Ctrl+Alt+M")
interface.iface.registerMainWindowAction(self.commanderAction, "Ctrl+Alt+M")

def unload(self):
self.toolbox.setVisible(False)
self.menu.deleteLater()
#delete temporary output files
folder = ProcessingUtils.tempFolder()
folder = tempFolder()
if QDir(folder).exists():
shutil.rmtree(folder, True)

self.iface.unregisterMainWindowAction(self.commanderAction)
interface.iface.unregisterMainWindowAction(self.commanderAction)

def openCommander(self):
if self.commander is None:
self.commander = CommanderWindow(self.iface.mainWindow(), self.iface.mapCanvas())
self.commander = CommanderWindow(interface.iface.mainWindow(), interface.iface.mapCanvas())
Processing.addAlgListListener(self.commander)
self.commander.prepareGui()
self.commander.show()
@@ -17,17 +17,19 @@
***************************************************************************
"""

from processing.tools.general import runalg, runandload, alghelp, alglist, algoptions, load, extent, getobject
from processing.tools.vector import getfeatures, spatialindex, values, uniquevalues
from processing.tools.raster import scanraster
from processing.tests.TestData import loadTestData

__author__ = 'Victor Olaya'
__date__ = 'August 2012'
__copyright__ = '(C) 2012, Victor Olaya'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'

from processing.tools.dataobjects import *
from processing.tools.general import *
from processing.tools.vector import *
from processing.tools.raster import *
from processing.tools.system import *
from processing.tests.TestData import loadTestData

def classFactory(iface):
from processing.ProcessingPlugin import ProcessingPlugin
return ProcessingPlugin(iface)
@@ -17,7 +17,7 @@
# * *
# ***************************************************************************
# """
# from processing.core.LayerExporter import LayerExporter
# from processing.tools import dataobjects
# from processing.parameters.ParameterString import ParameterString
# from processing.servertools.GeoServerToolsAlgorithm import GeoServerToolsAlgorithm
#
@@ -29,7 +29,7 @@
#
# from qgis.core import *
# from processing.parameters.ParameterVector import ParameterVector
# from processing.core.QGisLayers import QGisLayers
# from processing.tools import dataobjects
# import os
#
# class CreateMosaicDatastore(GeoServerToolsAlgorithm):
@@ -16,7 +16,7 @@
* *
***************************************************************************
"""
from processing.core.QGisLayers import QGisLayers
from processing.tools import dataobjects
from processing.parameters.ParameterBoolean import ParameterBoolean


@@ -80,7 +80,7 @@ def processAlgorithm(self, progress):
options['overwrite'] = True

layerUri = self.getParameterValue(self.INPUT);
layer = QGisLayers.getObjectFromUri(layerUri)
layer = dataobjects.getObjectFromUri(layerUri)
ret, errMsg = QgsVectorLayerImport.importLayer(layer, uri.uri(), providerName, self.crs, False, False, options)
if ret != 0:
raise GeoAlgorithmExecutionException(u"Error importing to PostGIS\n%s" % errMsg)
@@ -26,8 +26,8 @@
import os
from qgis.core import *
from processing.parameters.ParameterVector import ParameterVector
from processing.core.QGisLayers import QGisLayers
from processing.core.LayerExporter import LayerExporter
from processing.tools import dataobjects
from processing.tools import dataobjects
from processing.parameters.ParameterString import ParameterString
from processing.admintools.GeoServerToolsAlgorithm import GeoServerToolsAlgorithm

@@ -39,9 +39,9 @@ class ImportVectorIntoGeoServer(GeoServerToolsAlgorithm):
def processAlgorithm(self, progress):
self.createCatalog()
inputFilename = self.getParameterValue(self.INPUT)
layer = QGisLayers.getObjectFromUri(inputFilename)
layer = dataobjects.getObjectFromUri(inputFilename)
workspaceName = self.getParameterValue(self.WORKSPACE)
filename = LayerExporter.exportVectorLayer(layer)
filename = dataobjects.exportVectorLayer(layer)
basefilename = os.path.basename(filename)
basepathname = os.path.dirname(filename) + os.sep + basefilename[:basefilename.find('.')]
connection = {
@@ -28,7 +28,7 @@
import urllib
import urlparse
from zipfile import ZipFile
from processing.core.ProcessingUtils import ProcessingUtils
from processing.tools.system import *


logger = logging.getLogger("gsconfig.support")
@@ -195,7 +195,7 @@ def prepare_upload_bundle(name, data):
file-like objects. The client code is responsible for deleting the zip
archive when it's done."""
#we ut the zip file in the processing temp dir, so it is deleted at the end.
f = ProcessingUtils.getTempFilename('zip')
f = getTempFilename('zip')
zip_file = ZipFile(f, 'w')
for ext, stream in data.iteritems():
fname = "%s.%s" % (name, ext)
@@ -29,7 +29,7 @@
from qgis.core import *

from processing.core.GeoAlgorithm import GeoAlgorithm
from processing.core.QGisLayers import QGisLayers
from processing.tools import dataobjects, vector

from processing.parameters.ParameterVector import ParameterVector
from processing.parameters.ParameterString import ParameterString
@@ -72,7 +72,7 @@ def processAlgorithm(self, progress):
fieldPrecision = self.getParameterValue(self.FIELD_PRECISION)
output = self.getOutputFromName(self.OUTPUT_LAYER)

layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.INPUT_LAYER))
layer = dataobjects.getObjectFromUri(self.getParameterValue(self.INPUT_LAYER))

provider = layer.dataProvider()
fields = provider.fields()
@@ -81,7 +81,7 @@ def processAlgorithm(self, progress):
outFeat = QgsFeature()
inGeom = QgsGeometry()
nElement = 0
features = QGisLayers.features(layer)
features = vector.features(layer)
nFeat = len(features)
for inFeat in features:
progress.setPercentage(int((100 * nElement)/nFeat))
@@ -27,7 +27,7 @@
from PyQt4.QtCore import *
from qgis.core import *
from processing.parameters.ParameterVector import ParameterVector
from processing.core.QGisLayers import QGisLayers
from processing.tools import dataobjects, vector
from processing.outputs.OutputVector import OutputVector

class AutoincrementalField(GeoAlgorithm):
@@ -42,7 +42,7 @@ class AutoincrementalField(GeoAlgorithm):

def processAlgorithm(self, progress):
output = self.getOutputFromName(self.OUTPUT)
vlayer = QGisLayers.getObjectFromUri(self.getParameterValue(self.INPUT))
vlayer = dataobjects.getObjectFromUri(self.getParameterValue(self.INPUT))
vprovider = vlayer.dataProvider()
fields = vprovider.fields()
fields.append(QgsField("AUTO", QVariant.Int))
@@ -51,7 +51,7 @@ def processAlgorithm(self, progress):
outFeat = QgsFeature()
inGeom = QgsGeometry()
nElement = 0
features = QGisLayers.features(vlayer)
features = vector.features(vlayer)
nFeat = len(features)
for inFeat in features:
progress.setPercentage(int((100 * nElement)/nFeat))
@@ -33,7 +33,7 @@
from processing.core.GeoAlgorithm import GeoAlgorithm
from processing.outputs.OutputHTML import OutputHTML
from processing.tools import *
from processing.core.QGisLayers import QGisLayers
from processing.tools import dataobjects

class BarPlot(GeoAlgorithm):

@@ -44,7 +44,7 @@ class BarPlot(GeoAlgorithm):

def processAlgorithm(self, progress):
uri = self.getParameterValue(self.INPUT)
layer = QGisLayers.getObjectFromUri(uri)
layer = dataobjects.getObjectFromUri(uri)
namefieldname = self.getParameterValue(self.NAME_FIELD)
valuefieldname = self.getParameterValue(self.VALUE_FIELD)
output = self.getOutputValue(self.OUTPUT)
@@ -33,7 +33,7 @@
from qgis.core import *
from processing.parameters.ParameterNumber import ParameterNumber
from processing.outputs.OutputRaster import OutputRaster
from processing.core.QGisLayers import QGisLayers
from processing.tools import dataobjects

class CreateConstantRaster(GeoAlgorithm):

@@ -49,7 +49,7 @@ class CreateConstantRaster(GeoAlgorithm):
def processAlgorithm(self, progress):
output = self.getOutputFromName(self.OUTPUT)
value = self.getOutputValue(self.NUMBER)
layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.INPUT))
layer = dataobjects.getObjectFromUri(self.getParameterValue(self.INPUT))
cellsize = (layer.extent().xMaximum() - layer.extent().xMinimum())/layer.width()
w = RasterWriter(output.getCompatibleFileName(self), layer.extent().xMinimum(), layer.extent().yMinimum(), layer.extent().xMaximum(),
layer.extent().yMaximum(), cellsize, 1, self.crs)
@@ -27,7 +27,7 @@
from PyQt4.QtCore import *
from qgis.core import *
from processing.parameters.ParameterVector import ParameterVector
from processing.core.QGisLayers import QGisLayers
from processing.tools import dataobjects, vector
from processing.outputs.OutputVector import OutputVector
from processing.parameters.ParameterTableField import ParameterTableField

@@ -45,7 +45,7 @@ class EquivalentNumField(GeoAlgorithm):
def processAlgorithm(self, progress):
fieldname = self.getParameterValue(self.FIELD)
output = self.getOutputFromName(self.OUTPUT)
vlayer = QGisLayers.getObjectFromUri(self.getParameterValue(self.INPUT))
vlayer = dataobjects.getObjectFromUri(self.getParameterValue(self.INPUT))
vprovider = vlayer.dataProvider()
fieldindex = vlayer.fieldNameIndex(fieldname)
fields = vprovider.fields()
@@ -55,7 +55,7 @@ def processAlgorithm(self, progress):
inGeom = QgsGeometry()
nElement = 0
classes = {}
features = QGisLayers.features(vlayer)
features = vector.features(vlayer)
nFeat = len(features)
for feature in features:
progress.setPercentage(int((100 * nElement)/nFeat))
@@ -28,7 +28,7 @@
from PyQt4.QtGui import *
from qgis.core import *
from processing.parameters.ParameterVector import ParameterVector
from processing.core.QGisLayers import QGisLayers
from processing.tools import dataobjects, vector
from processing.outputs.OutputVector import OutputVector

class Explode(GeoAlgorithm):
@@ -42,15 +42,15 @@ class Explode(GeoAlgorithm):
#===========================================================================

def processAlgorithm(self, progress):
vlayer = QGisLayers.getObjectFromUri(self.getParameterValue(self.INPUT))
vlayer = dataobjects.getObjectFromUri(self.getParameterValue(self.INPUT))
output = self.getOutputFromName(self.OUTPUT)
vprovider = vlayer.dataProvider()
fields = vprovider.fields()
writer = output.getVectorWriter(fields, QGis.WKBLineString, vlayer.crs() )
outFeat = QgsFeature()
inGeom = QgsGeometry()
nElement = 0
features = QGisLayers.features(vlayer)
features = vector.features(vlayer)
nFeat = len(features)
for feature in features:
nElement += 1
@@ -30,7 +30,7 @@
from qgis.core import *

from processing.core.GeoAlgorithm import GeoAlgorithm
from processing.core.QGisLayers import QGisLayers
from processing.tools import dataobjects, vector
from processing.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException

from processing.parameters.ParameterVector import ParameterVector
@@ -82,7 +82,7 @@ def processAlgorithm(self, progress):
globalExpression = self.getParameterValue(self.GLOBAL)
output = self.getOutputFromName(self.OUTPUT_LAYER)

layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.INPUT_LAYER))
layer = dataobjects.getObjectFromUri(self.getParameterValue(self.INPUT_LAYER))
provider = layer.dataProvider()
fields = provider.fields()
fields.append(QgsField(fieldName, self.TYPES[fieldType], "", fieldLength, fieldPrecision))
@@ -125,7 +125,7 @@ def processAlgorithm(self, progress):
unicode(sys.exc_info()[0].__name__), unicode(sys.exc_info()[1]))

#run
features = QGisLayers.features(layer)
features = vector.features(layer)
nFeatures = len(features)
nElement = 1
for feat in features:

0 comments on commit 807ffaa

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