Skip to content

Commit

Permalink
[sextante] allow to select multiple geometry types for ParameterVector
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed Aug 6, 2013
1 parent a2776da commit 470c9d0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions python/plugins/sextante/core/QGisLayers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions python/plugins/sextante/parameters/ParameterVector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.