Skip to content

Commit

Permalink
-Simplified the QgsRasterLayer::generateBandName function based on a …
Browse files Browse the repository at this point in the history
…suggestion from Jef

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@10279 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
ersts committed Mar 14, 2009
1 parent 53e36ec commit 19297d8
Showing 1 changed file with 1 addition and 27 deletions.
28 changes: 1 addition & 27 deletions src/core/raster/qgsrasterlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) );
}

/**
Expand Down

0 comments on commit 19297d8

Please sign in to comment.