Skip to content

Commit ccea540

Browse files
committedJul 29, 2011
[BACKPORT]fix RandomPoints crash when there are NULL values in
attributes
1 parent f3d5387 commit ccea540

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed
 

‎python/plugins/fTools/tools/doRandPoints.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def outFile(self):
132132
if self.shapefileName is None or self.encoding is None:
133133
return
134134
self.outShape.setText( QString( self.shapefileName ) )
135-
135+
136136
# combine all polygons in layer to create single polygon (slow for complex polygons)
137137
def createSinglePolygon(self, vlayer):
138138
provider = vlayer.dataProvider()
@@ -153,13 +153,15 @@ def createSinglePolygon(self, vlayer):
153153
count = count + add
154154
self.progressBar.setValue(count)
155155
return geom
156-
156+
157157
# Generate list of random points
158158
def simpleRandom(self, n, bound, xmin, xmax, ymin, ymax):
159159
seed()
160160
points = []
161161
i = 1
162162
count = 40.00
163+
if n == 0:
164+
return []
163165
add = ( 70.00 - 40.00 ) / n
164166
while i <= n:
165167
pGeom = QgsGeometry().fromPoint(QgsPoint(xmin + (xmax-xmin) * random(), ymin + (ymax-ymin) * random()))
@@ -225,8 +227,8 @@ def randomize(self, inLayer, outPath, minimum, design, value):
225227
count = count + add
226228
self.progressBar.setValue(count)
227229
del writer
228-
229-
#
230+
231+
#
230232
def loopThruPolygons(self, inLayer, numRand, design):
231233
sProvider = inLayer.dataProvider()
232234
sAllAttrs = sProvider.attributeIndexes()

0 commit comments

Comments
 (0)
Please sign in to comment.