1
1
#-----------------------------------------------------------
2
- #
2
+ #
3
3
# Random selection within subsets
4
4
#
5
- # A QGIS plugin for randomly selecting features from
5
+ # A QGIS plugin for randomly selecting features from
6
6
# within multiple user defined subsets based on an input field.
7
7
#
8
8
# Copyright (C) 2008 Carson Farmer
11
11
# WEB : www.geog.uvic.ca/spar/carson
12
12
#
13
13
#-----------------------------------------------------------
14
- #
14
+ #
15
15
# licensed under the terms of GNU GPL 2
16
- #
16
+ #
17
17
# This program is free software; you can redistribute it and/or modify
18
18
# it under the terms of the GNU General Public License as published by
19
19
# the Free Software Foundation; either version 2 of the License, or
20
20
# (at your option) any later version.
21
- #
21
+ #
22
22
# This program is distributed in the hope that it will be useful,
23
23
# but WITHOUT ANY WARRANTY; without even the implied warranty of
24
24
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25
25
# GNU General Public License for more details.
26
- #
26
+ #
27
27
# You should have received a copy of the GNU General Public License along
28
28
# with this program; if not, write to the Free Software Foundation, Inc.,
29
29
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
30
- #
30
+ #
31
31
#--------------------------------------------------------------------
32
32
from PyQt4 .QtCore import *
33
33
from PyQt4 .QtGui import *
@@ -42,7 +42,7 @@ def __init__(self, iface):
42
42
self .iface = iface
43
43
# Set up the user interface from Designer.
44
44
self .setupUi (self )
45
- QObject .connect (self .inShape , SIGNAL ("currentIndexChanged(QString)" ), self .update )
45
+ QObject .connect (self .inShape , SIGNAL ("currentIndexChanged(QString)" ), self .update )
46
46
self .setWindowTitle (self .tr ("Random selection within subsets" ))
47
47
# populate layer list
48
48
self .progressBar .setValue (0 )
@@ -58,6 +58,8 @@ def update(self, inputLayer):
58
58
changedField = self .getFieldList (changedLayer )
59
59
for i in changedField :
60
60
self .inField .addItem (unicode (changedField [i ].name ()))
61
+ maxFeatures = changedLayer .dataProvider ().featureCount ()
62
+ self .spnNumber .setMaximum ( maxFeatures )
61
63
62
64
def accept (self ):
63
65
if self .inShape .currentText () == "" :
@@ -158,7 +160,7 @@ def getFieldList(self, vlayer):
158
160
return myFields
159
161
160
162
def getUniqueValues (self , provider , index ):
161
- allAttrs = provider .attributeIndexes ()
163
+ allAttrs = provider .attributeIndexes ()
162
164
provider .select (allAttrs )
163
165
feat = QgsFeature ()
164
166
values = []
0 commit comments