1
+ # -*- coding: utf-8 -*-
1
2
#-----------------------------------------------------------
2
- #
3
+ #
3
4
# fTools
4
5
# Copyright (C) 2009 Carson Farmer
5
6
# EMAIL: carson.farmer (at) gmail.com
6
7
# WEB : http://www.ftools.ca/fTools.html
7
8
#
8
9
# A collection of data management and analysis tools for vector data
9
10
#
10
- # Geoprocessing functions adapted from 'Geoprocessing Plugin',
11
+ # Geoprocessing functions adapted from 'Geoprocessing Plugin',
11
12
# (C) 2008 by Dr. Horst Duester, Stefan Ziegler
12
13
#
13
14
#-----------------------------------------------------------
14
- #
15
+ #
15
16
# licensed under the terms of GNU GPL 2
16
- #
17
+ #
17
18
# This program is free software; you can redistribute it and/or modify
18
19
# it under the terms of the GNU General Public License as published by
19
20
# the Free Software Foundation; either version 2 of the License, or
20
21
# (at your option) any later version.
21
- #
22
+ #
22
23
# This program is distributed in the hope that it will be useful,
23
24
# but WITHOUT ANY WARRANTY; without even the implied warranty of
24
25
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25
26
# GNU General Public License for more details.
26
- #
27
+ #
27
28
# You should have received a copy of the GNU General Public License along
28
29
# with this program; if not, write to the Free Software Foundation, Inc.,
29
30
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
30
- #
31
+ #
31
32
#---------------------------------------------------------------------
32
33
33
34
from PyQt4 .QtCore import *
44
45
# TODO: Eliminate the following modules in favour of above multi-function formats
45
46
import doIntersectLines , doJoinAttributes , doSelectByLocation , doVectorSplit , doMeanCoords
46
47
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
48
50
49
51
class fToolsPlugin :
50
52
def __init__ ( self ,iface ):
@@ -53,7 +55,7 @@ def __init__( self,iface ):
53
55
self .QgisVersion = unicode ( QGis .QGIS_VERSION_INT )
54
56
except :
55
57
self .QgisVersion = unicode ( QGis .qgisVersion )[ 0 ]
56
-
58
+
57
59
def getThemeIcon ( self , icon ):
58
60
settings = QSettings ()
59
61
pluginPath = QString ( os .path .dirname ( __file__ ) )
@@ -65,7 +67,7 @@ def getThemeIcon( self, icon ):
65
67
return QIcon ( ":" + defaultPath )
66
68
else :
67
69
return QIcon ()
68
-
70
+
69
71
def updateThemeIcons ( self , theme ):
70
72
self .analysisMenu .setIcon ( QIcon ( self .getThemeIcon ( "analysis.png" ) ) )
71
73
self .distMatrix .setIcon ( QIcon ( self .getThemeIcon ( "matrix.png" ) ) )
@@ -75,13 +77,13 @@ def updateThemeIcons( self, theme ):
75
77
self .listUnique .setIcon ( QIcon ( self .getThemeIcon ( "unique.png" ) ) )
76
78
self .nearestNeigh .setIcon ( QIcon ( self .getThemeIcon ( "neighbour.png" ) ) )
77
79
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" ) ) )
79
81
80
82
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" ) ) )
85
87
self .vectGrid .setIcon ( QIcon ( self .getThemeIcon ( "vector_grid.png" ) ) )
86
88
self .selectLocation .setIcon ( QIcon ( self .getThemeIcon ( "select_location.png" ) ) )
87
89
self .layerExtent .setIcon ( QIcon ( self .getThemeIcon ( "layer_extent.png" ) ) )
@@ -104,27 +106,28 @@ def updateThemeIcons( self, theme ):
104
106
self .extNodes .setIcon ( QIcon ( self .getThemeIcon ( "extract_nodes.png" ) ) )
105
107
self .simplify .setIcon ( QIcon ( self .getThemeIcon ( "simplify.png" ) ) )
106
108
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" ) ) )
108
110
self .polysToLines .setIcon ( QIcon ( self .getThemeIcon ( "to_lines.png" ) ) )
109
-
111
+
110
112
self .dataManageMenu .setIcon ( QIcon ( self .getThemeIcon ( "management.png" ) ) )
111
113
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" ) ) )
114
116
self .spatJoin .setIcon ( QIcon ( self .getThemeIcon ( "join_location.png" ) ) )
115
117
self .splitVect .setIcon ( QIcon ( self .getThemeIcon ( "split_layer.png" ) ) )
118
+ self .mergeShapes .setIcon ( QIcon ( self .getThemeIcon ( "merge_shapes.png" ) ) )
116
119
self .ftools_aboot .setIcon ( QIcon ( self .getThemeIcon ( "ftools_logo.png" ) ) )
117
120
118
121
def initGui ( self ):
119
122
if int ( self .QgisVersion ) < 1 :
120
- QMessageBox .warning ( self .iface .getMainWindow (), "fTools" ,
123
+ QMessageBox .warning ( self .iface .getMainWindow (), "fTools" ,
121
124
QCoreApplication .translate ( "fTools" , "Quantum GIS version detected: " ) + unicode ( self .QgisVersion )+ ".xx\n "
122
125
+ QCoreApplication .translate ( "fTools" , "This version of fTools requires at least QGIS version 1.0.0\n Plugin will not be enabled." ) )
123
126
return None
124
127
QObject .connect ( self .iface , SIGNAL ( "currentThemeChanged ( QString )" ), self .updateThemeIcons )
125
128
self .menu = QMenu ()
126
129
self .menu .setTitle ( QCoreApplication .translate ( "fTools" , "&Vector" ) )
127
-
130
+
128
131
self .analysisMenu = QMenu ( QCoreApplication .translate ( "fTools" , "&Analysis Tools" ) )
129
132
self .distMatrix = QAction ( QCoreApplication .translate ( "fTools" , "Distance matrix" ),self .iface .mainWindow ( ) )
130
133
self .sumLines = QAction ( QCoreApplication .translate ( "fTools" , "Sum line lengths" ), self .iface .mainWindow () )
@@ -145,7 +148,7 @@ def initGui( self ):
145
148
self .vectGrid = QAction ( QCoreApplication .translate ( "fTools" , "Vector grid" ), self .iface .mainWindow () )
146
149
self .selectLocation = QAction ( QCoreApplication .translate ( "fTools" , "Select by location" ), self .iface .mainWindow () )
147
150
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 ,
149
152
self .regPoints , self .vectGrid , self .selectLocation , self .layerExtent ] )
150
153
151
154
self .geoMenu = QMenu ( QCoreApplication .translate ( "fTools" , "&Geoprocessing Tools" ) )
@@ -157,7 +160,7 @@ def initGui( self ):
157
160
self .clip = QAction ( QCoreApplication .translate ( "fTools" , "Clip" ),self .iface .mainWindow () )
158
161
self .dissolve = QAction ( QCoreApplication .translate ( "fTools" , "Dissolve" ),self .iface .mainWindow () )
159
162
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 ,
161
164
self .union , self .symDifference , self .clip , self .erase , self .dissolve ] )
162
165
163
166
self .conversionMenu = QMenu ( QCoreApplication .translate ( "fTools" , "G&eometry Tools" ) )
@@ -170,7 +173,7 @@ def initGui( self ):
170
173
self .multiToSingle = QAction ( QCoreApplication .translate ( "fTools" , "Multipart to singleparts" ),self .iface .mainWindow () )
171
174
self .singleToMulti = QAction ( QCoreApplication .translate ( "fTools" , "Singleparts to multipart" ),self .iface .mainWindow () )
172
175
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 ,
174
177
self .simplify , self .multiToSingle , self .singleToMulti , self .polysToLines , self .extNodes ] )
175
178
176
179
self .dataManageMenu = QMenu ( QCoreApplication .translate ( "fTools" , "&Data Management Tools" ) )
@@ -179,10 +182,11 @@ def initGui( self ):
179
182
self .joinAttr = QAction ( QCoreApplication .translate ( "fTools" , "Join attributes" ), self .iface .mainWindow () )
180
183
self .spatJoin = QAction ( QCoreApplication .translate ( "fTools" , "Join attributes by location" ), self .iface .mainWindow () )
181
184
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 ] )
183
187
self .ftools_aboot = QAction ( QCoreApplication .translate ( "fTools" , "fTools Information" ), self .iface .mainWindow () )
184
188
self .updateThemeIcons ( "theme" )
185
-
189
+
186
190
self .menu .addMenu ( self .analysisMenu )
187
191
self .menu .addMenu ( self .researchMenu )
188
192
self .menu .addMenu ( self .geoMenu )
@@ -195,7 +199,7 @@ def initGui( self ):
195
199
actions = menu_bar .actions ()
196
200
lastAction = actions [ len ( actions ) - 1 ]
197
201
menu_bar .insertMenu ( lastAction , self .menu )
198
-
202
+
199
203
QObject .connect ( self .distMatrix , SIGNAL ("triggered()" ), self .dodistMatrix )
200
204
QObject .connect ( self .sumLines , SIGNAL ("triggered()" ), self .dosumLines )
201
205
QObject .connect ( self .pointsPoly , SIGNAL ("triggered()" ), self .dopointsPoly )
@@ -237,6 +241,7 @@ def initGui( self ):
237
241
QObject .connect ( self .joinAttr , SIGNAL ("triggered()" ), self .dojoinAttr )
238
242
QObject .connect ( self .spatJoin , SIGNAL ("triggered()" ), self .dospatJoin )
239
243
QObject .connect ( self .splitVect , SIGNAL ("triggered()" ), self .dosplitVect )
244
+ QObject .connect ( self .mergeShapes , SIGNAL ( "triggered()" ), self .doMergeShapes )
240
245
241
246
QObject .connect ( self .ftools_aboot , SIGNAL ("triggered()" ), self .doaboot )
242
247
@@ -314,11 +319,11 @@ def dodistMatrix( self ):
314
319
def docentroids ( self ):
315
320
d = doGeometry .GeometryDialog ( self .iface , 7 )
316
321
d .exec_ ()
317
-
322
+
318
323
def dodelaunay ( self ):
319
324
d = doGeometry .GeometryDialog ( self .iface , 8 )
320
325
d .exec_ ()
321
-
326
+
322
327
def doextent ( self ):
323
328
d = doGeometry .GeometryDialog ( self .iface , 9 )
324
329
d .exec_ ()
@@ -391,6 +396,10 @@ def dospatJoin( self ):
391
396
d = doSpatialJoin .Dialog ( self .iface )
392
397
d .exec_ ()
393
398
399
+ def doMergeShapes ( self ):
400
+ d = doMergeShapes .Dialog ( self .iface )
401
+ d .exec_ ()
402
+
394
403
def doaboot ( self ):
395
404
d = doAbout .Dialog ( self .iface )
396
405
d .exec_ ()
0 commit comments