Skip to content

Commit 6274cd1

Browse files
committedNov 12, 2011
Merge branch 'master' of github.com:qgis/Quantum-GIS
2 parents cf7b989 + d3fe194 commit 6274cd1

27 files changed

+692
-103
lines changed
 

‎python/plugins/fTools/__init__.py

100755100644
File mode changed.

‎python/plugins/fTools/fTools.py

100755100644
+25-7
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
import doIntersectLines, doSelectByLocation, doVectorSplit, doMeanCoords
4444
import doPointDistance, doPointsInPolygon, doRandom, doRandPoints, doRegPoints
4545
import doSpatialJoin, doSubsetSelect, doSumLines, doVectorGrid, doMergeShapes
46-
import doValidate, doSimplify, doDefineProj
46+
import doValidate, doSimplify, doDefineProj, doSpatialIndex
4747

4848
class fToolsPlugin:
4949
def __init__(self,iface):
@@ -103,6 +103,7 @@ def updateThemeIcons(self, theme):
103103
self.voronoi.setIcon(QIcon(self.getThemeIcon("voronoi.png")))
104104
self.extNodes.setIcon(QIcon(self.getThemeIcon("extract_nodes.png")))
105105
self.simplify.setIcon(QIcon(self.getThemeIcon("simplify.png")))
106+
self.densify.setIcon(QIcon(self.getThemeIcon("densify.png")))
106107
self.multiToSingle.setIcon(QIcon(self.getThemeIcon("multi_to_single.png")))
107108
self.singleToMulti.setIcon(QIcon(self.getThemeIcon("single_to_multi.png")))
108109
self.polysToLines.setIcon(QIcon(self.getThemeIcon("to_lines.png")))
@@ -113,6 +114,7 @@ def updateThemeIcons(self, theme):
113114
self.spatJoin.setIcon(QIcon(self.getThemeIcon("join_location.png")))
114115
self.splitVect.setIcon(QIcon(self.getThemeIcon("split_layer.png")))
115116
self.mergeShapes.setIcon(QIcon(self.getThemeIcon("merge_shapes.png")))
117+
self.spatialIndex.setIcon(QIcon(self.getThemeIcon("spatial_index.png")))
116118

117119
def initGui(self):
118120
if int(self.QgisVersion) < 1:
@@ -167,19 +169,22 @@ def initGui(self):
167169
self.voronoi = QAction(QCoreApplication.translate("fTools", "Voronoi Polygons"),self.iface.mainWindow())
168170
self.extNodes = QAction(QCoreApplication.translate("fTools", "Extract nodes"),self.iface.mainWindow())
169171
self.simplify = QAction(QCoreApplication.translate("fTools", "Simplify geometries"),self.iface.mainWindow())
172+
self.densify = QAction(QCoreApplication.translate("fTools", "Densify geometries"),self.iface.mainWindow())
170173
self.multiToSingle = QAction(QCoreApplication.translate("fTools", "Multipart to singleparts"),self.iface.mainWindow())
171174
self.singleToMulti = QAction(QCoreApplication.translate("fTools", "Singleparts to multipart"),self.iface.mainWindow())
172175
self.polysToLines = QAction(QCoreApplication.translate("fTools", "Polygons to lines"),self.iface.mainWindow())
173176
self.linesToPolys = QAction(QCoreApplication.translate("fTools", "Lines to polygons"),self.iface.mainWindow())
174177
self.conversionMenu.addActions([self.checkGeom, self.compGeo, self.centroids, self.delaunay, self.voronoi,
175-
self.simplify, self.multiToSingle, self.singleToMulti, self.polysToLines, self.linesToPolys, self.extNodes])
178+
self.simplify, self.densify, self.multiToSingle, self.singleToMulti, self.polysToLines, self.linesToPolys,
179+
self.extNodes])
176180

177181
self.dataManageMenu = QMenu(QCoreApplication.translate("fTools", "&Data Management Tools"))
178182
self.define = QAction(QCoreApplication.translate("fTools", "Define current projection"), self.iface.mainWindow())
179183
self.spatJoin = QAction(QCoreApplication.translate("fTools", "Join attributes by location"), self.iface.mainWindow())
180184
self.splitVect = QAction(QCoreApplication.translate("fTools", "Split vector layer"), self.iface.mainWindow())
181185
self.mergeShapes = QAction(QCoreApplication.translate("fTools", "Merge shapefiles to one"), self.iface.mainWindow())
182-
self.dataManageMenu.addActions([self.define, self.spatJoin, self.splitVect, self.mergeShapes])
186+
self.spatialIndex = QAction(QCoreApplication.translate("fTools", "Create spatial index"), self.iface.mainWindow())
187+
self.dataManageMenu.addActions([self.define, self.spatJoin, self.splitVect, self.mergeShapes, self.spatialIndex])
183188
self.updateThemeIcons("theme")
184189

185190
self.menu.addMenu(self.analysisMenu)
@@ -222,7 +227,8 @@ def initGui(self):
222227
QObject.connect(self.multiToSingle, SIGNAL("triggered()"), self.domultiToSingle)
223228
QObject.connect(self.singleToMulti, SIGNAL("triggered()"), self.dosingleToMulti)
224229
QObject.connect(self.checkGeom, SIGNAL("triggered()"), self.docheckGeom)
225-
QObject.connect(self.simplify, SIGNAL("triggered()"), self.dosimplify)
230+
QObject.connect(self.simplify, SIGNAL("triggered()"), self.doSimplify)
231+
QObject.connect(self.densify, SIGNAL("triggered()"), self.doDensify)
226232
QObject.connect(self.centroids, SIGNAL("triggered()"), self.docentroids)
227233
QObject.connect(self.delaunay, SIGNAL("triggered()"), self.dodelaunay)
228234
QObject.connect(self.voronoi, SIGNAL("triggered()"), self.dovoronoi)
@@ -235,12 +241,19 @@ def initGui(self):
235241
QObject.connect(self.spatJoin, SIGNAL("triggered()"), self.dospatJoin)
236242
QObject.connect(self.splitVect, SIGNAL("triggered()"), self.dosplitVect)
237243
QObject.connect(self.mergeShapes, SIGNAL("triggered()"), self.doMergeShapes)
244+
QObject.connect(self.spatialIndex, SIGNAL("triggered()"), self.doSpatIndex)
238245

239246
def unload(self):
240247
pass
241248

242-
def dosimplify(self):
243-
d = doSimplify.Dialog(self.iface)
249+
def doSimplify(self):
250+
d = doSimplify.Dialog(self.iface, 1)
251+
d.show()
252+
d.exec_()
253+
254+
def doDensify(self):
255+
d = doSimplify.Dialog(self.iface, 2)
256+
d.show()
244257
d.exec_()
245258

246259
def dopolysToLines(self):
@@ -319,7 +332,7 @@ def docentroids(self):
319332
def dodelaunay(self):
320333
d = doGeometry.GeometryDialog(self.iface, 8)
321334
d.exec_()
322-
335+
323336
def dovoronoi(self):
324337
d = doGeometry.GeometryDialog(self.iface, 10)
325338
d.exec_()
@@ -390,5 +403,10 @@ def dospatJoin(self):
390403

391404
def doMergeShapes(self):
392405
d = doMergeShapes.Dialog(self.iface)
406+
d.show()
393407
d.exec_()
394408

409+
def doSpatIndex(self):
410+
d = doSpatialIndex.Dialog(self.iface)
411+
d.show()
412+
d.exec_()

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

100755100644
File mode changed.

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

100755100644
+4-2
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,9 @@ def manageGui(self):
161161
self.cmbField.setVisible( False )
162162
self.field_label.setVisible( False )
163163
self.resize( 381, 100 )
164-
myList = []
164+
self.populateLayers()
165+
166+
def populateLayers( self ):
165167
self.inShape.clear()
166168
if self.myFunction == 3 or self.myFunction == 6:
167169
myList = ftools_utils.getLayerNames( [ QGis.Polygon, QGis.Line ] )
@@ -176,7 +178,6 @@ def manageGui(self):
176178
else:
177179
myList = ftools_utils.getLayerNames( [ QGis.Point, QGis.Line, QGis.Polygon ] )
178180
self.inShape.addItems( myList )
179-
return
180181

181182
#1: Singleparts to multipart
182183
#2: Multipart to singleparts
@@ -241,6 +242,7 @@ def runFinishedFromThread( self, success ):
241242
if addToTOC == QMessageBox.Yes:
242243
if not ftools_utils.addShapeToCanvas( unicode( self.shapefileName ) ):
243244
QMessageBox.warning( self, self.tr("Geoprocessing"), self.tr( "Error loading output shapefile:\n%1" ).arg( unicode( self.shapefileName ) ))
245+
self.populateLayers()
244246
else:
245247
QMessageBox.warning( self, self.tr("Geometry"), self.tr( "Error writing output shapefile." ) )
246248

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

100755100644
+6-3
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,9 @@ def manageGui( self ):
182182
self.label_2.setText( self.tr( "Union layer" ) )
183183
self.setWindowTitle( self.tr( "Union" ) )
184184
self.resize(381, 100)
185+
self.populateLayers()
186+
187+
def populateLayers( self ):
185188
myListA = []
186189
myListB = []
187190
self.inShapeA.clear()
@@ -195,7 +198,6 @@ def manageGui( self ):
195198
myListB = ftools_utils.getLayerNames( [ QGis.Point, QGis.Line, QGis.Polygon ] )
196199
self.inShapeA.addItems( myListA )
197200
self.inShapeB.addItems( myListB )
198-
return
199201

200202
#1: Buffer
201203
#2: Convex Hull
@@ -257,6 +259,7 @@ def runFinishedFromThread( self, results ):
257259
if addToTOC == QMessageBox.Yes:
258260
if not ftools_utils.addShapeToCanvas( unicode( self.shapefileName ) ):
259261
QMessageBox.warning( self, self.tr("Geoprocessing"), self.tr( "Error loading output shapefile:\n%1" ).arg( unicode( self.shapefileName ) ))
262+
self.populateLayers()
260263

261264
def runStatusFromThread( self, status ):
262265
self.progressBar.setValue( status )
@@ -1103,7 +1106,7 @@ def union( self ):
11031106
writer.addFeature( outFeat )
11041107
except:
11051108
FEATURE_EXCEPT = False
1106-
# this really shouldn't happen, as we
1109+
# this really shouldn't happen, as we
11071110
# haven't edited the input geom at all
11081111
# continue
11091112
else:
@@ -1144,7 +1147,7 @@ def union( self ):
11441147
# print str(err)
11451148
FEATURE_EXCEPT = False
11461149
# else:
1147-
# # this only happends if the bounding box
1150+
# # this only happends if the bounding box
11481151
# # intersects, but the geometry doesn't
11491152
# try:
11501153
# outFeat.setGeometry( geom )

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

100755100644
+6-2
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,13 @@ def __init__(self, iface):
4646
QObject.connect(self.inLine2, SIGNAL("currentIndexChanged(QString)"), self.update2)
4747
self.setWindowTitle( self.tr("Line intersections") )
4848
self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok )
49-
# populate layer list
5049
self.progressBar.setValue(0)
51-
mapCanvas = self.iface.mapCanvas()
50+
self.populateLayers()
51+
52+
def populateLayers( self ):
5253
layers = ftools_utils.getLayerNames([QGis.Line])
54+
self.inLine1.clear()
55+
self.inLine2.clear()
5356
self.inLine1.addItems(layers)
5457
self.inLine2.addItems(layers)
5558

@@ -92,6 +95,7 @@ def accept(self):
9295
if addToTOC == QMessageBox.Yes:
9396
if not ftools_utils.addShapeToCanvas( unicode( outPath ) ):
9497
QMessageBox.warning( self, self.tr("Geoprocessing"), self.tr( "Error loading output shapefile:\n%1" ).arg( unicode( outPath ) ))
98+
self.populateLayers()
9599
self.progressBar.setValue(0)
96100
self.buttonOk.setEnabled( True )
97101

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

100755100644
+7-3
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,15 @@ def __init__(self, iface, function):
4545
QObject.connect(self.toolOut, SIGNAL("clicked()"), self.outFile)
4646
QObject.connect(self.inShape, SIGNAL("currentIndexChanged(QString)"), self.update)
4747
self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok )
48-
49-
# populate layer list
5048
self.progressBar.setValue(0)
51-
mapCanvas = self.iface.mapCanvas()
49+
self.populateLayers()
50+
51+
def populateLayers( self ):
5252
layers = ftools_utils.getLayerNames([QGis.Point, QGis.Line, QGis.Polygon])
53+
QObject.disconnect(self.inShape, SIGNAL("currentIndexChanged(QString)"), self.update)
54+
self.inShape.clear()
5355
self.inShape.addItems(layers)
56+
QObject.connect(self.inShape, SIGNAL("currentIndexChanged(QString)"), self.update)
5457

5558
def updateUi(self):
5659
if self.function == 1:
@@ -96,6 +99,7 @@ def accept(self):
9699
if addToTOC == QMessageBox.Yes:
97100
vlayer = QgsVectorLayer(outPath, unicode(outName), "ogr")
98101
QgsMapLayerRegistry.instance().addMapLayer(vlayer)
102+
self.populateLayers()
99103
self.progressBar.setValue(0)
100104
self.buttonOk.setEnabled( True )
101105

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

100755100644
File mode changed.

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

100755100644
File mode changed.

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

100755100644
+8-4
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,18 @@ def __init__(self, iface):
4444
QObject.connect(self.toolOut, SIGNAL("clicked()"), self.outFile)
4545
self.setWindowTitle(self.tr("Count Points in Polygon"))
4646
self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok )
47-
# populate layer list
4847
self.progressBar.setValue(0)
49-
mapCanvas = self.iface.mapCanvas()
48+
self.populateLayers()
49+
50+
def populateLayers( self ):
5051
layers = ftools_utils.getLayerNames([QGis.Polygon])
52+
self.inPolygon.clear()
5153
self.inPolygon.addItems(layers)
54+
55+
self.inPoint.clear()
5256
layers = ftools_utils.getLayerNames([QGis.Point])
5357
self.inPoint.addItems(layers)
54-
58+
5559
def accept(self):
5660
self.buttonOk.setEnabled( False )
5761
if self.inPolygon.currentText() == "":
@@ -79,6 +83,7 @@ def accept(self):
7983
if addToTOC == QMessageBox.Yes:
8084
self.vlayer = QgsVectorLayer(outPath, unicode(outName), "ogr")
8185
QgsMapLayerRegistry.instance().addMapLayer(self.vlayer)
86+
self.populateLayers()
8287
self.progressBar.setValue(0)
8388
self.buttonOk.setEnabled( True )
8489

@@ -112,7 +117,6 @@ def compute(self, inPoly, inPts, inField, outPath, progressBar):
112117
if not QgsVectorFileWriter.deleteShapeFile(self.shapefileName):
113118
return
114119
writer = QgsVectorFileWriter(self.shapefileName, self.encoding, fieldList, polyProvider.geometryType(), sRs)
115-
#writer = QgsVectorFileWriter(outPath, "UTF-8", fieldList, polyProvider.geometryType(), sRs)
116120
inFeat = QgsFeature()
117121
inFeatB = QgsFeature()
118122
outFeat = QgsFeature()

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

100755100644
+8-2
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,14 @@ def __init__(self, iface):
4646
self.progressBar.setValue(0)
4747
self.setWindowTitle(self.tr("Random Points"))
4848
self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok )
49-
self.mapCanvas = self.iface.mapCanvas()
49+
self.populateLayers()
50+
51+
def populateLayers( self ):
5052
layers = ftools_utils.getLayerNames([QGis.Polygon, "Raster"])
53+
QObject.disconnect(self.inShape, SIGNAL("currentIndexChanged(QString)"), self.update)
54+
self.inShape.clear()
5155
self.inShape.addItems(layers)
56+
QObject.connect(self.inShape, SIGNAL("currentIndexChanged(QString)"), self.update)
5257

5358
# If input layer is changed, update field list
5459
def update(self, inputLayer):
@@ -123,6 +128,7 @@ def accept(self):
123128
if addToTOC == QMessageBox.Yes:
124129
self.vlayer = QgsVectorLayer(outPath, unicode(outName), "ogr")
125130
QgsMapLayerRegistry.instance().addMapLayer(self.vlayer)
131+
self.populateLayers()
126132
self.progressBar.setValue(0)
127133
self.buttonOk.setEnabled( True )
128134

@@ -208,7 +214,7 @@ def randomize(self, inLayer, outPath, minimum, design, value):
208214
points = self.vectorRandom(int(value), inLayer,
209215
ext.xMinimum(), ext.xMaximum(), ext.yMinimum(), ext.yMaximum())
210216
else: points = self.loopThruPolygons(inLayer, value, design)
211-
crs = self.mapCanvas.mapRenderer().destinationSrs()
217+
crs = self.iface.mapCanvas().mapRenderer().destinationSrs()
212218
if not crs.isValid(): crs = None
213219
fields = { 0 : QgsField("ID", QVariant.Int) }
214220
check = QFile(self.shapefileName)

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

100755100644
File mode changed.

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

100755100644
+7-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,11 @@ def __init__(self, iface):
5050
self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok )
5151
self.progressBar.setValue(0)
5252
self.mapCanvas = self.iface.mapCanvas()
53+
self.populateLayers()
54+
55+
def populateLayers( self ):
5356
layers = ftools_utils.getLayerNames("all")
57+
self.inShape.clear()
5458
self.inShape.addItems(layers)
5559

5660
def accept(self):
@@ -89,6 +93,7 @@ def accept(self):
8993
if addToTOC == QMessageBox.Yes:
9094
self.vlayer = QgsVectorLayer(outPath, unicode(outName), "ogr")
9195
QgsMapLayerRegistry.instance().addMapLayer(self.vlayer)
96+
self.populateLayers()
9297
self.progressBar.setValue(0)
9398
self.buttonOk.setEnabled( True )
9499

@@ -98,7 +103,7 @@ def outFile(self):
98103
if self.shapefileName is None or self.encoding is None:
99104
return
100105
self.outShape.setText( QString( self.shapefileName ) )
101-
106+
102107
# Generate list of random points
103108
def simpleRandom(self, n, bound, xmin, xmax, ymin, ymax):
104109
seed()
@@ -109,7 +114,7 @@ def simpleRandom(self, n, bound, xmin, xmax, ymin, ymax):
109114
if pGeom.intersects(bound):
110115
points.append(pGeom)
111116
i = i + 1
112-
return points
117+
return points
113118

114119
def regularize(self, bound, outPath, offset, value, gridType, inset, crs):
115120
area = bound.width() * bound.height()

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

100755100644
File mode changed.

0 commit comments

Comments
 (0)
Please sign in to comment.