Navigation Menu

Skip to content

Commit

Permalink
Fix some test failures
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jan 17, 2017
1 parent 4896569 commit 6a4d605
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 11 deletions.
4 changes: 4 additions & 0 deletions src/server/qgswmsconfigparser.cpp
Expand Up @@ -79,6 +79,10 @@ QgsComposition* QgsWmsConfigParser::createPrintComposition( const QString& compo
continue;
}

// Change CRS of map to match requested CRS
if ( mapSettings.destinationCrs().isValid() )
currentMap->setCrs( mapSettings.destinationCrs() );

QStringList coordList = extent.split( QStringLiteral( "," ) );
if ( coordList.size() < 4 )
{
Expand Down
2 changes: 1 addition & 1 deletion tests/src/core/testqgsatlascomposition.cpp
Expand Up @@ -146,7 +146,7 @@ void TestQgsAtlasComposition::init()
// select epsg:2154
QgsCoordinateReferenceSystem crs;
crs.createFromSrid( 2154 );
mMapSettings->setDestinationCrs( crs );
QgsProject::instance()->setCrs( crs );
mComposition = new QgsComposition( *mMapSettings, QgsProject::instance() );
mComposition->setPaperSize( 297, 210 ); //A4 landscape

Expand Down
10 changes: 4 additions & 6 deletions tests/src/core/testqgscomposerscalebar.cpp
Expand Up @@ -75,6 +75,10 @@ void TestQgsComposerScaleBar::initTestCase()
// so we enforce C locale to make sure we get expected result
QLocale::setDefault( QLocale::c() );

//reproject to WGS84
QgsCoordinateReferenceSystem destCRS;
destCRS.createFromId( 4326, QgsCoordinateReferenceSystem::EpsgCrsId );
QgsProject::instance()->setCrs( destCRS );
QgsProject::instance()->setEllipsoid( QStringLiteral( "WGS84" ) );

mMapSettings = new QgsMapSettings();
Expand All @@ -89,12 +93,6 @@ void TestQgsComposerScaleBar::initTestCase()
//create composition with composer map
mMapSettings->setLayers( QList<QgsMapLayer*>() << mRasterLayer );

//reproject to WGS84
QgsCoordinateReferenceSystem destCRS;
destCRS.createFromId( 4326, QgsCoordinateReferenceSystem::EpsgCrsId );
mMapSettings->setDestinationCrs( destCRS );
mMapSettings->setCrsTransformEnabled( true );

mComposition = new QgsComposition( *mMapSettings, QgsProject::instance() );
mComposition->setPaperSize( 297, 210 ); //A4 landscape
mComposerMap = new QgsComposerMap( mComposition, 20, 20, 150, 150 );
Expand Down
1 change: 1 addition & 0 deletions tests/src/core/testqgscomposition.cpp
Expand Up @@ -618,6 +618,7 @@ void TestQgsComposition::itemVariablesFunction()
QgsComposerMap* map = new QgsComposerMap( composition );
map->setNewExtent( extent );
map->setSceneRect( QRectF( 30, 60, 200, 100 ) );
map->setCrs( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ) );
composition->addComposerMap( map );
map->setId( "map_id" );

Expand Down
4 changes: 1 addition & 3 deletions tests/src/python/test_qgsatlascomposition.py
Expand Up @@ -46,13 +46,11 @@ def testCase(self):
self.mapSettings = QgsMapSettings()
layerStringList = [mVectorLayer]
self.mapSettings.setLayers(layerStringList)
self.mapSettings.setCrsTransformEnabled(True)
self.mapSettings.setMapUnits(QgsUnitTypes.DistanceMeters)

# select epsg:2154
crs = QgsCoordinateReferenceSystem()
crs.createFromSrid(2154)
self.mapSettings.setDestinationCrs(crs)
QgsProject.instance().setCrs(crs)

self.mComposition = QgsComposition(self.mapSettings, QgsProject.instance())
self.mComposition.setPaperSize(297, 210)
Expand Down
2 changes: 1 addition & 1 deletion tests/src/python/test_qgscomposerpicture.py
Expand Up @@ -119,10 +119,10 @@ def testTrueNorth(self):
"""Test syncing picture to true north"""

mapSettings = QgsMapSettings()
mapSettings.setDestinationCrs(QgsCoordinateReferenceSystem.fromEpsgId(3575))
composition = QgsComposition(mapSettings, QgsProject.instance())

composerMap = QgsComposerMap(composition)
composerMap.setCrs(QgsCoordinateReferenceSystem.fromEpsgId(3575))
composerMap.setNewExtent(QgsRectangle(-2126029.962, -2200807.749, -119078.102, -757031.156))
composition.addComposerMap(composerMap)

Expand Down

0 comments on commit 6a4d605

Please sign in to comment.