Skip to content

Commit

Permalink
[composer] Add missing degree symbol for 'Decimal with suffix' format…
Browse files Browse the repository at this point in the history
… when using

a geographic crs
  • Loading branch information
nyalldawson committed Oct 5, 2014
1 parent f7cec71 commit ecedeb8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
10 changes: 9 additions & 1 deletion src/core/composer/qgscomposermapgrid.cpp
Expand Up @@ -1265,7 +1265,15 @@ QString QgsComposerMapGrid::gridAnnotationString( double value, QgsComposerMapGr
hemisphere = value < 0 ? QObject::tr( "S" ) : QObject::tr( "N" );
}
}
return QString::number( qAbs( value ), 'f', mGridAnnotationPrecision ) + hemisphere;
if ( geographic )
{
//insert degree symbol for geographic coordinates
return QString::number( qAbs( value ), 'f', mGridAnnotationPrecision ) + QChar( 176 ) + hemisphere;
}
else
{
return QString::number( qAbs( value ), 'f', mGridAnnotationPrecision ) + hemisphere;
}
}

QgsPoint p;
Expand Down
10 changes: 5 additions & 5 deletions tests/src/core/testqgscomposermapgrid.cpp
Expand Up @@ -475,23 +475,23 @@ void TestQgsComposerMapGrid::annotationFormats()
gridProjected.setAnnotationPrecision( 1 );

//normal e/w
QCOMPARE( gridGeographic.gridAnnotationString( 90, QgsComposerMapGrid::Longitude ), QString( "90.0E" ) );
QCOMPARE( gridGeographic.gridAnnotationString( 90, QgsComposerMapGrid::Longitude ), QString( "90.0" ) + QChar( 176 ) + QString( "E" ) );
QCOMPARE( gridProjected.gridAnnotationString( 90, QgsComposerMapGrid::Longitude ), QString( "90.0E" ) );

//0 degrees
QCOMPARE( gridGeographic.gridAnnotationString( 0, QgsComposerMapGrid::Longitude ), QString( "0.0" ) );
QCOMPARE( gridGeographic.gridAnnotationString( 0, QgsComposerMapGrid::Longitude ), QString( "0.0" ) + QChar( 176 ) );
QCOMPARE( gridProjected.gridAnnotationString( 0, QgsComposerMapGrid::Longitude ), QString( "0.0E" ) );

//180 degrees
QCOMPARE( gridGeographic.gridAnnotationString( 180, QgsComposerMapGrid::Longitude ), QString( "180.0" ) );
QCOMPARE( gridGeographic.gridAnnotationString( 180, QgsComposerMapGrid::Longitude ), QString( "180.0" ) + QChar( 176 ) );
QCOMPARE( gridProjected.gridAnnotationString( 180, QgsComposerMapGrid::Longitude ), QString( "180.0E" ) );

//normal n/s
QCOMPARE( gridGeographic.gridAnnotationString( 45, QgsComposerMapGrid::Latitude ), QString( "45.0N" ) );
QCOMPARE( gridGeographic.gridAnnotationString( 45, QgsComposerMapGrid::Latitude ), QString( "45.0" ) + QChar( 176 ) + QString( "N" ) );
QCOMPARE( gridProjected.gridAnnotationString( 45, QgsComposerMapGrid::Latitude ), QString( "45.0N" ) );

//0 north/south
QCOMPARE( gridGeographic.gridAnnotationString( 0, QgsComposerMapGrid::Latitude ), QString( "0.0" ) );
QCOMPARE( gridGeographic.gridAnnotationString( 0, QgsComposerMapGrid::Latitude ), QString( "0.0" ) + QChar( 176 ) );
QCOMPARE( gridProjected.gridAnnotationString( 0, QgsComposerMapGrid::Latitude ), QString( "0.0N" ) );

}
Expand Down

0 comments on commit ecedeb8

Please sign in to comment.