~ubuntu-branches/ubuntu/utopic/qgis/utopic

« back to all changes in this revision

Viewing changes to python/plugins/GdalTools/tools/doTileIndex.py

  • Committer: Package Import Robot
  • Author(s): Francesco Paolo Lovergine
  • Date: 2012-04-24 15:12:20 UTC
  • mfrom: (3.1.9 sid)
  • Revision ID: package-import@ubuntu.com-20120424151220-r88g00af5fpn5fc3
Tags: 1.7.4+1.7.5~20120320-1
The "Sometimes they come back" release.

* Branching from Qgis tree and adapting to current Debian Policy and
  standards. The target tree is currently set to release-1.7.
  (closes: #661491, #606304, #615683, #616182, #600308)
* Policy bumped to 3.9.3.
* Moving to debhelper compatibility level 9.
* Source format is now 3.0 with quilt support.
* Merged with 2bf42287 upstream git snapshot.
* Migrated to dh_python2 instead of python-central.
  (closes: #617048)
* Snapshot in qgis.org release-1.7: c936d031
* Added an automagic creation of a lintian override for sqlite embedding.
  This is required for uploading currently.
* Added missing ${misc:Depends} to make lintian happy.
* Copyright notes updated and debian/copyright moved to format 1.0.
* More licenses notices now reported in debian/copyright. Thanks ftpmasters.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
from PyQt4.QtCore import *
 
3
from PyQt4.QtGui import *
 
4
from qgis.core import *
 
5
from qgis.gui import *
 
6
 
 
7
from ui_widgetTileIndex import Ui_GdalToolsWidget as Ui_Widget
 
8
from widgetPluginBase import GdalToolsBasePluginWidget as BasePluginWidget
 
9
import GdalTools_utils as Utils
 
10
 
 
11
import os.path
 
12
 
 
13
class GdalToolsDialog( QWidget, Ui_Widget, BasePluginWidget ):
 
14
 
 
15
  def __init__( self, iface ):
 
16
      QWidget.__init__( self )
 
17
      self.iface = iface
 
18
 
 
19
      self.setupUi( self )
 
20
      BasePluginWidget.__init__( self, self.iface, "gdaltindex" )
 
21
 
 
22
      self.inSelector.setType( self.inSelector.FILE )
 
23
      self.outSelector.setType( self.outSelector.FILE )
 
24
 
 
25
      self.setParamsStatus(
 
26
        [
 
27
          ( self.inSelector, SIGNAL( "filenameChanged()" ) ),
 
28
          #( self.recurseCheck, SIGNAL( "stateChanged( int )" ),
 
29
          ( self.outSelector, SIGNAL( "filenameChanged()" ) ),
 
30
          ( self.indexFieldEdit, SIGNAL( "textChanged( const QString & )" ), self.indexFieldCheck),
 
31
          ( self.absolutePathCheck, SIGNAL( "stateChanged( int )" ), None, "1.5.0" ),
 
32
          ( self.skipDifferentProjCheck, SIGNAL( "stateChanged( int )" ), None, "1.5.0" )
 
33
        ]
 
34
      )
 
35
 
 
36
      self.connect( self.inSelector, SIGNAL( "selectClicked()" ), self.fillInputDirEdit )
 
37
      self.connect( self.outSelector, SIGNAL( "selectClicked()" ), self.fillOutputFileEdit )
 
38
 
 
39
  def fillInputDirEdit( self ):
 
40
      inputDir = Utils.FileDialog.getExistingDirectory( self, self.tr( "Select the input directory with raster files" ))
 
41
      if inputDir.isEmpty():
 
42
        return
 
43
      self.inSelector.setFilename( inputDir )
 
44
 
 
45
  def fillOutputFileEdit( self ):
 
46
      lastUsedFilter = Utils.FileFilter.lastUsedVectorFilter()
 
47
      outputFile, encoding = Utils.FileDialog.getSaveFileName( self, self.tr( "Select where to save the TileIndex output" ), Utils.FileFilter.allVectorsFilter(), lastUsedFilter, True )
 
48
      if outputFile.isEmpty():
 
49
        return
 
50
      Utils.FileFilter.setLastUsedVectorFilter(lastUsedFilter)
 
51
 
 
52
      self.outputFormat = Utils.fillVectorOutputFormat( lastUsedFilter, outputFile )
 
53
      self.outSelector.setFilename( outputFile )
 
54
      self.lastEncoding = encoding
 
55
 
 
56
  def getArguments( self ):
 
57
      arguments = QStringList()
 
58
      if self.indexFieldCheck.isChecked() and not self.indexFieldEdit.text().isEmpty():
 
59
        arguments << "-tileindex"
 
60
        arguments << self.indexFieldEdit.text()
 
61
      if self.absolutePathCheck.isChecked():
 
62
        arguments << "-write_absolute_path"
 
63
      if self.skipDifferentProjCheck.isChecked():
 
64
        arguments << "-skip_different_projection"
 
65
      arguments << self.getOutputFileName()
 
66
      arguments << Utils.getRasterFiles( self.getInputFileName(), self.recurseCheck.isChecked() )
 
67
      return arguments
 
68
 
 
69
  def getOutputFileName( self ):
 
70
      return self.outSelector.filename()
 
71
 
 
72
  def getInputFileName( self ):
 
73
      return self.inSelector.filename()
 
74
 
 
75
  def addLayerIntoCanvas( self, fileInfo ):
 
76
      vl = self.iface.addVectorLayer( fileInfo.filePath(), fileInfo.baseName(), "ogr" )
 
77
      if vl != None and vl.isValid():
 
78
        if hasattr( self, 'lastEncoding' ):
 
79
          vl.setProviderEncoding( self.lastEncoding )
 
80