Index: python/plugins/GdalTools/GdalTools.py =================================================================== --- python/plugins/GdalTools/GdalTools.py (revision 15100) +++ python/plugins/GdalTools/GdalTools.py (working copy) @@ -196,6 +196,11 @@ QObject.connect( self.rgb, SIGNAL( "triggered()" ), self.doRGB ) self.menu.addAction(self.rgb) + self.tileindex = QAction( QIcon( ":icons/tileindex.png" ), QCoreApplication.translate( "GdalTools", "Tile index" ), self.iface.mainWindow() ) + self.rgb.setStatusTip( QCoreApplication.translate( "GdalTools", "Build a shapefile as a raster tileindex" ) ) + QObject.connect( self.tileindex, SIGNAL( "triggered()" ), self.doTileIndex ) + self.menu.addAction(self.tileindex) + self.settings = QAction( QCoreApplication.translate( "GdalTools", "GdalTools settings" ), self.iface.mainWindow() ) self.settings.setStatusTip( QCoreApplication.translate( "GdalTools", "Various settings for Gdal Tools" ) ) QObject.connect( self.settings, SIGNAL( "triggered()" ), self.doSettings ) @@ -300,6 +305,11 @@ d = PctRgb( self.iface ) d.show_() + def doTileIndex( self ): + from tools.doTileIndex import GdalToolsDialog as TileIndex + d = TileIndex( self.iface ) + d.show_() + def doSettings( self ): from tools.doSettings import GdalToolsSettingsDialog as Settings d = Settings( self.iface ) Index: python/plugins/GdalTools/tools/doTileIndex.py =================================================================== --- python/plugins/GdalTools/tools/doTileIndex.py (revision 0) +++ python/plugins/GdalTools/tools/doTileIndex.py (revision 0) @@ -0,0 +1,74 @@ +# -*- coding: utf-8 -*- +from PyQt4.QtCore import * +from PyQt4.QtGui import * +from qgis.core import * +from qgis.gui import * + +from ui_widgetTileIndex import Ui_GdalToolsWidget as Ui_Widget +from widgetPluginBase import GdalToolsBasePluginWidget as BasePluginWidget +import GdalTools_utils as Utils + +import os.path + +class GdalToolsDialog( QWidget, Ui_Widget, BasePluginWidget ): + + def __init__( self, iface ): + QWidget.__init__( self ) + self.iface = iface + + self.setupUi( self ) + BasePluginWidget.__init__( self, self.iface, "gdaltindex" ) + + self.setParamsStatus( + [ + ( self.inputDirEdit, SIGNAL( "textChanged( const QString & )" ) ), + #( self.recurseCheck, SIGNAL( "stateChanged( int )" ), + ( self.outputFileEdit, SIGNAL( "textChanged( const QString & )" ) ), + ( self.indexFieldEdit, SIGNAL( "textChanged( const QString & )" ), self.indexFieldCheck), + ( self.absolutePathCheck, SIGNAL( "stateChanged( int )" ) ), + ( self.skipDifferentProjCheck, SIGNAL( "stateChanged( int )" ) ) + ] + ) + + self.connect( self.selectInputDirButton, SIGNAL( "clicked()" ), self.fillInputDirEdit ) + self.connect( self.selectOutputFileButton, SIGNAL( "clicked()" ), self.fillOutputFileEdit ) + + def fillInputDirEdit( self ): + inputDir = Utils.FileDialog.getExistingDirectory( self, self.tr( "Select the input directory with raster files" )) + if inputDir.isEmpty(): + return + + self.inputDirEdit.setText( inputDir ) + + def fillOutputFileEdit( self ): + lastUsedFilter = Utils.FileFilter.lastUsedVectorFilter() + outputFile, encoding = Utils.FileDialog.getSaveFileName( self, self.tr( "Select where to save the TileIndex output" ), Utils.FileFilter.allVectorsFilter(), lastUsedFilter, True ) + if outputFile.isEmpty(): + return + Utils.FileFilter.setLastUsedVectorFilter(lastUsedFilter) + + self.outputFormat = Utils.fillVectorOutputFormat( lastUsedFilter, outputFile ) + self.outputFileEdit.setText( outputFile ) + self.lastEncoding = encoding + + def getArguments( self ): + arguments = QStringList() + if self.indexFieldCheck.isChecked() and not self.indexFieldEdit.text().isEmpty(): + arguments << "-tileindex" + arguments << self.indexFieldEdit.text() + if self.absolutePathCheck.isChecked(): + arguments << "-write_absolute_path" + if self.skipDifferentProjCheck.isChecked(): + arguments << "-skip_different_projection" + arguments << self.outputFileEdit.text() + arguments << Utils.getRasterFiles( self.inputDirEdit.text(), self.recurseCheck.isChecked() ) + return arguments + + def getOutputFileName( self ): + return self.outputFileEdit.text() + + def addLayerIntoCanvas( self, fileInfo ): + vl = self.iface.addVectorLayer( fileInfo.filePath(), fileInfo.baseName(), "ogr" ) + if vl.isValid(): + if hasattr( self, 'lastEncoding' ): + vl.setProviderEncoding( self.lastEncoding ) Index: python/plugins/GdalTools/tools/widgetTileIndex.ui =================================================================== --- python/plugins/GdalTools/tools/widgetTileIndex.ui (revision 0) +++ python/plugins/GdalTools/tools/widgetTileIndex.ui (revision 0) @@ -0,0 +1,105 @@ + + + GdalToolsWidget + + + + 0 + 0 + 400 + 188 + + + + Raster tile index + + + + + + + + Input directory + + + + + + + + + + + + Select... + + + + + + + + + Recurse subdirectories + + + + + + + Output shapefile + + + + + + + + + + + + Select... + + + + + + + + + Tile index field + + + + + + + true + + + location + + + + + + + + + Write absolute path + + + + + + + Skip files with different projection ref + + + + + + + + Index: python/plugins/GdalTools/resources.qrc =================================================================== --- python/plugins/GdalTools/resources.qrc (revision 15100) +++ python/plugins/GdalTools/resources.qrc (working copy) @@ -17,6 +17,7 @@ icons/raster-clip.png icons/raster-paletted.png icons/raster-rgb.png + icons/tileindex.png icons/about.png