Skip to content

Commit

Permalink
#9060: use QGis::fromUnitToUnitFactor in QgsDecorationScaleBar
Browse files Browse the repository at this point in the history
  • Loading branch information
ahuarte47 committed Jan 14, 2014
1 parent 23f6a23 commit 2bffa19
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions src/app/qgsdecorationscalebar.cpp
Expand Up @@ -139,19 +139,10 @@ void QgsDecorationScaleBar::render( QPainter * theQPainter )
QGis::UnitType myPreferredUnits = QGis::fromLiteral( settings.value( "/qgis/measure/displayunits", QGis::toLiteral( QGis::Meters ) ).toString() );
QGis::UnitType myMapUnits = canvas->mapUnits();

// Adjust units meter/feet or vice versa
if ( myMapUnits == QGis::Meters && myPreferredUnits == QGis::Feet )
{
// From meter to feet
myMapUnits = QGis::Feet;
myMapUnitsPerPixelDouble /= 0.3084;
}
else if ( myMapUnits == QGis::Feet && myPreferredUnits == QGis::Meters )
{
// From feet to meter
myMapUnits = QGis::Meters;
myMapUnitsPerPixelDouble *= 0.3084;
}
// Adjust units meter/feet/... or vice versa
myMapUnitsPerPixelDouble *= QGis::fromUnitToUnitFactor( myMapUnits, myPreferredUnits );
myMapUnits = myPreferredUnits;

//Calculate size of scale bar for preferred number of map units
double myScaleBarWidth = mPreferredSize / myMapUnitsPerPixelDouble;

Expand Down

0 comments on commit 2bffa19

Please sign in to comment.