Skip to content
Permalink
Browse files

Squashed commit of the following:

commit 883cdbc3ead1a98c594d9f5584cd50a3fd161511
Author: Giuseppe Sucameli <brush.tyler@gmail.com>
Date:   Mon Nov 30 01:12:47 2015 +0100

    [DbManager] fix indentation due to merge f15b6011f9

commit f15b6011f97797794ff4369645449b6803e15cd0
Merge: c4dcb7b 6d3df91
Author: Giuseppe Sucameli <brush.tyler@gmail.com>
Date:   Mon Nov 30 01:09:18 2015 +0100

    Merge branch 'gdaltools_buildvrt_asrs' of https://github.com/giohappy/QGIS into giohappy-gdaltools_buildvrt_asrs

    Conflicts:
    	python/plugins/GdalTools/tools/doBuildVRT.py

commit 6d3df91
Author: giohappy <giohappy@gmail.com>
Date:   Wed Jun 4 12:48:58 2014 +0200

    Added a_srs option to buildvrt command
  • Loading branch information
brushtyler committed Nov 30, 2015
1 parent c4dcb7b commit 57eb4090848650a6ad9b1e86631ee36916adcaad
Showing with 110 additions and 74 deletions.
  1. +46 −31 python/plugins/GdalTools/tools/doBuildVRT.py
  2. +64 −43 python/plugins/GdalTools/tools/widgetBuildVRT.ui
@@ -28,6 +28,7 @@

from ui_widgetBuildVRT import Ui_GdalToolsWidget as Ui_Widget
from widgetPluginBase import GdalToolsBasePluginWidget as BasePluginWidget
from dialogSRS import GdalToolsSRSDialog as SRSDialog
import GdalTools_utils as Utils


@@ -41,28 +42,33 @@ def __init__(self, iface):
self.setupUi(self)
BasePluginWidget.__init__(self, self.iface, "gdalbuildvrt")

self.inSelector.setType(self.inSelector.FILE)
self.outSelector.setType(self.outSelector.FILE)
self.inSelector.setType( self.inSelector.FILE )
self.outSelector.setType( self.outSelector.FILE )
self.recurseCheck.hide()
self.visibleRasterLayers = []

self.setParamsStatus([
(self.inSelector, SIGNAL("filenameChanged()")),
(self.outSelector, SIGNAL("filenameChanged()")),
(self.resolutionComboBox, SIGNAL("currentIndexChanged(int)"), self.resolutionCheck),
(self.srcNoDataSpin, SIGNAL("valueChanged(int)"), self.srcNoDataCheck, 1700),
(self.inputDirCheck, SIGNAL("stateChanged(int)")),
(self.separateCheck, SIGNAL("stateChanged(int)"), None, 1700),
(self.allowProjDiffCheck, SIGNAL("stateChanged(int)"), None, 1700),
(self.recurseCheck, SIGNAL("stateChanged(int)"), self.inputDirCheck),
(self.inputSelLayersCheck, SIGNAL("stateChanged(int)"))
])
self.setParamsStatus(
[
(self.inSelector, SIGNAL("filenameChanged()")),
(self.outSelector, SIGNAL("filenameChanged()")),
(self.resolutionComboBox, SIGNAL("currentIndexChanged(int)"), self.resolutionCheck),
(self.srcNoDataSpin, SIGNAL("valueChanged(int)"), self.srcNoDataCheck, 1700),
(self.inputDirCheck, SIGNAL("stateChanged(int)")),
(self.separateCheck, SIGNAL("stateChanged(int)"), None, 1700),
(self.targetSRSEdit, SIGNAL("textChanged(const QString &)"), self.targetSRSCheck),
(self.allowProjDiffCheck, SIGNAL("stateChanged(int)"), None, 1700),
(self.recurseCheck, SIGNAL("stateChanged(int)"), self.inputDirCheck),
(self.inputSelLayersCheck, SIGNAL("stateChanged(int)"))
]
)

self.connect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputFilesEdit)
self.connect(self.outSelector, SIGNAL("selectClicked()"), self.fillOutputFileEdit)
self.connect(self.inputDirCheck, SIGNAL("stateChanged( int )"), self.switchToolMode)
self.connect(self.inputSelLayersCheck, SIGNAL("stateChanged( int )"), self.switchLayerMode)
self.connect(self.iface.mapCanvas(), SIGNAL("stateChanged( int )"), self.switchLayerMode)
self.connect( self.inputDirCheck, SIGNAL( "stateChanged( int )" ), self.switchToolMode )
self.connect( self.inputSelLayersCheck, SIGNAL( "stateChanged( int )" ), self.switchLayerMode )
self.connect( self.iface.mapCanvas(), SIGNAL( "stateChanged( int )" ), self.switchLayerMode )
self.connect(self.selectTargetSRSButton, SIGNAL("clicked()"), self.fillTargetSRSEdit)


def initialize(self):
# connect to mapCanvas.layerChanged() signal
@@ -75,57 +81,63 @@ def onClosing(self):
self.disconnect(self.iface.mapCanvas(), SIGNAL("layersChanged()"), self.onVisibleLayersChanged)
BasePluginWidget.onClosing(self)


def onVisibleLayersChanged(self):
# refresh list of visible raster layers
self.visibleRasterLayers = []
for layer in self.iface.mapCanvas().layers():
if Utils.LayerRegistry.isRaster(layer):
self.visibleRasterLayers.append(layer.source())
if Utils.LayerRegistry.isRaster( layer ):
self.visibleRasterLayers.append( layer.source() )

# refresh the text in the command viewer
self.someValueChanged()

def switchToolMode(self):
self.recurseCheck.setVisible(self.inputDirCheck.isChecked())
self.recurseCheck.setVisible( self.inputDirCheck.isChecked() )
self.inSelector.clear()

if self.inputDirCheck.isChecked():
self.inFileLabel = self.label.text()
self.label.setText(QCoreApplication.translate("GdalTools", "&Input directory"))
self.label.setText( QCoreApplication.translate( "GdalTools", "&Input directory" ) )

QObject.disconnect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputFilesEdit)
QObject.connect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputDir)
else:
self.label.setText(self.inFileLabel)
self.label.setText( self.inFileLabel )

QObject.connect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputFilesEdit)
QObject.disconnect(self.inSelector, SIGNAL("selectClicked()"), self.fillInputDir)

def switchLayerMode(self):
enableInputFiles = not self.inputSelLayersCheck.isChecked()
self.inputDirCheck.setEnabled(enableInputFiles)
self.inSelector.setEnabled(enableInputFiles)
self.recurseCheck.setEnabled(enableInputFiles)
self.inputDirCheck.setEnabled( enableInputFiles )
self.inSelector.setEnabled( enableInputFiles )
self.recurseCheck.setEnabled( enableInputFiles )

def fillInputFilesEdit(self):
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
files = Utils.FileDialog.getOpenFileNames(self, self.tr("Select the files for VRT"), Utils.FileFilter.allRastersFilter(), lastUsedFilter)
files = Utils.FileDialog.getOpenFileNames(self, self.tr( "Select the files for VRT" ), Utils.FileFilter.allRastersFilter(), lastUsedFilter)
if files == '':
return
Utils.FileFilter.setLastUsedRasterFilter(lastUsedFilter)
self.inSelector.setFilename(",".join(files))

def fillOutputFileEdit(self):
outputFile = Utils.FileDialog.getSaveFileName(self, self.tr("Select where to save the VRT"), self.tr("VRT (*.vrt)"))
outputFile = Utils.FileDialog.getSaveFileName(self, self.tr( "Select where to save the VRT" ), self.tr( "VRT (*.vrt)" ))
if outputFile == '':
return
self.outSelector.setFilename(outputFile)

def fillInputDir(self):
inputDir = Utils.FileDialog.getExistingDirectory(self, self.tr("Select the input directory with files for VRT"))
def fillInputDir( self ):
inputDir = Utils.FileDialog.getExistingDirectory( self, self.tr( "Select the input directory with files for VRT" ))
if inputDir == '':
return
self.inSelector.setFilename(inputDir)
self.inSelector.setFilename( inputDir )

def fillTargetSRSEdit(self):
dialog = SRSDialog( "Select the target SRS", self )
if dialog.exec_():
self.targetSRSEdit.setText(dialog.getProjection())

def getArguments(self):
arguments = []
@@ -136,14 +148,17 @@ def getArguments(self):
arguments.append("-separate")
if self.srcNoDataCheck.isChecked():
arguments.append("-srcnodata")
arguments.append(unicode(self.srcNoDataSpin.value()))
arguments.append(str(self.srcNoDataSpin.value()))
if self.targetSRSCheck.isChecked() and self.targetSRSEdit.text():
arguments.append("-a_srs")
arguments.append(self.targetSRSEdit.text())
if self.allowProjDiffCheck.isChecked():
arguments.append("-allow_projection_difference")
arguments.append(self.getOutputFileName())
if self.inputSelLayersCheck.isChecked():
arguments.extend(self.visibleRasterLayers)
elif self.inputDirCheck.isChecked():
arguments.extend(Utils.getRasterFiles(self.getInputFileName(), self.recurseCheck.isChecked()))
arguments.extend(Utils.getRasterFiles( self.getInputFileName(), self.recurseCheck.isChecked() ))
else:
arguments.extend(self.getInputFileName())
return arguments
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>348</width>
<height>266</height>
<height>304</height>
</rect>
</property>
<property name="sizePolicy">
@@ -32,10 +32,30 @@
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QCheckBox" name="inputDirCheck">
<item row="4" column="1">
<widget class="GdalToolsInOutSelector" name="outSelector" native="true"/>
</item>
<item row="6" column="1">
<widget class="QSpinBox" name="srcNoDataSpin">
<property name="minimum">
<number>-100000</number>
</property>
<property name="maximum">
<number>65000</number>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QCheckBox" name="targetSRSCheck">
<property name="text">
<string>Choose input directory instead of files</string>
<string>Target SRS</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QCheckBox" name="srcNoDataCheck">
<property name="text">
<string>&amp;Source No Data</string>
</property>
</widget>
</item>
@@ -49,13 +69,6 @@
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QCheckBox" name="recurseCheck">
<property name="text">
<string>Recurse subdirectories</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
@@ -66,6 +79,30 @@
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QCheckBox" name="inputDirCheck">
<property name="text">
<string>Choose input directory instead of files</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QCheckBox" name="separateCheck">
<property name="text">
<string>Se&amp;parate</string>
</property>
</widget>
</item>
<item row="10" column="0" colspan="2">
<widget class="QCheckBox" name="allowProjDiffCheck">
<property name="text">
<string>Allow projection difference</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="GdalToolsInOutSelector" name="inSelector" native="true"/>
</item>
<item row="5" column="0">
<widget class="QCheckBox" name="resolutionCheck">
<property name="text">
@@ -101,42 +138,26 @@
</item>
</widget>
</item>
<item row="6" column="0">
<widget class="QCheckBox" name="srcNoDataCheck">
<property name="text">
<string>&amp;Source No Data</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QSpinBox" name="srcNoDataSpin">
<property name="minimum">
<number>-100000</number>
</property>
<property name="maximum">
<number>65000</number>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QCheckBox" name="separateCheck">
<item row="3" column="1">
<widget class="QCheckBox" name="recurseCheck">
<property name="text">
<string>Se&amp;parate</string>
<string>Recurse subdirectories</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="GdalToolsInOutSelector" name="inSelector" native="true"/>
</item>
<item row="4" column="1">
<widget class="GdalToolsInOutSelector" name="outSelector" native="true"/>
</item>
<item row="8" column="0" colspan="2">
<widget class="QCheckBox" name="allowProjDiffCheck">
<property name="text">
<string>Allow projection difference</string>
</property>
</widget>
<item row="7" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLineEdit" name="targetSRSEdit"/>
</item>
<item>
<widget class="QPushButton" name="selectTargetSRSButton">
<property name="text">
<string>Select</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>

0 comments on commit 57eb409

Please sign in to comment.
You can’t perform that action at this time.