Skip to content

Commit

Permalink
[processing] fixed behaviour of select algorithms in modeler
Browse files Browse the repository at this point in the history
  • Loading branch information
volaya committed Jun 20, 2014
1 parent 2e858c4 commit b390b3e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
Expand Up @@ -46,7 +46,6 @@ class SelectByLocation(GeoAlgorithm):


def defineCharacteristics(self):
self.allowOnlyOpenedLayers = True
self.name = 'Select by location'
self.group = 'Vector selection tools'
self.addParameter(ParameterVector(self.INPUT, 'Layer to select from',
Expand Down
Expand Up @@ -1059,7 +1059,6 @@ class mmqgisx_select_algorithm(GeoAlgorithm):
RESULT = 'RESULT'

def defineCharacteristics(self):
self.allowOnlyOpenedLayers = True
self.name = 'Select by attribute'
self.group = 'Vector selection tools'

Expand Down Expand Up @@ -1087,8 +1086,7 @@ def defineCharacteristics(self):
def processAlgorithm(self, progress):

filename = self.getParameterValue(self.LAYERNAME)
layer = dataobjects.getObjectFromUri(filename)

layer = dataobjects.getObjectFromUri(filename)
attribute = self.getParameterValue(self.ATTRIBUTE)
comparison = self.comparisons[self.getParameterValue(self.COMPARISON)]
comparisonvalue = self.getParameterValue(self.COMPARISONVALUE)
Expand Down
11 changes: 11 additions & 0 deletions python/plugins/processing/tools/dataobjects.py
Expand Up @@ -36,6 +36,12 @@

ALL_TYPES = [-1]

_loadedLayers = {}

def resetLoadedLayers():
global _loadedLayers
_loadedLayers = {}

def getSupportedOutputVectorLayerExtensions():
formats = QgsVectorFileWriter.supportedFiltersAndFormats()
exts = ['shp'] # shp is the default, should be the first
Expand Down Expand Up @@ -206,6 +212,9 @@ def getObjectFromUri(uri, forceLoad=True):

if uri is None:
return None
print _loadedLayers
if uri in _loadedLayers:
return _loadedLayers[uri]
layers = getRasterLayers()
for layer in layers:
if layer.source() == uri:
Expand All @@ -228,11 +237,13 @@ def getObjectFromUri(uri, forceLoad=True):
if layer.isValid():
if prjSetting:
settings.setValue('/Projections/defaultBehaviour', prjSetting)
_loadedLayers[layer.source()] = layer
return layer
layer = QgsRasterLayer(uri, uri)
if layer.isValid():
if prjSetting:
settings.setValue('/Projections/defaultBehaviour', prjSetting)
_loadedLayers[layer.source()] = layer
return layer
if prjSetting:
settings.setValue('/Projections/defaultBehaviour', prjSetting)
Expand Down

0 comments on commit b390b3e

Please sign in to comment.