29
29
req_mods = { "osgeo" : "osgeo [python-gdal]" }
30
30
31
31
try :
32
- from tools import GdalTools_utils as Utils
33
-
34
- from tools import ( doBuildVRT , doContour , doRasterize , doPolygonize , doMerge , doSieve , doProximity , doNearBlack )
35
- from tools import ( doWarp , doGrid , doTranslate , doClipper , doInfo , doProjection , doOverview , doRgbPct , doPctRgb )
36
- from tools import ( doSettings , doAbout )
32
+ from osgeo import gdal
33
+ from osgeo import ogr
37
34
except ImportError , e :
38
35
error_str = str (e )
39
36
error_mod = error_str .replace ( "No module named " , "" )
@@ -52,26 +49,27 @@ def __init__( self, iface ):
52
49
except :
53
50
self .QgisVersion = unicode ( QGis .qgisVersion )[ 0 ]
54
51
55
- # For i18n support
56
- userPluginPath = QFileInfo ( QgsApplication .qgisUserDbFilePath () ).path () + "/python/plugins/GdalTools"
57
- systemPluginPath = QgsApplication .prefixPath () + "/python/plugins/GdalTools"
52
+ if QGis .QGIS_VERSION [0 :3 ] < "1.5" :
53
+ # For i18n support
54
+ userPluginPath = QFileInfo ( QgsApplication .qgisUserDbFilePath () ).path () + "/python/plugins/GdalTools"
55
+ systemPluginPath = QgsApplication .prefixPath () + "/python/plugins/GdalTools"
58
56
59
- overrideLocale = QSettings ().value ( "locale/overrideFlag" , QVariant ( False ) ).toBool ()
60
- if not overrideLocale :
61
- localeFullName = QLocale .system ().name ()
62
- else :
63
- localeFullName = QSettings ().value ( "locale/userLocale" , QVariant ( "" ) ).toString ()
57
+ overrideLocale = QSettings ().value ( "locale/overrideFlag" , QVariant ( False ) ).toBool ()
58
+ if not overrideLocale :
59
+ localeFullName = QLocale .system ().name ()
60
+ else :
61
+ localeFullName = QSettings ().value ( "locale/userLocale" , QVariant ( "" ) ).toString ()
64
62
65
- if QFileInfo ( userPluginPath ).exists ():
66
- translationPath = userPluginPath + "/i18n/GdalTools_" + localeFullName + ".qm"
67
- else :
68
- translationPath = systemPluginPath + "/i18n/GdalTools_" + localeFullName + ".qm"
63
+ if QFileInfo ( userPluginPath ).exists ():
64
+ translationPath = userPluginPath + "/i18n/GdalTools_" + localeFullName + ".qm"
65
+ else :
66
+ translationPath = systemPluginPath + "/i18n/GdalTools_" + localeFullName + ".qm"
69
67
70
- self .localePath = translationPath
71
- if QFileInfo ( self .localePath ).exists ():
72
- self .translator = QTranslator ()
73
- self .translator .load ( self .localePath )
74
- QCoreApplication .installTranslator ( self .translator )
68
+ self .localePath = translationPath
69
+ if QFileInfo ( self .localePath ).exists ():
70
+ self .translator = QTranslator ()
71
+ self .translator .load ( self .localePath )
72
+ QCoreApplication .installTranslator ( self .translator )
75
73
76
74
def initGui ( self ):
77
75
if int ( self .QgisVersion ) < 1 :
@@ -80,7 +78,8 @@ def initGui( self ):
80
78
+ QCoreApplication .translate ( "GdalTools" , "This version of Gdal Tools requires at least QGIS version 1.0.0\n Plugin will not be enabled." ) )
81
79
return None
82
80
83
- self .GdalVersion = Utils .Version ( Utils .GdalConfig .version () )
81
+ from tools .GdalTools_utils import Version , GdalConfig
82
+ self .GdalVersion = Version ( GdalConfig .version () )
84
83
85
84
self .menu = QMenu ()
86
85
self .menu .setTitle ( QCoreApplication .translate ( "GdalTools" , "&Raster" ) )
@@ -198,77 +197,96 @@ def unload( self ):
198
197
pass
199
198
200
199
def doBuildVRT ( self ):
201
- d = doBuildVRT .GdalToolsDialog ( self .iface )
200
+ from tools .doBuildVRT import GdalToolsDialog as BuildVRT
201
+ d = BuildVRT ( self .iface )
202
202
d .show_ ()
203
203
204
204
def doContour ( self ):
205
- d = doContour .GdalToolsDialog ( self .iface )
205
+ from tools .doContour import GdalToolsDialog as Contour
206
+ d = Contour ( self .iface )
206
207
d .show_ ()
207
208
208
209
def doRasterize ( self ):
209
- d = doRasterize .GdalToolsDialog ( self .iface )
210
+ from tools .doRasterize import GdalToolsDialog as Rasterize
211
+ d = Rasterize ( self .iface )
210
212
d .show_ ()
211
213
212
214
def doPolygonize ( self ):
213
- d = doPolygonize .GdalToolsDialog ( self .iface )
215
+ from tools .doPolygonize import GdalToolsDialog as Polygonize
216
+ d = Polygonize ( self .iface )
214
217
d .show_ ()
215
218
216
219
def doMerge ( self ):
217
- d = doMerge .GdalToolsDialog ( self .iface )
220
+ from tools .doMerge import GdalToolsDialog as Merge
221
+ d = Merge ( self .iface )
218
222
d .show_ ()
219
223
220
224
def doSieve ( self ):
221
- d = doSieve .GdalToolsDialog ( self .iface )
225
+ from tools .doSieve import GdalToolsDialog as Sieve
226
+ d = Sieve ( self .iface )
222
227
d .show_ ()
223
228
224
229
def doProximity ( self ):
225
- d = doProximity .GdalToolsDialog ( self .iface )
230
+ from tools .doProximity import GdalToolsDialog as Proximity
231
+ d = Proximity ( self .iface )
226
232
d .show_ ()
227
233
228
234
def doNearBlack ( self ):
229
- d = doNearBlack .GdalToolsDialog ( self .iface )
235
+ from tools .doNearBlack import GdalToolsDialog as NearBlack
236
+ d = NearBlack ( self .iface )
230
237
d .show_ ()
231
238
232
239
def doWarp ( self ):
233
- d = doWarp .GdalToolsDialog ( self .iface )
240
+ from tools .doWarp import GdalToolsDialog as Warp
241
+ d = Warp ( self .iface )
234
242
d .show_ ()
235
243
236
244
def doGrid ( self ):
237
- d = doGrid .GdalToolsDialog ( self .iface )
245
+ from tools .doGrid import GdalToolsDialog as Grid
246
+ d = Grid ( self .iface )
238
247
d .show_ ()
239
248
240
249
def doTranslate ( self ):
241
- d = doTranslate .GdalToolsDialog ( self .iface )
250
+ from tools .doTranslate import GdalToolsDialog as Translate
251
+ d = Translate ( self .iface )
242
252
d .show_ ()
243
253
244
254
def doInfo ( self ):
245
- d = doInfo .GdalToolsDialog ( self .iface )
255
+ from tools .doInfo import GdalToolsDialog as Info
256
+ d = Info ( self .iface )
246
257
d .show_ ()
247
258
248
259
def doProjection ( self ):
249
- d = doProjection .GdalToolsDialog ( self .iface )
260
+ from tools .doProjection import GdalToolsDialog as Projection
261
+ d = Projection ( self .iface )
250
262
d .show_ ()
251
263
252
264
def doOverview ( self ):
253
- d = doOverview .GdalToolsDialog ( self .iface )
265
+ from tools .doOverview import GdalToolsDialog as Overview
266
+ d = Overview ( self .iface )
254
267
d .show_ ()
255
268
256
269
def doClipper ( self ):
257
- d = doClipper .GdalToolsDialog ( self .iface )
270
+ from tools .doClipper import GdalToolsDialog as Clipper
271
+ d = Clipper ( self .iface )
258
272
d .show_ ()
259
273
260
274
def doPaletted ( self ):
261
- d = doRgbPct .GdalToolsDialog ( self .iface )
275
+ from tools .doRgbPct import GdalToolsDialog as RgbPct
276
+ d = RgbPct ( self .iface )
262
277
d .show_ ()
263
278
264
279
def doRGB ( self ):
265
- d = doPctRgb .GdalToolsDialog ( self .iface )
280
+ from tools .doPctRgb import GdalToolsDialog as PctRgb
281
+ d = PctRgb ( self .iface )
266
282
d .show_ ()
267
283
268
284
def doSettings ( self ):
269
- d = doSettings .GdalToolsSettingsDialog ( self .iface )
285
+ from tools .doSettings import GdalToolsSettingsDialog as Settings
286
+ d = Settings ( self .iface )
270
287
d .exec_ ()
271
288
272
289
def doAbout ( self ):
273
- d = doAbout .GdalToolsAboutDialog ( self .iface )
290
+ from tools .doAbout import GdalToolsAboutDialog as About
291
+ d = About ( self .iface )
274
292
d .exec_ ()
0 commit comments