Skip to content
Permalink
Browse files

-Simplified the QgsRasterLayer::generateBandName function based on a …

…suggestion from Jef

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@10279 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
ersts
ersts committed Mar 14, 2009
1 parent 53e36ec commit 19297d881fe0b0c5442bf1d51a4854a1ec93044c
Showing with 1 addition and 27 deletions.
  1. +1 −27 src/core/raster/qgsrasterlayer.cpp
@@ -4892,33 +4892,7 @@ void QgsRasterLayer::closeDataset()

QString QgsRasterLayer::generateBandName( int theBandNumber )
{
//Calculate magnitude of band count for padding
QString myBandName = tr( "Band" ) + " ";
int myBandCount = bandCount();
int myLeadingZeros = 0;
int myWholeNumber = myBandCount / 10;
while( myWholeNumber > 0 )
{
myLeadingZeros++;
myWholeNumber = myBandCount / pow( 10, myLeadingZeros + 1 );
}

//Pad the band number of needed
int myMagnitude = 0;
myWholeNumber = theBandNumber / 10;
while( myWholeNumber > 0 )
{
myMagnitude++;
myWholeNumber = theBandNumber / pow( 10, myMagnitude + 1 );
}

for( int myPadder = 0; myPadder < myLeadingZeros - myMagnitude; myPadder++ )
{
myBandName += "0";
}
myBandName += QString::number( theBandNumber );

return myBandName;
return tr( "Band" ) + QString( " %1" ) .arg( theBandNumber, 1 + ( int ) log10( ( float ) bandCount() ), 10, QChar( '0' ) );
}

/**

0 comments on commit 19297d8

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