mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-16 00:03:12 -04:00
[BACKPORT]fix RandomPoints crash when there are NULL values in
attributes
This commit is contained in:
parent
f3d5387edb
commit
ccea540242
@ -132,7 +132,7 @@ class Dialog(QDialog, Ui_Dialog):
|
|||||||
if self.shapefileName is None or self.encoding is None:
|
if self.shapefileName is None or self.encoding is None:
|
||||||
return
|
return
|
||||||
self.outShape.setText( QString( self.shapefileName ) )
|
self.outShape.setText( QString( self.shapefileName ) )
|
||||||
|
|
||||||
# combine all polygons in layer to create single polygon (slow for complex polygons)
|
# combine all polygons in layer to create single polygon (slow for complex polygons)
|
||||||
def createSinglePolygon(self, vlayer):
|
def createSinglePolygon(self, vlayer):
|
||||||
provider = vlayer.dataProvider()
|
provider = vlayer.dataProvider()
|
||||||
@ -153,13 +153,15 @@ class Dialog(QDialog, Ui_Dialog):
|
|||||||
count = count + add
|
count = count + add
|
||||||
self.progressBar.setValue(count)
|
self.progressBar.setValue(count)
|
||||||
return geom
|
return geom
|
||||||
|
|
||||||
# Generate list of random points
|
# Generate list of random points
|
||||||
def simpleRandom(self, n, bound, xmin, xmax, ymin, ymax):
|
def simpleRandom(self, n, bound, xmin, xmax, ymin, ymax):
|
||||||
seed()
|
seed()
|
||||||
points = []
|
points = []
|
||||||
i = 1
|
i = 1
|
||||||
count = 40.00
|
count = 40.00
|
||||||
|
if n == 0:
|
||||||
|
return []
|
||||||
add = ( 70.00 - 40.00 ) / n
|
add = ( 70.00 - 40.00 ) / n
|
||||||
while i <= n:
|
while i <= n:
|
||||||
pGeom = QgsGeometry().fromPoint(QgsPoint(xmin + (xmax-xmin) * random(), ymin + (ymax-ymin) * random()))
|
pGeom = QgsGeometry().fromPoint(QgsPoint(xmin + (xmax-xmin) * random(), ymin + (ymax-ymin) * random()))
|
||||||
@ -225,8 +227,8 @@ class Dialog(QDialog, Ui_Dialog):
|
|||||||
count = count + add
|
count = count + add
|
||||||
self.progressBar.setValue(count)
|
self.progressBar.setValue(count)
|
||||||
del writer
|
del writer
|
||||||
|
|
||||||
#
|
#
|
||||||
def loopThruPolygons(self, inLayer, numRand, design):
|
def loopThruPolygons(self, inLayer, numRand, design):
|
||||||
sProvider = inLayer.dataProvider()
|
sProvider = inLayer.dataProvider()
|
||||||
sAllAttrs = sProvider.attributeIndexes()
|
sAllAttrs = sProvider.attributeIndexes()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user