Skip to content
Permalink
Browse files

[composer] Add missing degree symbol for 'Decimal with suffix' format…

… when using

a geographic crs
  • Loading branch information
nyalldawson committed Oct 5, 2014
1 parent f7cec71 commit ecedeb8b7b916228b9b84accb35ce357a3378ac5
Showing with 14 additions and 6 deletions.
  1. +9 −1 src/core/composer/qgscomposermapgrid.cpp
  2. +5 −5 tests/src/core/testqgscomposermapgrid.cpp
@@ -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;
@@ -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" ) );

}

0 comments on commit ecedeb8

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