Skip to content

Commit

Permalink
Merge branch 'master' of github.com:qgis/Quantum-GIS
Browse files Browse the repository at this point in the history
  • Loading branch information
timlinux committed Nov 12, 2011
2 parents cf7b989 + d3fe194 commit 6274cd1
Show file tree
Hide file tree
Showing 27 changed files with 692 additions and 103 deletions.
Empty file modified python/plugins/fTools/__init__.py 100755 → 100644
Empty file.
32 changes: 25 additions & 7 deletions python/plugins/fTools/fTools.py 100755 → 100644
Expand Up @@ -43,7 +43,7 @@
import doIntersectLines, doSelectByLocation, doVectorSplit, doMeanCoords
import doPointDistance, doPointsInPolygon, doRandom, doRandPoints, doRegPoints
import doSpatialJoin, doSubsetSelect, doSumLines, doVectorGrid, doMergeShapes
import doValidate, doSimplify, doDefineProj
import doValidate, doSimplify, doDefineProj, doSpatialIndex

class fToolsPlugin:
def __init__(self,iface):
Expand Down Expand Up @@ -103,6 +103,7 @@ def updateThemeIcons(self, theme):
self.voronoi.setIcon(QIcon(self.getThemeIcon("voronoi.png")))
self.extNodes.setIcon(QIcon(self.getThemeIcon("extract_nodes.png")))
self.simplify.setIcon(QIcon(self.getThemeIcon("simplify.png")))
self.densify.setIcon(QIcon(self.getThemeIcon("densify.png")))
self.multiToSingle.setIcon(QIcon(self.getThemeIcon("multi_to_single.png")))
self.singleToMulti.setIcon(QIcon(self.getThemeIcon("single_to_multi.png")))
self.polysToLines.setIcon(QIcon(self.getThemeIcon("to_lines.png")))
Expand All @@ -113,6 +114,7 @@ def updateThemeIcons(self, theme):
self.spatJoin.setIcon(QIcon(self.getThemeIcon("join_location.png")))
self.splitVect.setIcon(QIcon(self.getThemeIcon("split_layer.png")))
self.mergeShapes.setIcon(QIcon(self.getThemeIcon("merge_shapes.png")))
self.spatialIndex.setIcon(QIcon(self.getThemeIcon("spatial_index.png")))

def initGui(self):
if int(self.QgisVersion) < 1:
Expand Down Expand Up @@ -167,19 +169,22 @@ def initGui(self):
self.voronoi = QAction(QCoreApplication.translate("fTools", "Voronoi Polygons"),self.iface.mainWindow())
self.extNodes = QAction(QCoreApplication.translate("fTools", "Extract nodes"),self.iface.mainWindow())
self.simplify = QAction(QCoreApplication.translate("fTools", "Simplify geometries"),self.iface.mainWindow())
self.densify = QAction(QCoreApplication.translate("fTools", "Densify geometries"),self.iface.mainWindow())
self.multiToSingle = QAction(QCoreApplication.translate("fTools", "Multipart to singleparts"),self.iface.mainWindow())
self.singleToMulti = QAction(QCoreApplication.translate("fTools", "Singleparts to multipart"),self.iface.mainWindow())
self.polysToLines = QAction(QCoreApplication.translate("fTools", "Polygons to lines"),self.iface.mainWindow())
self.linesToPolys = QAction(QCoreApplication.translate("fTools", "Lines to polygons"),self.iface.mainWindow())
self.conversionMenu.addActions([self.checkGeom, self.compGeo, self.centroids, self.delaunay, self.voronoi,
self.simplify, self.multiToSingle, self.singleToMulti, self.polysToLines, self.linesToPolys, self.extNodes])
self.simplify, self.densify, self.multiToSingle, self.singleToMulti, self.polysToLines, self.linesToPolys,
self.extNodes])

self.dataManageMenu = QMenu(QCoreApplication.translate("fTools", "&Data Management Tools"))
self.define = QAction(QCoreApplication.translate("fTools", "Define current projection"), self.iface.mainWindow())
self.spatJoin = QAction(QCoreApplication.translate("fTools", "Join attributes by location"), self.iface.mainWindow())
self.splitVect = QAction(QCoreApplication.translate("fTools", "Split vector layer"), self.iface.mainWindow())
self.mergeShapes = QAction(QCoreApplication.translate("fTools", "Merge shapefiles to one"), self.iface.mainWindow())
self.dataManageMenu.addActions([self.define, self.spatJoin, self.splitVect, self.mergeShapes])
self.spatialIndex = QAction(QCoreApplication.translate("fTools", "Create spatial index"), self.iface.mainWindow())
self.dataManageMenu.addActions([self.define, self.spatJoin, self.splitVect, self.mergeShapes, self.spatialIndex])
self.updateThemeIcons("theme")

self.menu.addMenu(self.analysisMenu)
Expand Down Expand Up @@ -222,7 +227,8 @@ def initGui(self):
QObject.connect(self.multiToSingle, SIGNAL("triggered()"), self.domultiToSingle)
QObject.connect(self.singleToMulti, SIGNAL("triggered()"), self.dosingleToMulti)
QObject.connect(self.checkGeom, SIGNAL("triggered()"), self.docheckGeom)
QObject.connect(self.simplify, SIGNAL("triggered()"), self.dosimplify)
QObject.connect(self.simplify, SIGNAL("triggered()"), self.doSimplify)
QObject.connect(self.densify, SIGNAL("triggered()"), self.doDensify)
QObject.connect(self.centroids, SIGNAL("triggered()"), self.docentroids)
QObject.connect(self.delaunay, SIGNAL("triggered()"), self.dodelaunay)
QObject.connect(self.voronoi, SIGNAL("triggered()"), self.dovoronoi)
Expand All @@ -235,12 +241,19 @@ def initGui(self):
QObject.connect(self.spatJoin, SIGNAL("triggered()"), self.dospatJoin)
QObject.connect(self.splitVect, SIGNAL("triggered()"), self.dosplitVect)
QObject.connect(self.mergeShapes, SIGNAL("triggered()"), self.doMergeShapes)
QObject.connect(self.spatialIndex, SIGNAL("triggered()"), self.doSpatIndex)

def unload(self):
pass

def dosimplify(self):
d = doSimplify.Dialog(self.iface)
def doSimplify(self):
d = doSimplify.Dialog(self.iface, 1)
d.show()
d.exec_()

def doDensify(self):
d = doSimplify.Dialog(self.iface, 2)
d.show()
d.exec_()

def dopolysToLines(self):
Expand Down Expand Up @@ -319,7 +332,7 @@ def docentroids(self):
def dodelaunay(self):
d = doGeometry.GeometryDialog(self.iface, 8)
d.exec_()

def dovoronoi(self):
d = doGeometry.GeometryDialog(self.iface, 10)
d.exec_()
Expand Down Expand Up @@ -390,5 +403,10 @@ def dospatJoin(self):

def doMergeShapes(self):
d = doMergeShapes.Dialog(self.iface)
d.show()
d.exec_()

def doSpatIndex(self):
d = doSpatialIndex.Dialog(self.iface)
d.show()
d.exec_()
Empty file modified python/plugins/fTools/tools/doDefineProj.py 100755 → 100644
Empty file.
6 changes: 4 additions & 2 deletions python/plugins/fTools/tools/doGeometry.py 100755 → 100644
Expand Up @@ -161,7 +161,9 @@ def manageGui(self):
self.cmbField.setVisible( False )
self.field_label.setVisible( False )
self.resize( 381, 100 )
myList = []
self.populateLayers()

def populateLayers( self ):
self.inShape.clear()
if self.myFunction == 3 or self.myFunction == 6:
myList = ftools_utils.getLayerNames( [ QGis.Polygon, QGis.Line ] )
Expand All @@ -176,7 +178,6 @@ def manageGui(self):
else:
myList = ftools_utils.getLayerNames( [ QGis.Point, QGis.Line, QGis.Polygon ] )
self.inShape.addItems( myList )
return

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

Expand Down
9 changes: 6 additions & 3 deletions python/plugins/fTools/tools/doGeoprocessing.py 100755 → 100644
Expand Up @@ -182,6 +182,9 @@ def manageGui( self ):
self.label_2.setText( self.tr( "Union layer" ) )
self.setWindowTitle( self.tr( "Union" ) )
self.resize(381, 100)
self.populateLayers()

def populateLayers( self ):
myListA = []
myListB = []
self.inShapeA.clear()
Expand All @@ -195,7 +198,6 @@ def manageGui( self ):
myListB = ftools_utils.getLayerNames( [ QGis.Point, QGis.Line, QGis.Polygon ] )
self.inShapeA.addItems( myListA )
self.inShapeB.addItems( myListB )
return

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

def runStatusFromThread( self, status ):
self.progressBar.setValue( status )
Expand Down Expand Up @@ -1103,7 +1106,7 @@ def union( self ):
writer.addFeature( outFeat )
except:
FEATURE_EXCEPT = False
# this really shouldn't happen, as we
# this really shouldn't happen, as we
# haven't edited the input geom at all
# continue
else:
Expand Down Expand Up @@ -1144,7 +1147,7 @@ def union( self ):
# print str(err)
FEATURE_EXCEPT = False
# else:
# # this only happends if the bounding box
# # this only happends if the bounding box
# # intersects, but the geometry doesn't
# try:
# outFeat.setGeometry( geom )
Expand Down
8 changes: 6 additions & 2 deletions python/plugins/fTools/tools/doIntersectLines.py 100755 → 100644
Expand Up @@ -46,10 +46,13 @@ def __init__(self, iface):
QObject.connect(self.inLine2, SIGNAL("currentIndexChanged(QString)"), self.update2)
self.setWindowTitle( self.tr("Line intersections") )
self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok )
# populate layer list
self.progressBar.setValue(0)
mapCanvas = self.iface.mapCanvas()
self.populateLayers()

def populateLayers( self ):
layers = ftools_utils.getLayerNames([QGis.Line])
self.inLine1.clear()
self.inLine2.clear()
self.inLine1.addItems(layers)
self.inLine2.addItems(layers)

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

Expand Down
10 changes: 7 additions & 3 deletions python/plugins/fTools/tools/doMeanCoords.py 100755 → 100644
Expand Up @@ -45,12 +45,15 @@ def __init__(self, iface, function):
QObject.connect(self.toolOut, SIGNAL("clicked()"), self.outFile)
QObject.connect(self.inShape, SIGNAL("currentIndexChanged(QString)"), self.update)
self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok )

# populate layer list
self.progressBar.setValue(0)
mapCanvas = self.iface.mapCanvas()
self.populateLayers()

def populateLayers( self ):
layers = ftools_utils.getLayerNames([QGis.Point, QGis.Line, QGis.Polygon])
QObject.disconnect(self.inShape, SIGNAL("currentIndexChanged(QString)"), self.update)
self.inShape.clear()
self.inShape.addItems(layers)
QObject.connect(self.inShape, SIGNAL("currentIndexChanged(QString)"), self.update)

def updateUi(self):
if self.function == 1:
Expand Down Expand Up @@ -96,6 +99,7 @@ def accept(self):
if addToTOC == QMessageBox.Yes:
vlayer = QgsVectorLayer(outPath, unicode(outName), "ogr")
QgsMapLayerRegistry.instance().addMapLayer(vlayer)
self.populateLayers()
self.progressBar.setValue(0)
self.buttonOk.setEnabled( True )

Expand Down
Empty file modified python/plugins/fTools/tools/doMergeShapes.py 100755 → 100644
Empty file.
Empty file modified python/plugins/fTools/tools/doPointDistance.py 100755 → 100644
Empty file.
12 changes: 8 additions & 4 deletions python/plugins/fTools/tools/doPointsInPolygon.py 100755 → 100644
Expand Up @@ -44,14 +44,18 @@ def __init__(self, iface):
QObject.connect(self.toolOut, SIGNAL("clicked()"), self.outFile)
self.setWindowTitle(self.tr("Count Points in Polygon"))
self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok )
# populate layer list
self.progressBar.setValue(0)
mapCanvas = self.iface.mapCanvas()
self.populateLayers()

def populateLayers( self ):
layers = ftools_utils.getLayerNames([QGis.Polygon])
self.inPolygon.clear()
self.inPolygon.addItems(layers)

self.inPoint.clear()
layers = ftools_utils.getLayerNames([QGis.Point])
self.inPoint.addItems(layers)

def accept(self):
self.buttonOk.setEnabled( False )
if self.inPolygon.currentText() == "":
Expand Down Expand Up @@ -79,6 +83,7 @@ def accept(self):
if addToTOC == QMessageBox.Yes:
self.vlayer = QgsVectorLayer(outPath, unicode(outName), "ogr")
QgsMapLayerRegistry.instance().addMapLayer(self.vlayer)
self.populateLayers()
self.progressBar.setValue(0)
self.buttonOk.setEnabled( True )

Expand Down Expand Up @@ -112,7 +117,6 @@ def compute(self, inPoly, inPts, inField, outPath, progressBar):
if not QgsVectorFileWriter.deleteShapeFile(self.shapefileName):
return
writer = QgsVectorFileWriter(self.shapefileName, self.encoding, fieldList, polyProvider.geometryType(), sRs)
#writer = QgsVectorFileWriter(outPath, "UTF-8", fieldList, polyProvider.geometryType(), sRs)
inFeat = QgsFeature()
inFeatB = QgsFeature()
outFeat = QgsFeature()
Expand Down
10 changes: 8 additions & 2 deletions python/plugins/fTools/tools/doRandPoints.py 100755 → 100644
Expand Up @@ -46,9 +46,14 @@ def __init__(self, iface):
self.progressBar.setValue(0)
self.setWindowTitle(self.tr("Random Points"))
self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok )
self.mapCanvas = self.iface.mapCanvas()
self.populateLayers()

def populateLayers( self ):
layers = ftools_utils.getLayerNames([QGis.Polygon, "Raster"])
QObject.disconnect(self.inShape, SIGNAL("currentIndexChanged(QString)"), self.update)
self.inShape.clear()
self.inShape.addItems(layers)
QObject.connect(self.inShape, SIGNAL("currentIndexChanged(QString)"), self.update)

# If input layer is changed, update field list
def update(self, inputLayer):
Expand Down Expand Up @@ -123,6 +128,7 @@ def accept(self):
if addToTOC == QMessageBox.Yes:
self.vlayer = QgsVectorLayer(outPath, unicode(outName), "ogr")
QgsMapLayerRegistry.instance().addMapLayer(self.vlayer)
self.populateLayers()
self.progressBar.setValue(0)
self.buttonOk.setEnabled( True )

Expand Down Expand Up @@ -208,7 +214,7 @@ def randomize(self, inLayer, outPath, minimum, design, value):
points = self.vectorRandom(int(value), inLayer,
ext.xMinimum(), ext.xMaximum(), ext.yMinimum(), ext.yMaximum())
else: points = self.loopThruPolygons(inLayer, value, design)
crs = self.mapCanvas.mapRenderer().destinationSrs()
crs = self.iface.mapCanvas().mapRenderer().destinationSrs()
if not crs.isValid(): crs = None
fields = { 0 : QgsField("ID", QVariant.Int) }
check = QFile(self.shapefileName)
Expand Down
Empty file modified python/plugins/fTools/tools/doRandom.py 100755 → 100644
Empty file.
9 changes: 7 additions & 2 deletions python/plugins/fTools/tools/doRegPoints.py 100755 → 100644
Expand Up @@ -50,7 +50,11 @@ def __init__(self, iface):
self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok )
self.progressBar.setValue(0)
self.mapCanvas = self.iface.mapCanvas()
self.populateLayers()

def populateLayers( self ):
layers = ftools_utils.getLayerNames("all")
self.inShape.clear()
self.inShape.addItems(layers)

def accept(self):
Expand Down Expand Up @@ -89,6 +93,7 @@ def accept(self):
if addToTOC == QMessageBox.Yes:
self.vlayer = QgsVectorLayer(outPath, unicode(outName), "ogr")
QgsMapLayerRegistry.instance().addMapLayer(self.vlayer)
self.populateLayers()
self.progressBar.setValue(0)
self.buttonOk.setEnabled( True )

Expand All @@ -98,7 +103,7 @@ def outFile(self):
if self.shapefileName is None or self.encoding is None:
return
self.outShape.setText( QString( self.shapefileName ) )

# Generate list of random points
def simpleRandom(self, n, bound, xmin, xmax, ymin, ymax):
seed()
Expand All @@ -109,7 +114,7 @@ def simpleRandom(self, n, bound, xmin, xmax, ymin, ymax):
if pGeom.intersects(bound):
points.append(pGeom)
i = i + 1
return points
return points

def regularize(self, bound, outPath, offset, value, gridType, inset, crs):
area = bound.width() * bound.height()
Expand Down
Empty file modified python/plugins/fTools/tools/doSelectByLocation.py 100755 → 100644
Empty file.

0 comments on commit 6274cd1

Please sign in to comment.