Skip to content
Permalink
Browse files

[processing] added extent as output type and made it available in mod…

…eler
  • Loading branch information
volaya committed Sep 2, 2013
1 parent 1655f8e commit d9a9620932debe9cf566414ad8245ae8346ce0dc
@@ -322,7 +322,7 @@ def setParameterValue(self, paramName, value):
def setOutputValue(self, outputName, value):
for out in self.outputs:
if out.name == outputName:
out.value = value
out.setValue(value)

def getVisibleOutputsCount(self):
'''returns the number of non-hidden outputs'''
@@ -16,6 +16,7 @@
* *
***************************************************************************
"""
from processing.outputs.OutputExtent import OutputExtent

__author__ = 'Victor Olaya'
__date__ = 'August 2012'
@@ -282,7 +283,23 @@ def getExtents(self):
params = self.model.parameters
for param in params:
if isinstance(param, ParameterExtent):
extents.append(AlgorithmAndParameter(AlgorithmAndParameter.PARENT_MODEL_ALGORITHM, param.name, "", param.description))
extents.append(AlgorithmAndParameter(AlgorithmAndParameter.PARENT_MODEL_ALGORITHM, param.name, "", param.description))


if self.algIndex is None:
dependent = []
else:
dependent = self.model.getDependentAlgorithms(self.algIndex)
#dependent.append(self.algIndex)

i=0
for alg in self.model.algs:
if i not in dependent:
for out in alg.outputs:
if isinstance(out, OutputExtent):
extents.append(AlgorithmAndParameter(i, out.name, alg.name, out.description))
i+=1

return extents

def getNumbers(self):
@@ -16,6 +16,7 @@
* *
***************************************************************************
"""
from processing.outputs.OutputExtent import OutputExtent
__author__ = 'Victor Olaya'
__date__ = 'January 2013'
__copyright__ = '(C) 2012, Victor Olaya'
@@ -34,6 +35,7 @@ class VectorLayerBoundsAlgorithm(GeoAlgorithm):
XMAX = "XMAX"
YMIN = "YMIN"
YMAX = "YMAX"
EXTENT = "EXTENT"

def defineCharacteristics(self):
self.showInModeler = True
@@ -45,6 +47,7 @@ def defineCharacteristics(self):
self.addOutput(OutputNumber(self.XMAX, "max X"))
self.addOutput(OutputNumber(self.YMIN, "min Y"))
self.addOutput(OutputNumber(self.YMAX, "max Y"))
self.addOutput(OutputExtent(self.EXTENT, "Extent"))

def processAlgorithm(self, progress):
uri = self.getParameterValue(self.LAYER)
@@ -53,4 +56,6 @@ def processAlgorithm(self, progress):
self.setOutputValue(self.XMAX, layer.extent().xMaximum())
self.setOutputValue(self.YMIN, layer.extent().yMinimum())
self.setOutputValue(self.YMAX, layer.extent().yMaximum())
self.setOutputValue(self.EXTENT,
(layer.extent().xMinimum(), layer.extent().xMaximum(), layer.extent().yMinimum(), layer.extent().yMaximum()))

@@ -0,0 +1,44 @@
# -*- coding: utf-8 -*-

"""
***************************************************************************
OutputNumber.py
---------------------
Date : August 2012
Copyright : (C) 2012 by Victor Olaya
Email : volayaf at gmail dot com
***************************************************************************
* *
* 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. *
* *
***************************************************************************
"""

__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.outputs.Output import Output

class OutputExtent(Output):

def __init__(self, name="", description=""):
self.name = name
self.description = description
self.value = None
self.hidden = True

def setValue(self, value):
try:
if value != None and isinstance(value, basestring):
value = value.strip()
else:
self.value = ",".join([str(v) for v in value])
return True
except:
return False

0 comments on commit d9a9620

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