Skip to content
Permalink
Browse files

don't use color interpretation band names when band count > 1

  • Loading branch information
etiennesky committed Jul 14, 2012
1 parent 79d5dda commit 72c9f5a37e053ecd04536df33493f9e61d14b839
Showing with 19 additions and 10 deletions.
  1. +11 −7 src/app/qgsrasterlayerproperties.cpp
  2. +8 −3 src/gui/raster/qgsrasterrendererwidget.cpp
@@ -244,19 +244,23 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer* lyr, QgsMapCanv
cboxTransparencyBand->addItem( tr( "None" ), -1 );
int nBands = provider->bandCount();
QString bandName;
for ( int i = 1; i <= nBands; ++i ) //band numbering seem to start at 1

if ( nBands == 1 )
{
bandName = provider->colorInterpretationName( i );
/* Color interpretation name only makes sense for 1-band rasters */
bandName = provider->colorInterpretationName( 1 );
if ( bandName == "Undefined" )
bandName = provider->generateBandName( 1 );
cboxTransparencyBand->addItem( bandName, 1 );
}
else if ( nBands > 1 )
{
for ( int i = 1; i <= nBands; ++i ) //band numbering seem to start at 1
{
cboxTransparencyBand->addItem( provider->generateBandName( i ), i );
}
else
{
bandName = provider->generateBandName( i );
cboxTransparencyBand->addItem( bandName, i );
}
}

if ( renderer )
{
cboxTransparencyBand->setCurrentIndex( cboxTransparencyBand->findData( renderer->alphaBand() ) );
@@ -34,11 +34,16 @@ QString QgsRasterRendererWidget::displayBandName( int band ) const
return name;
}

name = provider->colorInterpretationName( band );
if ( name == "Undefined" )
/* Color interpretation name only makes sense for 1-band rasters */
if ( provider->bandCount() <= 1 )
{
name = provider->generateBandName( band );
name = provider->colorInterpretationName( band );
if ( name != "Undefined" )
return name;
}

name = provider->generateBandName( band );

return name;
}

0 comments on commit 72c9f5a

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