Skip to content

Commit 769bac7

Browse files
author
brushtyler
committed
Applied patch from #2930: improve GdalTools Translate dialog.
Contributed by Duarte Carreira, thanks! git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@14020 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent da53198 commit 769bac7

File tree

4 files changed

+200
-3
lines changed

4 files changed

+200
-3
lines changed

CONTRIBUTORS

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Carl Anderson
1515
Carlos Dávila
1616
Christian Ferreira
1717
Diego Moreira
18+
Duarte Carreira
1819
Faunalia (http://www.faunalia.it)
1920
Fernando Pacheco
2021
Florian El Ahdab

python/plugins/GdalTools/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def name():
2222
def description():
2323
return "Integrate gdal tools into qgis"
2424
def version():
25-
return "Version 1.2.8"
25+
return "Version 1.2.9"
2626
def qgisMinimumVersion():
2727
return "1.0"
2828
def classFactory(iface):

python/plugins/GdalTools/tools/doTranslate.py

+53-1
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,18 @@ def __init__(self, iface):
2020
BaseBatchWidget.__init__(self, self.iface, "gdal_translate")
2121

2222
# set the default QSpinBoxes and QProgressBar value
23+
self.outsizeSpin.setValue(25)
2324
self.progressBar.setValue(0)
2425

2526
self.progressBar.hide()
2627
self.formatLabel.hide()
2728
self.formatCombo.hide()
2829

30+
if Utils.Version( Utils.GdalConfig.version() ) < "1.7":
31+
index = self.expandCombo.findText('gray', Qt.MatchFixedString)
32+
if index >= 0:
33+
self.expandCombo.removeItem(index)
34+
2935
self.outputFormat = Utils.fillRasterOutputFormat()
3036

3137
self.setParamsStatus(
@@ -34,7 +40,13 @@ def __init__(self, iface):
3440
(self.outputFileEdit, SIGNAL("textChanged(const QString &)")),
3541
(self.targetSRSEdit, SIGNAL("textChanged(const QString &)"), self.targetSRSCheck),
3642
(self.selectTargetSRSButton, None, self.targetSRSCheck),
37-
(self.creationOptionsTable, [SIGNAL("cellValueChanged(int, int)"), SIGNAL("rowRemoved()")], self.creationGroupBox)
43+
(self.creationOptionsTable, [SIGNAL("cellValueChanged(int, int)"), SIGNAL("rowRemoved()")], self.creationGroupBox),
44+
(self.outsizeSpin, SIGNAL("valueChanged(const QString &)"), self.outsizeCheck),
45+
(self.nodataSpin, SIGNAL("valueChanged(int)"), self.nodataCheck),
46+
(self.expandCombo, SIGNAL("currentIndexChanged(int)"), self.expandCheck, "1.6.0"),
47+
(self.sdsCheck, SIGNAL("stateChanged(int)")),
48+
(self.srcwinEdit, SIGNAL("textChanged(const QString &)"), self.srcwinCheck),
49+
(self.prjwinEdit, SIGNAL("textChanged(const QString &)"), self.prjwinCheck)
3850
]
3951
)
4052

@@ -160,6 +172,46 @@ def getArguments(self):
160172
for opt in self.creationOptionsTable.options():
161173
arguments << "-co"
162174
arguments << opt
175+
if self.outsizeCheck.isChecked() and self.outsizeSpin.value() != 100:
176+
arguments << "-outsize"
177+
arguments << self.outsizeSpin.text()
178+
arguments << self.outsizeSpin.text()
179+
if self.expandCheck.isChecked():
180+
arguments << "-expand"
181+
arguments << self.expandCombo.currentText().toLower()
182+
if self.nodataCheck.isChecked():
183+
arguments << "-a_nodata"
184+
arguments << str(self.nodataSpin.value())
185+
if self.sdsCheck.isChecked():
186+
arguments << "-sds"
187+
if self.srcwinCheck.isChecked() and not self.srcwinEdit.text().isEmpty():
188+
#coordList = []
189+
coordList = self.srcwinEdit.text().split( ' ', QString.SkipEmptyParts )
190+
if len(coordList) == 4 and not coordList[3].isEmpty():
191+
try:
192+
for x in coordList:
193+
test = int(x)
194+
except ValueError:
195+
#print "Coordinates must be integer numbers."
196+
QMessageBox.critical(self, "Translate - srcwin", "Image coordinates (pixels) must be integer numbers.")
197+
else:
198+
arguments << "-srcwin"
199+
for x in coordList:
200+
arguments << x
201+
if self.prjwinCheck.isChecked() and not self.prjwinEdit.text().isEmpty():
202+
#coordList = []
203+
coordList = self.prjwinEdit.text().split( ' ', QString.SkipEmptyParts )
204+
if len(coordList) == 4 and not coordList[3].isEmpty():
205+
try:
206+
for x in coordList:
207+
test = float(x)
208+
except ValueError:
209+
#print "Coordinates must be integer numbers."
210+
QMessageBox.critical(self, "Translate - prjwin", "Image coordinates (geographic) must be numbers.")
211+
else:
212+
arguments << "-projwin"
213+
for x in coordList:
214+
arguments << x
163215
if self.isBatchEnabled():
164216
if self.formatCombo.currentIndex() != 0:
165217
arguments << "-of"

python/plugins/GdalTools/tools/widgetTranslate.ui

+145-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<x>0</x>
88
<y>0</y>
99
<width>335</width>
10-
<height>259</height>
10+
<height>453</height>
1111
</rect>
1212
</property>
1313
<property name="sizePolicy">
@@ -142,6 +142,150 @@
142142
</item>
143143
</layout>
144144
</item>
145+
<item row="4" column="0">
146+
<widget class="QCheckBox" name="outsizeCheck">
147+
<property name="maximumSize">
148+
<size>
149+
<width>100</width>
150+
<height>16777215</height>
151+
</size>
152+
</property>
153+
<property name="toolTip">
154+
<string>Percentage to resize image. This will change pixel size/image resolution accordingly: 25% will create an image with pixels 4x larger.</string>
155+
</property>
156+
<property name="text">
157+
<string>Outsize:</string>
158+
</property>
159+
</widget>
160+
</item>
161+
<item row="4" column="1">
162+
<widget class="QSpinBox" name="outsizeSpin">
163+
<property name="maximumSize">
164+
<size>
165+
<width>75</width>
166+
<height>16777215</height>
167+
</size>
168+
</property>
169+
<property name="toolTip">
170+
<string>Percentage to resize image. This will change pixel size/image resolution accordingly: 25% will create an image with pixels 4x larger.</string>
171+
</property>
172+
<property name="suffix">
173+
<string>%</string>
174+
</property>
175+
<property name="minimum">
176+
<number>1</number>
177+
</property>
178+
<property name="maximum">
179+
<number>1000</number>
180+
</property>
181+
</widget>
182+
</item>
183+
<item row="5" column="0">
184+
<widget class="QCheckBox" name="nodataCheck">
185+
<property name="toolTip">
186+
<string>Assign a specified nodata value to output bands.</string>
187+
</property>
188+
<property name="text">
189+
<string>No data:</string>
190+
</property>
191+
</widget>
192+
</item>
193+
<item row="5" column="1">
194+
<widget class="QSpinBox" name="nodataSpin">
195+
<property name="maximumSize">
196+
<size>
197+
<width>75</width>
198+
<height>16777215</height>
199+
</size>
200+
</property>
201+
<property name="toolTip">
202+
<string>Assign a specified nodata value to output bands.</string>
203+
</property>
204+
<property name="maximum">
205+
<number>255</number>
206+
</property>
207+
</widget>
208+
</item>
209+
<item row="6" column="0">
210+
<widget class="QCheckBox" name="expandCheck">
211+
<property name="toolTip">
212+
<string>To expose a dataset with 1 band with a color table as a dataset with 3 (RGB) or 4 (RGBA) bands.
213+
Usefull for output drivers such as JPEG, JPEG2000, MrSID, ECW that don't support color indexed datasets.
214+
The 'gray' value (from GDAL 1.7.0) enables to expand a dataset with a color table that only contains gray levels to a gray indexed dataset.</string>
215+
</property>
216+
<property name="text">
217+
<string>Expand:</string>
218+
</property>
219+
</widget>
220+
</item>
221+
<item row="6" column="1">
222+
<widget class="QComboBox" name="expandCombo">
223+
<property name="toolTip">
224+
<string>To expose a dataset with 1 band with a color table as a dataset with 3 (RGB) or 4 (RGBA) bands.
225+
Usefull for output drivers such as JPEG, JPEG2000, MrSID, ECW that don't support color indexed datasets.
226+
The 'gray' value (from GDAL 1.7.0) enables to expand a dataset with a color table that only contains gray levels to a gray indexed dataset.</string>
227+
</property>
228+
<item>
229+
<property name="text">
230+
<string>Gray</string>
231+
</property>
232+
</item>
233+
<item>
234+
<property name="text">
235+
<string>RGB</string>
236+
</property>
237+
</item>
238+
<item>
239+
<property name="text">
240+
<string>RGBA</string>
241+
</property>
242+
</item>
243+
</widget>
244+
</item>
245+
<item row="7" column="0">
246+
<widget class="QCheckBox" name="srcwinCheck">
247+
<property name="toolTip">
248+
<string>Selects a subwindow from the source image for copying based on pixel/line location. (Enter Xoff Yoff Xsize Ysize)</string>
249+
</property>
250+
<property name="text">
251+
<string>Srcwin:</string>
252+
</property>
253+
</widget>
254+
</item>
255+
<item row="7" column="1">
256+
<widget class="QLineEdit" name="srcwinEdit">
257+
<property name="toolTip">
258+
<string>Selects a subwindow from the source image for copying based on pixel/line location. (Enter Xoff Yoff Xsize Ysize)</string>
259+
</property>
260+
</widget>
261+
</item>
262+
<item row="8" column="0">
263+
<widget class="QCheckBox" name="prjwinCheck">
264+
<property name="toolTip">
265+
<string>Selects a subwindow from the source image for copying (like -srcwin) but with the corners given in georeferenced coordinates. (Enter ulx uly lrx lry)</string>
266+
</property>
267+
<property name="text">
268+
<string>Prjwin:</string>
269+
</property>
270+
</widget>
271+
</item>
272+
<item row="8" column="1">
273+
<widget class="QLineEdit" name="prjwinEdit">
274+
<property name="toolTip">
275+
<string>Selects a subwindow from the source image for copying (like -srcwin) but with the corners given in georeferenced coordinates. (Enter ulx uly lrx lry)</string>
276+
</property>
277+
</widget>
278+
</item>
279+
<item row="9" column="0">
280+
<widget class="QCheckBox" name="sdsCheck">
281+
<property name="toolTip">
282+
<string>Copy all subdatasets of this file to individual output files. Use with formats like HDF or OGDI that have subdatasets.</string>
283+
</property>
284+
<property name="text">
285+
<string>Sds</string>
286+
</property>
287+
</widget>
288+
</item>
145289
</layout>
146290
</item>
147291
<item>

0 commit comments

Comments
 (0)