Skip to content
Permalink
Browse files

correctly handle WMS rasters in Random Points tool (fix #5202)

  • Loading branch information
alexbruy committed May 22, 2012
1 parent c94269c commit 860f3708bbf8e3a2f1f4e7e427bf7f67670951ac
Showing with 13 additions and 3 deletions.
  1. +3 −3 python/plugins/fTools/tools/doRandPoints.py
  2. +10 −0 python/plugins/fTools/tools/ftools_utils.py
@@ -79,7 +79,7 @@ def update(self, inputLayer):
self.cmbField.setEnabled(False)
self.label_4.setEnabled(False)

# when 'OK' button is pressed, gather required inputs, and initiate random points generation
# when 'OK' button is pressed, gather required inputs, and initiate random points generation
def accept(self):
self.buttonOk.setEnabled( False )
if self.inShape.currentText() == "":
@@ -100,7 +100,7 @@ def accept(self):
self.progressBar.setValue(5)
mLayer = ftools_utils.getMapLayerByName(unicode(inName))
if mLayer.type() == mLayer.VectorLayer:
inLayer = QgsVectorLayer(unicode(mLayer.source()), unicode(mLayer.name()), unicode(mLayer.dataProvider().name()))
inLayer = ftools_utils.getVectorLayerByName(unicode(inName))
if self.rdoUnstratified.isChecked():
design = self.tr("unstratified")
value = self.spnUnstratified.value()
@@ -114,7 +114,7 @@ def accept(self):
design = self.tr("field")
value = unicode(self.cmbField.currentText())
elif mLayer.type() == mLayer.RasterLayer:
inLayer = QgsRasterLayer(unicode(mLayer.source()), unicode(mLayer.name()))
inLayer = ftools_utils.getRasterLayerByName(unicode(inName))
design = self.tr("unstratified")
value = self.spnUnstratified.value()
else:
@@ -206,6 +206,16 @@ def getVectorLayerByName( myName ):
else:
return None

# Return QgsRasterLayer from a layer name ( as string )
def getRasterLayerByName( myName ):
layermap = QgsMapLayerRegistry.instance().mapLayers()
for name, layer in layermap.iteritems():
if layer.type() == QgsMapLayer.RasterLayer and layer.name() == myName:
if layer.isValid():
return layer
else:
return None

# Return QgsMapLayer from a layer name ( as string )
def getMapLayerByName( myName ):
layermap = QgsMapLayerRegistry.instance().mapLayers()

0 comments on commit 860f370

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