Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[BACKPORT]fix RandomPoints crash when there are NULL values in
attributes
  • Loading branch information
alexbruy committed Jul 29, 2011
1 parent 299b933 commit 5ff54ab
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions python/plugins/fTools/tools/doRandPoints.py
Expand Up @@ -132,7 +132,7 @@ def outFile(self):
if self.shapefileName is None or self.encoding is None:
return
self.outShape.setText( QString( self.shapefileName ) )

# combine all polygons in layer to create single polygon (slow for complex polygons)
def createSinglePolygon(self, vlayer):
provider = vlayer.dataProvider()
Expand All @@ -153,13 +153,15 @@ def createSinglePolygon(self, vlayer):
count = count + add
self.progressBar.setValue(count)
return geom

# Generate list of random points
def simpleRandom(self, n, bound, xmin, xmax, ymin, ymax):
seed()
points = []
i = 1
count = 40.00
if n == 0:
return []
add = ( 70.00 - 40.00 ) / n
while i <= n:
pGeom = QgsGeometry().fromPoint(QgsPoint(xmin + (xmax-xmin) * random(), ymin + (ymax-ymin) * random()))
Expand Down Expand Up @@ -225,8 +227,8 @@ def randomize(self, inLayer, outPath, minimum, design, value):
count = count + add
self.progressBar.setValue(count)
del writer
#

#
def loopThruPolygons(self, inLayer, numRand, design):
sProvider = inLayer.dataProvider()
sAllAttrs = sProvider.attributeIndexes()
Expand Down

0 comments on commit 5ff54ab

Please sign in to comment.