Skip to content

Commit f3371e1

Browse files
author
mhugent
committedAug 19, 2007
georeferencer: disable the setting of 0 as nodata value by default, apply more robust version of if-statement in QgsRasterLayer::drawMultiBandColor
git-svn-id: http://svn.osgeo.org/qgis/branches/Release-0_8_0@7142 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent f292429 commit f3371e1

File tree

3 files changed

+24
-27
lines changed

3 files changed

+24
-27
lines changed
 

‎src/plugins/georeferencer/qgsgeorefwarpoptionsdialogbase.ui

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
<ui version="4.0" >
2-
<author></author>
3-
<comment></comment>
4-
<exportmacro></exportmacro>
52
<class>QgsGeorefWarpOptionsDialogBase</class>
63
<widget class="QDialog" name="QgsGeorefWarpOptionsDialogBase" >
74
<property name="geometry" >
85
<rect>
96
<x>0</x>
107
<y>0</y>
11-
<width>282</width>
12-
<height>100</height>
8+
<width>348</width>
9+
<height>103</height>
1310
</rect>
1411
</property>
1512
<property name="windowTitle" >
@@ -67,7 +64,7 @@
6764
<string>Use 0 for transparency when needed</string>
6865
</property>
6966
<property name="checked" >
70-
<bool>true</bool>
67+
<bool>false</bool>
7168
</property>
7269
</widget>
7370
</item>

‎src/plugins/georeferencer/qgsimagewarper.cpp

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,23 @@ void QgsImageWarper::warp(const QString& input, const QString& output,
6666
hSrcDS->GetRasterCount(),
6767
hSrcDS->GetRasterBand(1)->GetRasterDataType(),
6868
papszOptions);
69-
for (int i = 0; i < hSrcDS->GetRasterCount(); ++i) {
70-
GDALColorTable* cTable = hSrcDS->GetRasterBand(i+1)->GetColorTable();
71-
if (cTable)
72-
hDstDS->GetRasterBand(i+1)->SetColorTable(cTable);
73-
double noData = hSrcDS->GetRasterBand(i+1)->GetNoDataValue();
74-
if (noData != -1e10)
75-
hDstDS->GetRasterBand(i+1)->SetNoDataValue(noData);
76-
else if (useZeroAsTrans) {
77-
std::cerr<<"***** Source raster has no NODATA value, using 0"<<std::endl;
78-
hDstDS->GetRasterBand(i+1)->SetNoDataValue(0);
69+
for (int i = 0; i < hSrcDS->GetRasterCount(); ++i)
70+
{
71+
GDALColorTable* cTable = hSrcDS->GetRasterBand(i+1)->GetColorTable();
72+
if (cTable)
73+
{
74+
hDstDS->GetRasterBand(i+1)->SetColorTable(cTable);
75+
}
76+
double noData = hSrcDS->GetRasterBand(i+1)->GetNoDataValue();
77+
if (noData == -1e10 && useZeroAsTrans)
78+
{
79+
hDstDS->GetRasterBand(i+1)->SetNoDataValue(0);
80+
}
81+
else
82+
{
83+
hDstDS->GetRasterBand(i+1)->SetNoDataValue(noData);
84+
}
7985
}
80-
}
8186
psWarpOptions->hDstDS = hDstDS;
8287

8388
// Initialize and execute the warp operation.

‎src/raster/qgsrasterlayer.cpp

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2454,16 +2454,11 @@ void QgsRasterLayer::drawMultiBandColor(QPainter * theQPainter, QgsRasterViewPor
24542454
continue;
24552455
}
24562456

2457-
// TODO: check all channels ?
2458-
if ( myRedValueDouble == noDataValueDouble || myRedValueDouble != myRedValueDouble)
2459-
{
2460-
#ifdef QGISDEBUG
2461-
// QgsLogger::debug("myRedValueDouble", myRedValueDouble, __FILE__, __FUNCTION__, __LINE__, 1);
2462-
// QgsLogger::debug("noDataValueDouble", noDataValueDouble, __FILE__, __FUNCTION__, __LINE__, 1);
2463-
#endif
2464-
continue;
2465-
}
2466-
2457+
if((myRedValueDouble == noDataValueDouble || myRedValueDouble != myRedValueDouble) || (myGreenValueDouble == noDataValueDouble || myGreenValueDouble != myGreenValueDouble) || (myBlueValueDouble == noDataValueDouble || myBlueValueDouble != myBlueValueDouble))
2458+
{
2459+
continue;
2460+
}
2461+
24672462
int myRedValueInt = static_cast < int > ( myRedValueDouble );
24682463
int myGreenValueInt = static_cast < int > ( myGreenValueDouble );
24692464
int myBlueValueInt = static_cast < int > ( myBlueValueDouble );

0 commit comments

Comments
 (0)
Please sign in to comment.