Showing with 237 additions and 74 deletions.
  1. +2 −1 python/plugins/processing/algs/QGISAlgorithmProvider.py
  2. +1 −4 python/plugins/processing/algs/ftools/Buffer.py
  3. +191 −0 python/plugins/processing/algs/ftools/Eliminate.py
  4. +0 −4 python/plugins/processing/algs/ftools/ExtentFromLayer.py
  5. +0 −5 python/plugins/processing/algs/ftools/ExtractNodes.py
  6. +0 −5 python/plugins/processing/algs/ftools/FixedDistanceBuffer.py
  7. +0 −5 python/plugins/processing/algs/ftools/Intersection.py
  8. +0 −5 python/plugins/processing/algs/ftools/LinesIntersection.py
  9. +0 −5 python/plugins/processing/algs/ftools/LinesToPolygons.py
  10. +0 −5 python/plugins/processing/algs/ftools/MeanCoords.py
  11. +0 −4 python/plugins/processing/algs/ftools/MultipartToSingleparts.py
  12. +1 −1 python/plugins/processing/core/ProcessingConfig.py
  13. +1 −1 python/plugins/processing/core/ProcessingLog.py
  14. +2 −2 python/plugins/processing/grass/description/v.overlay.txt
  15. +0 −1 python/plugins/processing/gui/Postprocessing.py
  16. +5 −5 python/plugins/processing/gui/ProcessingToolbox.py
  17. +3 −0 python/plugins/processing/modeler/ModelerAlgorithm.py
  18. +20 −9 python/plugins/processing/modeler/ModelerDialog.py
  19. +2 −2 python/plugins/processing/saga/SagaAlgorithm.py
  20. +2 −4 python/plugins/processing/saga/SagaAlgorithmProvider.py
  21. +3 −0 python/plugins/processing/script/ScriptAlgorithm.py
  22. +1 −3 python/plugins/processing/tools/vector.py
  23. +2 −2 python/plugins/processing/ui/DlgHistory.ui
  24. +1 −1 python/plugins/processing/ui/ui_DlgHistory.py
3 changes: 2 additions & 1 deletion python/plugins/processing/algs/QGISAlgorithmProvider.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
***************************************************************************
"""
from processing.algs.Polygonize import Polygonize
from processing.algs.ftools.Eliminate import Eliminate

__author__ = 'Victor Olaya'
__date__ = 'December 2012'
Expand Down Expand Up @@ -112,7 +113,7 @@ def __init__(self):
ExportGeometryInfo(), Centroids(), Delaunay(), VoronoiPolygons(),
SimplifyGeometries(), DensifyGeometries(), DensifyGeometriesInterval(),
MultipartToSingleparts(), SinglePartsToMultiparts(), PolygonsToLines(),
LinesToPolygons(), ExtractNodes(),
LinesToPolygons(), ExtractNodes(),Eliminate(),
# geoprocessing
ConvexHull(), FixedDistanceBuffer(), VariableDistanceBuffer(),
Dissolve(), Difference(), Intersection(), Union(), Clip(),
Expand Down
5 changes: 1 addition & 4 deletions python/plugins/processing/algs/ftools/Buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,16 @@
* *
***************************************************************************
"""
from processing.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException

__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 PyQt4.QtCore import *
from qgis.core import *
from processing.tools import dataobjects, vector
from processing.core.ProcessingLog import ProcessingLog
from processing.tools import vector

def buffering(progress, writer, distance, field, useField, layer, dissolve, segments):

Expand Down
191 changes: 191 additions & 0 deletions python/plugins/processing/algs/ftools/Eliminate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
# -*- coding: utf-8 -*-

"""
***************************************************************************
Eliminate.py
---------------------
Date : August 2012
Copyright : (C) 2013 by Bernhard Str�bl
Email : bernhard.stroebl@jena.de
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""
from processing.parameters.ParameterSelection import ParameterSelection
from processing.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
from PyQt4 import QtCore

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

from PyQt4.QtCore import *
from qgis.core import *
from processing.core.GeoAlgorithm import GeoAlgorithm
from processing.tools import dataobjects
from processing.parameters.ParameterVector import ParameterVector
from processing.outputs.OutputVector import OutputVector


class Eliminate(GeoAlgorithm):

INPUT = "INPUT"
OUTPUT = "OUTPUT"
MODE = "MODE"

MODES = ["Area", "Common boundary"]
MODE_AREA = 0
MODE_BOUNDARY = 1


def defineCharacteristics(self):
self.name = "Eliminate sliver polygons"
self.group = "Vector geometry tools"
self.addParameter(ParameterVector(self.INPUT, "Input layer", [ParameterVector.VECTOR_TYPE_POLYGON]))
self.addParameter(ParameterSelection(self.MODE, "Merge selection with the neighbouring polygon with the largest", self.MODES))
self.addOutput(OutputVector(self.OUTPUT, "Cleaned layer"))

def processAlgorithm(self, progress):
inLayer = dataobjects.getObjectFromUri(self.getParameterValue(self.INPUT))
boundary = self.getParameterValue(self.MODE) == self.MODE_BOUNDARY

# keep references to the features to eliminate
fidsToEliminate = inLayer.selectedFeaturesIds()


provider = inLayer.dataProvider()
output = self.getOutputFromName(self.OUTPUT)
writer = output.getVectorWriter( provider.fields(),
provider.geometryType(),
inLayer.crs() )

#write all features to output layer
iterator = inLayer.getFeatures()
for feature in iterator:
writer.addFeature(feature)

#Open the layer to start cleaning it
outFileName = output.value
outLayer = QgsVectorLayer(outFileName, QtCore.QFileInfo(outFileName).completeBaseName(), "ogr")


# delete features to be eliminated in outLayer
outLayer.setSelectedFeatures(fidsToEliminate)
outLayer.startEditing()

if outLayer.deleteSelectedFeatures():
if self.saveChanges(outLayer):
outLayer.startEditing()
else:
raise GeoAlgorithmExecutionException("Could not delete features")

# ANALYZE
start = 20.00
progress.setPercentage(start)
add = 80.00 / len(fidsToEliminate)

lastLen = 0
geomsToMerge = dict()

# we go through the list and see if we find any polygons we can merge the selected with
# if we have no success with some we merge and then restart the whole story
while (lastLen != inLayer.selectedFeatureCount()): #check if we made any progress
lastLen = inLayer.selectedFeatureCount()
fidsToDeselect = []

#iterate over the polygons to eliminate
for fid2Eliminate in inLayer.selectedFeaturesIds():
feat = QgsFeature()

if inLayer.getFeatures( QgsFeatureRequest().setFilterFid( fid2Eliminate ).setSubsetOfAttributes([]) ).nextFeature( feat ):
geom2Eliminate = feat.geometry()
bbox = geom2Eliminate.boundingBox()
fit = outLayer.getFeatures( QgsFeatureRequest().setFilterRect( bbox ) )
mergeWithFid = None
mergeWithGeom = None
max = 0

selFeat = QgsFeature()
while fit.nextFeature(selFeat):
selGeom = selFeat.geometry()

if geom2Eliminate.intersects(selGeom): # we have a candidate
iGeom = geom2Eliminate.intersection(selGeom)

if boundary:
selValue = iGeom.length()
else:
# we need a common boundary
if 0 < iGeom.length():
selValue = selGeom.area()
else:
selValue = 0

if selValue > max:
max = selValue
mergeWithFid = selFeat.id()
mergeWithGeom = QgsGeometry(selGeom) # deep copy of the geometry

if mergeWithFid != None: # a successful candidate
newGeom = mergeWithGeom.combine(geom2Eliminate)

if outLayer.changeGeometry(mergeWithFid, newGeom):
# write change back to disc
if self.saveChanges(outLayer):
outLayer.startEditing()
else:
return

# mark feature as eliminated in inLayer
fidsToDeselect.append(fid2Eliminate)
else:
raise GeoAlgorithmExecutionException("Could not replace geometry of feature with id %s" % (mergeWithFid))

start = start + add
progress.setPercentage(start)
# end for fid2Eliminate

# deselect features that are already eliminated in inLayer
inLayer.deselect(fidsToDeselect)

#end while

if inLayer.selectedFeatureCount() > 0:
# copy all features that could not be eliminated to outLayer
if outLayer.addFeatures(inLayer.selectedFeatures()):
# inform user
fidList = ""

for fid in inLayer.selectedFeaturesIds():
if not fidList == "":
fidList += ", "

fidList += str(fid)

raise GeoAlgorithmExecutionException("Could not eliminate features with these ids:\n%s" % (fidList))
else:
raise GeoAlgorithmExecutionException("Could not add features")

# stop editing outLayer and commit any pending changes
self.saveChanges(outLayer)

def saveChanges(self, outLayer):
if not outLayer.commitChanges():
msg = ""
for aStrm in outLayer.commitErrors():
msg = msg + "\n" + aStrm
outLayer.rollBack()
raise GeoAlgorithmExecutionException("Commit error:\n%s" % (msg))

def checkParameterValuesBeforeExecuting(self):
inLayer = dataobjects.getObjectFromUri(self.getParameterValue(self.INPUT))
if inLayer.selectedFeatureCount() == 0:
return "No selection in input layer"

4 changes: 0 additions & 4 deletions python/plugins/processing/algs/ftools/ExtentFromLayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,11 @@
__revision__ = '$Format:%H$'

from PyQt4.QtCore import *

from qgis.core import *

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

from processing.parameters.ParameterVector import ParameterVector
from processing.parameters.ParameterBoolean import ParameterBoolean

from processing.outputs.OutputVector import OutputVector

class ExtentFromLayer(GeoAlgorithm):
Expand Down
5 changes: 0 additions & 5 deletions python/plugins/processing/algs/ftools/ExtractNodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ class ExtractNodes(GeoAlgorithm):
INPUT = "INPUT"
OUTPUT = "OUTPUT"

#===========================================================================
# def getIcon(self):
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/extract_nodes.png")
#===========================================================================

def defineCharacteristics(self):
self.name = "Extract nodes"
self.group = "Vector geometry tools"
Expand Down
5 changes: 0 additions & 5 deletions python/plugins/processing/algs/ftools/FixedDistanceBuffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,13 @@
__revision__ = '$Format:%H$'

from PyQt4.QtCore import *

from qgis.core import *

from processing.core.GeoAlgorithm import GeoAlgorithm
from processing.tools import dataobjects

from processing.parameters.ParameterVector import ParameterVector
from processing.parameters.ParameterBoolean import ParameterBoolean
from processing.parameters.ParameterNumber import ParameterNumber

from processing.outputs.OutputVector import OutputVector

from processing.algs.ftools import Buffer as buff

class FixedDistanceBuffer(GeoAlgorithm):
Expand Down
5 changes: 0 additions & 5 deletions python/plugins/processing/algs/ftools/Intersection.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ class Intersection(GeoAlgorithm):
INPUT2 = "INPUT2"
OUTPUT = "OUTPUT"

#===========================================================================
# def getIcon(self):
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/intersect.png")
#===========================================================================

def processAlgorithm(self, progress):
vlayerA = dataobjects.getObjectFromUri(self.getParameterValue(Intersection.INPUT))
vlayerB = dataobjects.getObjectFromUri(self.getParameterValue(Intersection.INPUT2))
Expand Down
5 changes: 0 additions & 5 deletions python/plugins/processing/algs/ftools/LinesIntersection.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@ class LinesIntersection(GeoAlgorithm):

OUTPUT = "OUTPUT"

#===========================================================================
# def getIcon(self):
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/intersections.png")
#===========================================================================

def defineCharacteristics(self):
self.name = "Line intersections"
self.group = "Vector overlay tools"
Expand Down
5 changes: 0 additions & 5 deletions python/plugins/processing/algs/ftools/LinesToPolygons.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ class LinesToPolygons(GeoAlgorithm):
INPUT = "INPUT"
OUTPUT = "OUTPUT"

#===========================================================================
# def getIcon(self):
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/to_lines.png")
#===========================================================================

def defineCharacteristics(self):
self.name = "Lines to polygons"
self.group = "Vector geometry tools"
Expand Down
5 changes: 0 additions & 5 deletions python/plugins/processing/algs/ftools/MeanCoords.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ class MeanCoords(GeoAlgorithm):
UID = "UID"
WEIGHT = "WEIGHT"

#===========================================================================
# def getIcon(self):
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/mean.png")
#===========================================================================

def defineCharacteristics(self):
self.name = "Mean coordinate(s)"
self.group = "Vector analysis tools"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,11 @@
__revision__ = '$Format:%H$'

from PyQt4.QtCore import *

from qgis.core import *

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

from processing.parameters.ParameterVector import ParameterVector

from processing.outputs.OutputVector import OutputVector

class MultipartToSingleparts(GeoAlgorithm):
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/core/ProcessingConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def getSettings():

@staticmethod
def configFile():
return os.path.join(userFolder(), "processing_qgis.conf")
return os.path.join(userFolder(), "processing.conf")

@staticmethod
def loadSettings():
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/core/ProcessingLog.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def startLogging():

@staticmethod
def logFilename():
batchfile = userFolder() + os.sep + "processing_qgis.log"
batchfile = userFolder() + os.sep + "processing.log"
return batchfile

@staticmethod
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/processing/grass/description/v.overlay.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
v.overlay
v.overlay - Overlays two vector maps.
Vector (v.*)
ParameterVector|ainput|Input layer (A)|2|False
ParameterVector|ainput|Input layer (A)|-1|False
ParameterSelection|atype|Input layer (A) Type|area;line
ParameterVector|binput|Input layer (B)|2|False
ParameterSelection|operator|Operator to use|and;or;not;xor
ParameterBoolean|-t|Do not create attribute table|False
OutputVector|output|Overlay

1 change: 0 additions & 1 deletion python/plugins/processing/gui/Postprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ def handleAlgorithmResults(alg, progress, showResults = True):
dataobjects.load(out.value, name, alg.crs, RenderingStyles.getStyle(alg.commandLineName(),out.name))
except Exception, e:
wrongLayers.append(out)
#QMessageBox.critical(None, "Error", str(e))
elif isinstance(out, OutputHTML):
ProcessingResults.addResult(out.description, out.value)
htmlResults = True
Expand Down
Loading