Skip to content

Commit ecedeb8

Browse files
committedOct 5, 2014
[composer] Add missing degree symbol for 'Decimal with suffix' format when using
a geographic crs
1 parent f7cec71 commit ecedeb8

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed
 

‎src/core/composer/qgscomposermapgrid.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1265,7 +1265,15 @@ QString QgsComposerMapGrid::gridAnnotationString( double value, QgsComposerMapGr
12651265
hemisphere = value < 0 ? QObject::tr( "S" ) : QObject::tr( "N" );
12661266
}
12671267
}
1268-
return QString::number( qAbs( value ), 'f', mGridAnnotationPrecision ) + hemisphere;
1268+
if ( geographic )
1269+
{
1270+
//insert degree symbol for geographic coordinates
1271+
return QString::number( qAbs( value ), 'f', mGridAnnotationPrecision ) + QChar( 176 ) + hemisphere;
1272+
}
1273+
else
1274+
{
1275+
return QString::number( qAbs( value ), 'f', mGridAnnotationPrecision ) + hemisphere;
1276+
}
12691277
}
12701278

12711279
QgsPoint p;

‎tests/src/core/testqgscomposermapgrid.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -475,23 +475,23 @@ void TestQgsComposerMapGrid::annotationFormats()
475475
gridProjected.setAnnotationPrecision( 1 );
476476

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

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

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

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

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

497497
}

0 commit comments

Comments
 (0)
Please sign in to comment.