@@ -48,6 +48,7 @@ class TestQgsComposerMapGrid: public QObject
48
48
void interiorExteriorTicksAnnotated (); // test interior & exterior tick mode with annotations
49
49
void lineBorder (); // test line border frame mode
50
50
void lineBorderAnnotated (); // test line border frame with annotations
51
+ void annotationFormats (); // various tests for annotation formats
51
52
52
53
private:
53
54
QgsComposition* mComposition ;
@@ -454,6 +455,47 @@ void TestQgsComposerMapGrid::lineBorderAnnotated()
454
455
mComposerMap ->grid ()->setAnnotationEnabled ( false );
455
456
}
456
457
458
+ void TestQgsComposerMapGrid::annotationFormats ()
459
+ {
460
+ // create grids in geographic and projected coordinates
461
+ QgsCoordinateReferenceSystem projectedCrs;
462
+ projectedCrs.createFromSrid ( 3994 );
463
+ QgsCoordinateReferenceSystem geographicCrs;
464
+ geographicCrs.createFromSrid ( 4326 );
465
+
466
+ QgsComposerMapGrid gridGeographic ( " geographic grid" , mComposerMap );
467
+ gridGeographic.setCrs ( geographicCrs );
468
+ QgsComposerMapGrid gridProjected ( " projected grid" , mComposerMap );
469
+ gridProjected.setCrs ( projectedCrs );
470
+
471
+ // decimal degrees format
472
+ gridGeographic.setAnnotationFormat ( QgsComposerMapGrid::DecimalWithSuffix );
473
+ gridGeographic.setAnnotationPrecision ( 1 );
474
+ gridProjected.setAnnotationFormat ( QgsComposerMapGrid::DecimalWithSuffix );
475
+ gridProjected.setAnnotationPrecision ( 1 );
476
+
477
+ // normal e/w
478
+ QCOMPARE ( gridGeographic.gridAnnotationString ( 90 , QgsComposerMapGrid::Longitude ), QString ( " 90.0E" ) );
479
+ QCOMPARE ( gridProjected.gridAnnotationString ( 90 , QgsComposerMapGrid::Longitude ), QString ( " 90.0E" ) );
480
+
481
+ // 0 degrees
482
+ QCOMPARE ( gridGeographic.gridAnnotationString ( 0 , QgsComposerMapGrid::Longitude ), QString ( " 0.0" ) );
483
+ QCOMPARE ( gridProjected.gridAnnotationString ( 0 , QgsComposerMapGrid::Longitude ), QString ( " 0.0E" ) );
484
+
485
+ // 180 degrees
486
+ QCOMPARE ( gridGeographic.gridAnnotationString ( 180 , QgsComposerMapGrid::Longitude ), QString ( " 180.0" ) );
487
+ QCOMPARE ( gridProjected.gridAnnotationString ( 180 , QgsComposerMapGrid::Longitude ), QString ( " 180.0E" ) );
488
+
489
+ // normal n/s
490
+ QCOMPARE ( gridGeographic.gridAnnotationString ( 45 , QgsComposerMapGrid::Latitude ), QString ( " 45.0N" ) );
491
+ QCOMPARE ( gridProjected.gridAnnotationString ( 45 , QgsComposerMapGrid::Latitude ), QString ( " 45.0N" ) );
492
+
493
+ // 0 north/south
494
+ QCOMPARE ( gridGeographic.gridAnnotationString ( 0 , QgsComposerMapGrid::Latitude ), QString ( " 0.0" ) );
495
+ QCOMPARE ( gridProjected.gridAnnotationString ( 0 , QgsComposerMapGrid::Latitude ), QString ( " 0.0N" ) );
496
+
497
+ }
498
+
457
499
458
500
459
501
QTEST_MAIN ( TestQgsComposerMapGrid )
0 commit comments