Skip to content
Permalink
Browse files

georeferencer: disable the setting of 0 as nodata value by default, a…

…pply 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
  • Loading branch information
mhugent
mhugent committed Aug 19, 2007
1 parent f292429 commit f3371e1a9adf77ece4b2c6b7dac6950da1335fc0
@@ -1,15 +1,12 @@
<ui version="4.0" >
<author></author>
<comment></comment>
<exportmacro></exportmacro>
<class>QgsGeorefWarpOptionsDialogBase</class>
<widget class="QDialog" name="QgsGeorefWarpOptionsDialogBase" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>282</width>
<height>100</height>
<width>348</width>
<height>103</height>
</rect>
</property>
<property name="windowTitle" >
@@ -67,7 +64,7 @@
<string>Use 0 for transparency when needed</string>
</property>
<property name="checked" >
<bool>true</bool>
<bool>false</bool>
</property>
</widget>
</item>
@@ -66,18 +66,23 @@ void QgsImageWarper::warp(const QString& input, const QString& output,
hSrcDS->GetRasterCount(),
hSrcDS->GetRasterBand(1)->GetRasterDataType(),
papszOptions);
for (int i = 0; i < hSrcDS->GetRasterCount(); ++i) {
GDALColorTable* cTable = hSrcDS->GetRasterBand(i+1)->GetColorTable();
if (cTable)
hDstDS->GetRasterBand(i+1)->SetColorTable(cTable);
double noData = hSrcDS->GetRasterBand(i+1)->GetNoDataValue();
if (noData != -1e10)
hDstDS->GetRasterBand(i+1)->SetNoDataValue(noData);
else if (useZeroAsTrans) {
std::cerr<<"***** Source raster has no NODATA value, using 0"<<std::endl;
hDstDS->GetRasterBand(i+1)->SetNoDataValue(0);
for (int i = 0; i < hSrcDS->GetRasterCount(); ++i)
{
GDALColorTable* cTable = hSrcDS->GetRasterBand(i+1)->GetColorTable();
if (cTable)
{
hDstDS->GetRasterBand(i+1)->SetColorTable(cTable);
}
double noData = hSrcDS->GetRasterBand(i+1)->GetNoDataValue();
if (noData == -1e10 && useZeroAsTrans)
{
hDstDS->GetRasterBand(i+1)->SetNoDataValue(0);
}
else
{
hDstDS->GetRasterBand(i+1)->SetNoDataValue(noData);
}
}
}
psWarpOptions->hDstDS = hDstDS;

// Initialize and execute the warp operation.
@@ -2454,16 +2454,11 @@ void QgsRasterLayer::drawMultiBandColor(QPainter * theQPainter, QgsRasterViewPor
continue;
}

// TODO: check all channels ?
if ( myRedValueDouble == noDataValueDouble || myRedValueDouble != myRedValueDouble)
{
#ifdef QGISDEBUG
// QgsLogger::debug("myRedValueDouble", myRedValueDouble, __FILE__, __FUNCTION__, __LINE__, 1);
// QgsLogger::debug("noDataValueDouble", noDataValueDouble, __FILE__, __FUNCTION__, __LINE__, 1);
#endif
continue;
}

if((myRedValueDouble == noDataValueDouble || myRedValueDouble != myRedValueDouble) || (myGreenValueDouble == noDataValueDouble || myGreenValueDouble != myGreenValueDouble) || (myBlueValueDouble == noDataValueDouble || myBlueValueDouble != myBlueValueDouble))
{
continue;
}

int myRedValueInt = static_cast < int > ( myRedValueDouble );
int myGreenValueInt = static_cast < int > ( myGreenValueDouble );
int myBlueValueInt = static_cast < int > ( myBlueValueDouble );

0 comments on commit f3371e1

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