Navigation Menu

Skip to content

Commit

Permalink
init random generator before creating points
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed May 16, 2014
1 parent 9f4e107 commit 9b4b1df
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
2 changes: 2 additions & 0 deletions python/plugins/processing/algs/qgis/RandomPointsExtent.py
Expand Up @@ -83,6 +83,8 @@ def processAlgorithm(self, progress):
index = QgsSpatialIndex()
points = dict()

random.seed()

while nIterations < maxIterations and nPoints < pointCount:
rx = xMin + (xMax - xMin) * random.random()
ry = yMin + (yMax - yMin) * random.random()
Expand Down
2 changes: 2 additions & 0 deletions python/plugins/processing/algs/qgis/RandomPointsLayer.py
Expand Up @@ -84,6 +84,8 @@ def processAlgorithm(self, progress):

request = QgsFeatureRequest()

random.seed()

while nIterations < maxIterations and nPoints < pointCount:
rx = bbox.xMinimum() + bbox.width() * random.random()
ry = bbox.yMinimum() + bbox.height() * random.random()
Expand Down
Expand Up @@ -80,10 +80,9 @@ def processAlgorithm(self, progress):
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
fields, QGis.WKBPoint, layer.dataProvider().crs())


request = QgsFeatureRequest()

da = QgsDistanceArea()

features = vector.features(layer)
for current, f in enumerate(features):
fGeom = QgsGeometry(f.geometry())
Expand All @@ -101,6 +100,8 @@ def processAlgorithm(self, progress):
maxIterations = pointCount * 200
total = 100.0 / pointCount

random.seed()

while nIterations < maxIterations and nPoints < pointCount:
rx = bbox.xMinimum() + bbox.width() * random.random()
ry = bbox.yMinimum() + bbox.height() * random.random()
Expand Down
Expand Up @@ -82,8 +82,8 @@ def processAlgorithm(self, progress):
fields, QGis.WKBPoint, layer.dataProvider().crs())

request = QgsFeatureRequest()

da = QgsDistanceArea()

features = vector.features(layer)
for current, f in enumerate(features):
fGeom = QgsGeometry(f.geometry())
Expand All @@ -101,6 +101,8 @@ def processAlgorithm(self, progress):
maxIterations = pointCount * 200
total = 100.0 / pointCount

random.seed()

while nIterations < maxIterations and nPoints < pointCount:
rx = bbox.xMinimum() + bbox.width() * random.random()
ry = bbox.yMinimum() + bbox.height() * random.random()
Expand Down

0 comments on commit 9b4b1df

Please sign in to comment.