Skip to content
Permalink
Browse files
[sextante] allow to select multiple geometry types for ParameterVector
  • Loading branch information
alexbruy committed Aug 6, 2013
1 parent a2776da commit 470c9d0683470e75f920cbe881cc614768d218fa
Showing with 7 additions and 7 deletions.
  1. +3 −3 python/plugins/sextante/core/QGisLayers.py
  2. +4 −4 python/plugins/sextante/parameters/ParameterVector.py
@@ -76,12 +76,12 @@ def getRasterLayers():
return raster

@staticmethod
def getVectorLayers(shapetype=-1):
def getVectorLayers(shapetype=[-1]):
layers = QGisLayers.iface.legendInterface().layers()
vector = list()
vector = []
for layer in layers:
if layer.type() == layer.VectorLayer:
if shapetype == QGisLayers.ALL_TYPES or layer.geometryType() == shapetype:
if shapetype == QGisLayers.ALL_TYPES or layer.geometryType() in shapetype:
uri = unicode(layer.source())
if not uri.lower().endswith("csv") and not uri.lower().endswith("dbf"):
vector.append(layer)
@@ -36,7 +36,7 @@ class ParameterVector(ParameterDataObject):
VECTOR_TYPE_POLYGON = 2
VECTOR_TYPE_ANY = -1

def __init__(self, name="", description="", shapetype=-1, optional=False):
def __init__(self, name="", description="", shapetype=[-1], optional=False):
ParameterDataObject.__init__(self, name, description)
self.optional = optional
self.shapetype = shapetype
@@ -92,11 +92,11 @@ def getFileFilter(self):

def serialize(self):
return self.__module__.split(".")[-1] + "|" + self.name + "|" + self.description +\
"|" + str(self.shapetype) + "|" + str(self.optional)
"|" + ",".join(str(t) for t in self.shapetype) + "|" + str(self.optional)

def deserialize(self, s):
tokens = s.split("|")
return ParameterVector(tokens[1], tokens[2], int(tokens[3]), str(True) == tokens[4])
return ParameterVector(tokens[1], tokens[2], [int(t) for t in tokens[3].split(",")], str(True) == tokens[4])

def getAsScriptCode(self):
return "##" + self.name + "=vector"
return "##" + self.name + "=vector"

0 comments on commit 470c9d0

Please sign in to comment.