Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Followup map settings variable commit
  • Loading branch information
nyalldawson committed Jan 22, 2019
1 parent f514516 commit 85a6b1a
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/core/expression/qgsexpression.cpp
Expand Up @@ -749,7 +749,7 @@ void QgsExpression::initVariableHelp()
sVariableHelpTexts.insert( QStringLiteral( "map_units" ), QCoreApplication::translate( "variable_help", "Units for map measurements." ) );
sVariableHelpTexts.insert( QStringLiteral( "map_crs_definition" ), QCoreApplication::translate( "variable_help", "Coordinate reference system of map (full definition)." ) );
sVariableHelpTexts.insert( QStringLiteral( "map_crs_acronym" ), QCoreApplication::translate( "variable_help", "Acronym of the coordinate reference system of the map." ) );
sVariableHelpTexts.insert( QStringLiteral( "map_ellipsoid_acr" ), QCoreApplication::translate( "variable_help", "Acronym of the ellipsoid of the coordinate reference system of the map." ) );
sVariableHelpTexts.insert( QStringLiteral( "map_crs_ellipsoid" ), QCoreApplication::translate( "variable_help", "Acronym of the ellipsoid of the coordinate reference system of the map." ) );
sVariableHelpTexts.insert( QStringLiteral( "map_crs_proj4" ), QCoreApplication::translate( "variable_help", "Proj4 definition of the coordinate reference system." ) );
sVariableHelpTexts.insert( QStringLiteral( "map_crs_wkt" ), QCoreApplication::translate( "variable_help", "WKT definition of the coordinate reference system." ) );
sVariableHelpTexts.insert( QStringLiteral( "map_layer_ids" ), QCoreApplication::translate( "variable_help", "List of map layer IDs visible in the map." ) );
Expand Down
2 changes: 1 addition & 1 deletion src/core/layout/qgslayoutitemmap.cpp
Expand Up @@ -1266,7 +1266,7 @@ QgsExpressionContext QgsLayoutItemMap::createExpressionContext() const
scope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "map_crs_description" ), mapCrs.description(), true ) );
scope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "map_units" ), QgsUnitTypes::toString( mapCrs.mapUnits() ), true ) );
scope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "map_crs_acronym" ), mapCrs.projectionAcronym(), true ) );
scope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "map_ellipsoid_acr" ), mapCrs.ellipsoidAcronym(), true ) );
scope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "map_crs_ellipsoid" ), mapCrs.ellipsoidAcronym(), true ) );
scope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "map_crs_proj4" ), mapCrs.toProj4(), true ) );
scope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "map_crs_wkt" ), mapCrs.toWkt(), true ) );

Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsexpressioncontext.cpp
Expand Up @@ -1013,7 +1013,7 @@ QgsExpressionContextScope *QgsExpressionContextUtils::mapSettingsScope( const Qg
scope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "map_units" ), QgsUnitTypes::toString( mapSettings.mapUnits() ), true ) );
scope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "map_crs_description" ), mapSettings.destinationCrs().description(), true ) );
scope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "map_crs_acronym" ), mapSettings.destinationCrs().projectionAcronym(), true ) );
scope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "map_ellipsoid_acr" ), mapSettings.destinationCrs().ellipsoidAcronym(), true ) );
scope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "map_crs_ellipsoid" ), mapSettings.destinationCrs().ellipsoidAcronym(), true ) );
scope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "map_crs_proj4" ), mapSettings.destinationCrs().toProj4(), true ) );
scope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "map_crs_wkt" ), mapSettings.destinationCrs().toWkt(), true ) );

Expand Down
14 changes: 7 additions & 7 deletions tests/src/core/testqgslayoutmap.cpp
Expand Up @@ -626,15 +626,15 @@ void TestQgsLayoutMap::expressionContext()
r = e6.evaluate( &c );
QCOMPARE( r.toString(), QString( "longlat" ) );

//QgsExpression e7( QStringLiteral( "@map_crs_pro4" ) );
//r = e7.evaluate( &c );
//QCOMPARE( r.toString(), QString( "+proj=longlat +datum=WGS84 +no_defs" ) );
QgsExpression e7( QStringLiteral( "@map_crs_proj4" ) );
r = e7.evaluate( &c );
QCOMPARE( r.toString(), QString( "+proj=longlat +datum=WGS84 +no_defs" ) );

//QgsExpression e8( QStringLiteral( "@map_crs_wkt" ) );
//r = e8.evaluate( &c );
//QVERIFY( r.toString().length() >= 15 );
QgsExpression e8( QStringLiteral( "@map_crs_wkt" ) );
r = e8.evaluate( &c );
QVERIFY( r.toString().length() >= 15 );

QgsExpression e9( QStringLiteral( "@map_ellipsoid_acr" ) );
QgsExpression e9( QStringLiteral( "@map_crs_ellipsoid" ) );
r = e9.evaluate( &c );
QCOMPARE( r.toString(), QString( "WGS84" ) );

Expand Down
32 changes: 16 additions & 16 deletions tests/src/core/testqgsmapsettings.cpp
Expand Up @@ -441,27 +441,27 @@ void TestQgsMapSettings::testExpressionContext()

e = QgsExpression( QStringLiteral( "@map_units" ) );
r = e.evaluate( &c );
QCOMPARE( r.toString(), QStringLiteral( "degrees" ) );\
QCOMPARE( r.toString(), QStringLiteral( "degrees" ) );

QgsExpression e5( QStringLiteral( "@map_crs_description" ) );
r = e5.evaluate( &c );
QCOMPARE( r.toString(), QString( "WGS 84" ) );
e = QgsExpression( QStringLiteral( "@map_crs_description" ) );
r = e.evaluate( &c );
QCOMPARE( r.toString(), QStringLiteral( "WGS 84" ) );

QgsExpression e6( QStringLiteral( "@map_crs_acronym" ) );
r = e6.evaluate( &c );
QCOMPARE( r.toString(), QString( "longlat" ) );
e = QgsExpression( QStringLiteral( "@map_crs_acronym" ) );
r = e.evaluate( &c );
QCOMPARE( r.toString(), QStringLiteral( "longlat" ) );

//QgsExpression e7( QStringLiteral( "@map_crs_pro4" ) );
//r = e7.evaluate( &c );
//QCOMPARE( r.toString(), QString( "+proj=longlat +datum=WGS84 +no_defs" ) );
e = QgsExpression( QStringLiteral( "@map_crs_proj4" ) );
r = e.evaluate( &c );
QCOMPARE( r.toString(), QStringLiteral( "+proj=longlat +datum=WGS84 +no_defs" ) );

//QgsExpression e8( QStringLiteral( "@map_crs_wkt" ) );
//r = e8.evaluate( &c );
//QVERIFY( r.toString().length() > 15 );
e = QgsExpression( QStringLiteral( "@map_crs_wkt" ) );
r = e.evaluate( &c );
QVERIFY( r.toString().length() > 15 );

QgsExpression e9( QStringLiteral( "@map_ellipsoid_acr" ) );
r = e9.evaluate( &c );
QCOMPARE( r.toString(), QString( "WGS84" ) );
e = QgsExpression( QStringLiteral( "@map_crs_ellipsoid" ) );
r = e.evaluate( &c );
QCOMPARE( r.toString(), QStringLiteral( "WGS84" ) );
}

QGSTEST_MAIN( TestQgsMapSettings )
Expand Down

0 comments on commit 85a6b1a

Please sign in to comment.