Skip to content

Commit febbca5

Browse files
author
cfarmer
committed
Adds 'merge shapes' tool to fTools (vector tools). Thanks to Alexander Bruy for the patch.
git-svn-id: http://svn.osgeo.org/qgis/trunk@13204 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 7b43dd5 commit febbca5

File tree

5 files changed

+348
-29
lines changed

5 files changed

+348
-29
lines changed

python/plugins/fTools/fTools.py

Lines changed: 38 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,34 @@
1+
# -*- coding: utf-8 -*-
12
#-----------------------------------------------------------
2-
#
3+
#
34
# fTools
45
# Copyright (C) 2009 Carson Farmer
56
# EMAIL: carson.farmer (at) gmail.com
67
# WEB : http://www.ftools.ca/fTools.html
78
#
89
# A collection of data management and analysis tools for vector data
910
#
10-
# Geoprocessing functions adapted from 'Geoprocessing Plugin',
11+
# Geoprocessing functions adapted from 'Geoprocessing Plugin',
1112
# (C) 2008 by Dr. Horst Duester, Stefan Ziegler
1213
#
1314
#-----------------------------------------------------------
14-
#
15+
#
1516
# licensed under the terms of GNU GPL 2
16-
#
17+
#
1718
# This program is free software; you can redistribute it and/or modify
1819
# it under the terms of the GNU General Public License as published by
1920
# the Free Software Foundation; either version 2 of the License, or
2021
# (at your option) any later version.
21-
#
22+
#
2223
# This program is distributed in the hope that it will be useful,
2324
# but WITHOUT ANY WARRANTY; without even the implied warranty of
2425
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2526
# GNU General Public License for more details.
26-
#
27+
#
2728
# You should have received a copy of the GNU General Public License along
2829
# with this program; if not, write to the Free Software Foundation, Inc.,
2930
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
30-
#
31+
#
3132
#---------------------------------------------------------------------
3233

3334
from PyQt4.QtCore import *
@@ -44,7 +45,8 @@
4445
# TODO: Eliminate the following modules in favour of above multi-function formats
4546
import doIntersectLines, doJoinAttributes, doSelectByLocation, doVectorSplit, doMeanCoords
4647
import doPointDistance, doPointsInPolygon, doRandom, doRandPoints, doRegPoints, doDefineProj
47-
import doReProject, doSpatialJoin, doSubsetSelect, doSumLines, doVectorGrid, doAbout
48+
import doReProject, doSpatialJoin, doSubsetSelect, doSumLines, doVectorGrid, doMergeShapes
49+
import doAbout
4850

4951
class fToolsPlugin:
5052
def __init__( self,iface ):
@@ -53,7 +55,7 @@ def __init__( self,iface ):
5355
self.QgisVersion = unicode( QGis.QGIS_VERSION_INT )
5456
except:
5557
self.QgisVersion = unicode( QGis.qgisVersion )[ 0 ]
56-
58+
5759
def getThemeIcon( self, icon ):
5860
settings = QSettings()
5961
pluginPath = QString( os.path.dirname( __file__ ) )
@@ -65,7 +67,7 @@ def getThemeIcon( self, icon ):
6567
return QIcon( ":" + defaultPath )
6668
else:
6769
return QIcon()
68-
70+
6971
def updateThemeIcons( self, theme ):
7072
self.analysisMenu.setIcon( QIcon( self.getThemeIcon( "analysis.png" ) ) )
7173
self.distMatrix.setIcon( QIcon( self.getThemeIcon( "matrix.png" ) ) )
@@ -75,13 +77,13 @@ def updateThemeIcons( self, theme ):
7577
self.listUnique.setIcon( QIcon( self.getThemeIcon( "unique.png" ) ) )
7678
self.nearestNeigh.setIcon( QIcon( self.getThemeIcon( "neighbour.png" ) ) )
7779
self.meanCoords.setIcon( QIcon( self.getThemeIcon( "mean.png" ) ) )
78-
self.intLines.setIcon( QIcon( self.getThemeIcon( "intersections.png" ) ) )
80+
self.intLines.setIcon( QIcon( self.getThemeIcon( "intersections.png" ) ) )
7981

8082
self.researchMenu.setIcon( QIcon( self.getThemeIcon( "sampling.png" ) ) )
81-
self.randSel.setIcon( QIcon( self.getThemeIcon( "random_selection.png" ) ) )
82-
self.randSub.setIcon( QIcon( self.getThemeIcon( "sub_selection.png" ) ) )
83-
self.randPoints.setIcon( QIcon( self.getThemeIcon( "random_points.png" ) ) )
84-
self.regPoints.setIcon( QIcon( self.getThemeIcon( "regular_points.png" ) ) )
83+
self.randSel.setIcon( QIcon( self.getThemeIcon( "random_selection.png" ) ) )
84+
self.randSub.setIcon( QIcon( self.getThemeIcon( "sub_selection.png" ) ) )
85+
self.randPoints.setIcon( QIcon( self.getThemeIcon( "random_points.png" ) ) )
86+
self.regPoints.setIcon( QIcon( self.getThemeIcon( "regular_points.png" ) ) )
8587
self.vectGrid.setIcon( QIcon( self.getThemeIcon( "vector_grid.png" ) ) )
8688
self.selectLocation.setIcon( QIcon( self.getThemeIcon( "select_location.png" ) ) )
8789
self.layerExtent.setIcon( QIcon( self.getThemeIcon( "layer_extent.png" ) ) )
@@ -104,27 +106,28 @@ def updateThemeIcons( self, theme ):
104106
self.extNodes.setIcon( QIcon( self.getThemeIcon( "extract_nodes.png") ) )
105107
self.simplify.setIcon( QIcon( self.getThemeIcon( "simplify.png") ) )
106108
self.multiToSingle.setIcon( QIcon( self.getThemeIcon( "multi_to_single.png") ) )
107-
self.singleToMulti.setIcon( QIcon( self.getThemeIcon( "single_to_multi.png") ) )
109+
self.singleToMulti.setIcon( QIcon( self.getThemeIcon( "single_to_multi.png") ) )
108110
self.polysToLines.setIcon( QIcon( self.getThemeIcon( "to_lines.png") ) )
109-
111+
110112
self.dataManageMenu.setIcon( QIcon( self.getThemeIcon( "management.png") ) )
111113
self.project.setIcon( QIcon( self.getThemeIcon( "export_projection.png") ) )
112-
self.define.setIcon( QIcon( self.getThemeIcon( "define_projection.png" ) ) )
113-
self.joinAttr.setIcon( QIcon( self.getThemeIcon( "join_attributes.png" ) ) )
114+
self.define.setIcon( QIcon( self.getThemeIcon( "define_projection.png" ) ) )
115+
self.joinAttr.setIcon( QIcon( self.getThemeIcon( "join_attributes.png" ) ) )
114116
self.spatJoin.setIcon( QIcon( self.getThemeIcon( "join_location.png" ) ) )
115117
self.splitVect.setIcon( QIcon( self.getThemeIcon( "split_layer.png" ) ) )
118+
self.mergeShapes.setIcon( QIcon( self.getThemeIcon( "merge_shapes.png" ) ) )
116119
self.ftools_aboot.setIcon( QIcon( self.getThemeIcon( "ftools_logo.png" ) ) )
117120

118121
def initGui( self ):
119122
if int( self.QgisVersion ) < 1:
120-
QMessageBox.warning( self.iface.getMainWindow(), "fTools",
123+
QMessageBox.warning( self.iface.getMainWindow(), "fTools",
121124
QCoreApplication.translate( "fTools", "Quantum GIS version detected: " ) +unicode( self.QgisVersion )+".xx\n"
122125
+ QCoreApplication.translate( "fTools", "This version of fTools requires at least QGIS version 1.0.0\nPlugin will not be enabled." ) )
123126
return None
124127
QObject.connect( self.iface, SIGNAL( "currentThemeChanged ( QString )" ), self.updateThemeIcons )
125128
self.menu = QMenu()
126129
self.menu.setTitle( QCoreApplication.translate( "fTools", "&Vector" ) )
127-
130+
128131
self.analysisMenu = QMenu( QCoreApplication.translate( "fTools", "&Analysis Tools" ) )
129132
self.distMatrix = QAction( QCoreApplication.translate( "fTools", "Distance matrix" ),self.iface.mainWindow( ) )
130133
self.sumLines = QAction( QCoreApplication.translate( "fTools", "Sum line lengths" ), self.iface.mainWindow() )
@@ -145,7 +148,7 @@ def initGui( self ):
145148
self.vectGrid = QAction( QCoreApplication.translate( "fTools", "Vector grid" ), self.iface.mainWindow() )
146149
self.selectLocation = QAction( QCoreApplication.translate( "fTools", "Select by location" ), self.iface.mainWindow() )
147150
self.layerExtent = QAction( QCoreApplication.translate( "fTools", "Polygon from layer extent" ), self.iface.mainWindow() )
148-
self.researchMenu.addActions( [ self.randSel, self.randSub, self.randPoints,
151+
self.researchMenu.addActions( [ self.randSel, self.randSub, self.randPoints,
149152
self.regPoints, self.vectGrid, self.selectLocation, self.layerExtent ] )
150153

151154
self.geoMenu = QMenu( QCoreApplication.translate( "fTools", "&Geoprocessing Tools" ) )
@@ -157,7 +160,7 @@ def initGui( self ):
157160
self.clip = QAction( QCoreApplication.translate( "fTools", "Clip" ),self.iface.mainWindow() )
158161
self.dissolve = QAction( QCoreApplication.translate( "fTools", "Dissolve" ),self.iface.mainWindow() )
159162
self.erase = QAction( QCoreApplication.translate( "fTools", "Difference" ),self.iface.mainWindow() )
160-
self.geoMenu.addActions( [ self.minConvex, self.dynaBuffer, self.intersect,
163+
self.geoMenu.addActions( [ self.minConvex, self.dynaBuffer, self.intersect,
161164
self.union, self.symDifference, self.clip, self.erase, self.dissolve ] )
162165

163166
self.conversionMenu = QMenu( QCoreApplication.translate( "fTools", "G&eometry Tools" ) )
@@ -170,7 +173,7 @@ def initGui( self ):
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() )
173-
self.conversionMenu.addActions( [ self.checkGeom, self.compGeo, self.centroids, self.delaunay,
176+
self.conversionMenu.addActions( [ self.checkGeom, self.compGeo, self.centroids, self.delaunay,
174177
self.simplify, self.multiToSingle, self.singleToMulti, self.polysToLines, self.extNodes] )
175178

176179
self.dataManageMenu = QMenu( QCoreApplication.translate( "fTools", "&Data Management Tools") )
@@ -179,10 +182,11 @@ def initGui( self ):
179182
self.joinAttr = QAction( QCoreApplication.translate( "fTools", "Join attributes" ), self.iface.mainWindow() )
180183
self.spatJoin = QAction( QCoreApplication.translate( "fTools", "Join attributes by location" ), self.iface.mainWindow() )
181184
self.splitVect = QAction( QCoreApplication.translate( "fTools", "Split vector layer" ), self.iface.mainWindow() )
182-
self.dataManageMenu.addActions( [ self.project, self.define, self.joinAttr, self.spatJoin, self.splitVect ] )
185+
self.mergeShapes = QAction( QCoreApplication.translate( "fTools", "Merge shapefiles to one" ), self.iface.mainWindow() )
186+
self.dataManageMenu.addActions( [ self.project, self.define, self.joinAttr, self.spatJoin, self.splitVect, self.mergeShapes ] )
183187
self.ftools_aboot = QAction( QCoreApplication.translate( "fTools", "fTools Information" ), self.iface.mainWindow() )
184188
self.updateThemeIcons( "theme" )
185-
189+
186190
self.menu.addMenu( self.analysisMenu )
187191
self.menu.addMenu( self.researchMenu )
188192
self.menu.addMenu( self.geoMenu )
@@ -195,7 +199,7 @@ def initGui( self ):
195199
actions = menu_bar.actions()
196200
lastAction = actions[ len( actions ) - 1 ]
197201
menu_bar.insertMenu( lastAction, self.menu )
198-
202+
199203
QObject.connect( self.distMatrix, SIGNAL("triggered()"), self.dodistMatrix )
200204
QObject.connect( self.sumLines, SIGNAL("triggered()"), self.dosumLines )
201205
QObject.connect( self.pointsPoly, SIGNAL("triggered()"), self.dopointsPoly )
@@ -237,6 +241,7 @@ def initGui( self ):
237241
QObject.connect( self.joinAttr, SIGNAL("triggered()"), self.dojoinAttr )
238242
QObject.connect( self.spatJoin, SIGNAL("triggered()"), self.dospatJoin )
239243
QObject.connect( self.splitVect, SIGNAL("triggered()"), self.dosplitVect )
244+
QObject.connect( self.mergeShapes, SIGNAL( "triggered()" ), self.doMergeShapes )
240245

241246
QObject.connect( self.ftools_aboot, SIGNAL("triggered()"), self.doaboot )
242247

@@ -314,11 +319,11 @@ def dodistMatrix( self ):
314319
def docentroids( self ):
315320
d = doGeometry.GeometryDialog( self.iface, 7 )
316321
d.exec_()
317-
322+
318323
def dodelaunay( self ):
319324
d = doGeometry.GeometryDialog( self.iface, 8 )
320325
d.exec_()
321-
326+
322327
def doextent( self ):
323328
d = doGeometry.GeometryDialog( self.iface, 9 )
324329
d.exec_()
@@ -391,6 +396,10 @@ def dospatJoin( self ):
391396
d = doSpatialJoin.Dialog( self.iface )
392397
d.exec_()
393398

399+
def doMergeShapes( self ):
400+
d = doMergeShapes.Dialog( self.iface )
401+
d.exec_()
402+
394403
def doaboot( self ):
395404
d = doAbout.Dialog( self.iface )
396405
d.exec_()
Loading

python/plugins/fTools/resources.qrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
<file>icons/default/sum_lines.png</file>
4242
<file>icons/default/vector_grid.png</file>
4343
<file>icons/default/split_layer.png</file>
44+
<file>icons/default/merge_shapes.png</file>
4445
<file>icons/default/neighbour.png</file>
4546
<file>icons/default/delaunay.png</file>
4647
<file>icons/default/layer_extent.png</file>

0 commit comments

Comments
 (0)