GdalTools_tileindex.diff
| python/plugins/GdalTools/GdalTools.py (working copy) | ||
|---|---|---|
| 196 | 196 |
QObject.connect( self.rgb, SIGNAL( "triggered()" ), self.doRGB ) |
| 197 | 197 |
self.menu.addAction(self.rgb) |
| 198 | 198 | |
| 199 |
self.tileindex = QAction( QIcon( ":icons/tileindex.png" ), QCoreApplication.translate( "GdalTools", "Tile index" ), self.iface.mainWindow() ) |
|
| 200 |
self.rgb.setStatusTip( QCoreApplication.translate( "GdalTools", "Build a shapefile as a raster tileindex" ) ) |
|
| 201 |
QObject.connect( self.tileindex, SIGNAL( "triggered()" ), self.doTileIndex ) |
|
| 202 |
self.menu.addAction(self.tileindex) |
|
| 203 | ||
| 199 | 204 |
self.settings = QAction( QCoreApplication.translate( "GdalTools", "GdalTools settings" ), self.iface.mainWindow() ) |
| 200 | 205 |
self.settings.setStatusTip( QCoreApplication.translate( "GdalTools", "Various settings for Gdal Tools" ) ) |
| 201 | 206 |
QObject.connect( self.settings, SIGNAL( "triggered()" ), self.doSettings ) |
| ... | ... | |
| 300 | 305 |
d = PctRgb( self.iface ) |
| 301 | 306 |
d.show_() |
| 302 | 307 | |
| 308 |
def doTileIndex( self ): |
|
| 309 |
from tools.doTileIndex import GdalToolsDialog as TileIndex |
|
| 310 |
d = TileIndex( self.iface ) |
|
| 311 |
d.show_() |
|
| 312 | ||
| 303 | 313 |
def doSettings( self ): |
| 304 | 314 |
from tools.doSettings import GdalToolsSettingsDialog as Settings |
| 305 | 315 |
d = Settings( self.iface ) |
| python/plugins/GdalTools/tools/doTileIndex.py (revision 0) | ||
|---|---|---|
| 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.setParamsStatus( |
|
| 23 |
[ |
|
| 24 |
( self.inputDirEdit, SIGNAL( "textChanged( const QString & )" ) ), |
|
| 25 |
#( self.recurseCheck, SIGNAL( "stateChanged( int )" ), |
|
| 26 |
( self.outputFileEdit, SIGNAL( "textChanged( const QString & )" ) ), |
|
| 27 |
( self.indexFieldEdit, SIGNAL( "textChanged( const QString & )" ), self.indexFieldCheck), |
|
| 28 |
( self.absolutePathCheck, SIGNAL( "stateChanged( int )" ) ), |
|
| 29 |
( self.skipDifferentProjCheck, SIGNAL( "stateChanged( int )" ) ) |
|
| 30 |
] |
|
| 31 |
) |
|
| 32 | ||
| 33 |
self.connect( self.selectInputDirButton, SIGNAL( "clicked()" ), self.fillInputDirEdit ) |
|
| 34 |
self.connect( self.selectOutputFileButton, SIGNAL( "clicked()" ), self.fillOutputFileEdit ) |
|
| 35 | ||
| 36 |
def fillInputDirEdit( self ): |
|
| 37 |
inputDir = Utils.FileDialog.getExistingDirectory( self, self.tr( "Select the input directory with raster files" )) |
|
| 38 |
if inputDir.isEmpty(): |
|
| 39 |
return |
|
| 40 | ||
| 41 |
self.inputDirEdit.setText( inputDir ) |
|
| 42 | ||
| 43 |
def fillOutputFileEdit( self ): |
|
| 44 |
lastUsedFilter = Utils.FileFilter.lastUsedVectorFilter() |
|
| 45 |
outputFile, encoding = Utils.FileDialog.getSaveFileName( self, self.tr( "Select where to save the TileIndex output" ), Utils.FileFilter.allVectorsFilter(), lastUsedFilter, True ) |
|
| 46 |
if outputFile.isEmpty(): |
|
| 47 |
return |
|
| 48 |
Utils.FileFilter.setLastUsedVectorFilter(lastUsedFilter) |
|
| 49 | ||
| 50 |
self.outputFormat = Utils.fillVectorOutputFormat( lastUsedFilter, outputFile ) |
|
| 51 |
self.outputFileEdit.setText( outputFile ) |
|
| 52 |
self.lastEncoding = encoding |
|
| 53 | ||
| 54 |
def getArguments( self ): |
|
| 55 |
arguments = QStringList() |
|
| 56 |
if self.indexFieldCheck.isChecked() and not self.indexFieldEdit.text().isEmpty(): |
|
| 57 |
arguments << "-tileindex" |
|
| 58 |
arguments << self.indexFieldEdit.text() |
|
| 59 |
if self.absolutePathCheck.isChecked(): |
|
| 60 |
arguments << "-write_absolute_path" |
|
| 61 |
if self.skipDifferentProjCheck.isChecked(): |
|
| 62 |
arguments << "-skip_different_projection" |
|
| 63 |
arguments << self.outputFileEdit.text() |
|
| 64 |
arguments << Utils.getRasterFiles( self.inputDirEdit.text(), self.recurseCheck.isChecked() ) |
|
| 65 |
return arguments |
|
| 66 | ||
| 67 |
def getOutputFileName( self ): |
|
| 68 |
return self.outputFileEdit.text() |
|
| 69 | ||
| 70 |
def addLayerIntoCanvas( self, fileInfo ): |
|
| 71 |
vl = self.iface.addVectorLayer( fileInfo.filePath(), fileInfo.baseName(), "ogr" ) |
|
| 72 |
if vl.isValid(): |
|
| 73 |
if hasattr( self, 'lastEncoding' ): |
|
| 74 |
vl.setProviderEncoding( self.lastEncoding ) |
|
| python/plugins/GdalTools/tools/widgetTileIndex.ui (revision 0) | ||
|---|---|---|
| 1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
| 2 |
<ui version="4.0"> |
|
| 3 |
<class>GdalToolsWidget</class> |
|
| 4 |
<widget class="QWidget" name="GdalToolsWidget"> |
|
| 5 |
<property name="geometry"> |
|
| 6 |
<rect> |
|
| 7 |
<x>0</x> |
|
| 8 |
<y>0</y> |
|
| 9 |
<width>400</width> |
|
| 10 |
<height>188</height> |
|
| 11 |
</rect> |
|
| 12 |
</property> |
|
| 13 |
<property name="windowTitle"> |
|
| 14 |
<string>Raster tile index</string> |
|
| 15 |
</property> |
|
| 16 |
<layout class="QVBoxLayout" name="verticalLayout"> |
|
| 17 |
<item> |
|
| 18 |
<layout class="QGridLayout" name="gridLayout"> |
|
| 19 |
<item row="0" column="0"> |
|
| 20 |
<widget class="QLabel" name="label"> |
|
| 21 |
<property name="text"> |
|
| 22 |
<string>Input directory</string> |
|
| 23 |
</property> |
|
| 24 |
</widget> |
|
| 25 |
</item> |
|
| 26 |
<item row="0" column="1"> |
|
| 27 |
<layout class="QHBoxLayout" name="horizontalLayout"> |
|
| 28 |
<item> |
|
| 29 |
<widget class="QLineEdit" name="inputDirEdit"/> |
|
| 30 |
</item> |
|
| 31 |
<item> |
|
| 32 |
<widget class="QPushButton" name="selectInputDirButton"> |
|
| 33 |
<property name="text"> |
|
| 34 |
<string>Select...</string> |
|
| 35 |
</property> |
|
| 36 |
</widget> |
|
| 37 |
</item> |
|
| 38 |
</layout> |
|
| 39 |
</item> |
|
| 40 |
<item row="1" column="1"> |
|
| 41 |
<widget class="QCheckBox" name="recurseCheck"> |
|
| 42 |
<property name="text"> |
|
| 43 |
<string>Recurse subdirectories</string> |
|
| 44 |
</property> |
|
| 45 |
</widget> |
|
| 46 |
</item> |
|
| 47 |
<item row="2" column="0"> |
|
| 48 |
<widget class="QLabel" name="label_2"> |
|
| 49 |
<property name="text"> |
|
| 50 |
<string>Output shapefile</string> |
|
| 51 |
</property> |
|
| 52 |
</widget> |
|
| 53 |
</item> |
|
| 54 |
<item row="2" column="1"> |
|
| 55 |
<layout class="QHBoxLayout" name="horizontalLayout_2"> |
|
| 56 |
<item> |
|
| 57 |
<widget class="QLineEdit" name="outputFileEdit"/> |
|
| 58 |
</item> |
|
| 59 |
<item> |
|
| 60 |
<widget class="QPushButton" name="selectOutputFileButton"> |
|
| 61 |
<property name="text"> |
|
| 62 |
<string>Select...</string> |
|
| 63 |
</property> |
|
| 64 |
</widget> |
|
| 65 |
</item> |
|
| 66 |
</layout> |
|
| 67 |
</item> |
|
| 68 |
<item row="3" column="0"> |
|
| 69 |
<widget class="QCheckBox" name="indexFieldCheck"> |
|
| 70 |
<property name="text"> |
|
| 71 |
<string>Tile index field</string> |
|
| 72 |
</property> |
|
| 73 |
</widget> |
|
| 74 |
</item> |
|
| 75 |
<item row="3" column="1"> |
|
| 76 |
<widget class="QLineEdit" name="indexFieldEdit"> |
|
| 77 |
<property name="enabled"> |
|
| 78 |
<bool>true</bool> |
|
| 79 |
</property> |
|
| 80 |
<property name="text"> |
|
| 81 |
<string>location</string> |
|
| 82 |
</property> |
|
| 83 |
</widget> |
|
| 84 |
</item> |
|
| 85 |
</layout> |
|
| 86 |
</item> |
|
| 87 |
<item> |
|
| 88 |
<widget class="QCheckBox" name="absolutePathCheck"> |
|
| 89 |
<property name="text"> |
|
| 90 |
<string>Write absolute path</string> |
|
| 91 |
</property> |
|
| 92 |
</widget> |
|
| 93 |
</item> |
|
| 94 |
<item> |
|
| 95 |
<widget class="QCheckBox" name="skipDifferentProjCheck"> |
|
| 96 |
<property name="text"> |
|
| 97 |
<string>Skip files with different projection ref</string> |
|
| 98 |
</property> |
|
| 99 |
</widget> |
|
| 100 |
</item> |
|
| 101 |
</layout> |
|
| 102 |
</widget> |
|
| 103 |
<resources/> |
|
| 104 |
<connections/> |
|
| 105 |
</ui> |
|
| python/plugins/GdalTools/resources.qrc (working copy) | ||
|---|---|---|
| 17 | 17 |
<file>icons/raster-clip.png</file> |
| 18 | 18 |
<file>icons/raster-paletted.png</file> |
| 19 | 19 |
<file>icons/raster-rgb.png</file> |
| 20 |
<file>icons/tileindex.png</file> |
|
| 20 | 21 |
<file>icons/about.png</file> |
| 21 | 22 |
</qresource> |
| 22 | 23 |
</RCC> |