Skip to content
Permalink
Browse files

Fix some test failures

  • Loading branch information
nyalldawson committed Jan 17, 2017
1 parent 4896569 commit 6a4d605256a7a8a3215c20dc0978cb82c09ecddb
@@ -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 )
{
@@ -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

@@ -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();
@@ -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 );
@@ -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" );

@@ -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)
@@ -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)

0 comments on commit 6a4d605

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