Skip to content
Permalink
Browse files

Use a simpler image for testing composer map rotation and overview

Update expected results and configuration of new image
Add rendering anomalies, as determined by travis ubuntu 12.02
  • Loading branch information
Sandro Santilli
Sandro Santilli committed Feb 5, 2015
1 parent 32ab967 commit fb344ff1b663c8029f7c7007f86c8411b8580a62
@@ -57,10 +57,10 @@ void TestQgsComposerMapOverview::initTestCase()
QgsApplication::initQgis();

//create maplayers from testdata and add to layer registry
QFileInfo rasterFileInfo( QString( TEST_DATA_DIR ) + QDir::separator() + "landsat.tif" );
QFileInfo rasterFileInfo( QString( TEST_DATA_DIR ) + QDir::separator() + "rgb256x256.png" );
mRasterLayer = new QgsRasterLayer( rasterFileInfo.filePath(),
rasterFileInfo.completeBaseName() );
QgsMultiBandColorRenderer* rasterRenderer = new QgsMultiBandColorRenderer( mRasterLayer->dataProvider(), 2, 3, 4 );
QgsMultiBandColorRenderer* rasterRenderer = new QgsMultiBandColorRenderer( mRasterLayer->dataProvider(), 1, 2, 3 );
mRasterLayer->setRenderer( rasterRenderer );

QgsMapLayerRegistry::instance()->addMapLayers( QList<QgsMapLayer*>() << mRasterLayer );
@@ -103,11 +103,11 @@ void TestQgsComposerMapOverview::cleanup()

void TestQgsComposerMapOverview::overviewMap()
{
QgsComposerMap* overviewMap = new QgsComposerMap( mComposition, 20, 130, 70, 70 );
QgsComposerMap* overviewMap = new QgsComposerMap( mComposition, 20, 130, 70, 70 );
overviewMap->setFrameEnabled( true );
mComposition->addComposerMap( overviewMap );
mComposerMap->setNewExtent( QgsRectangle( 785462.375, 3341423.125, 789262.375, 3343323.125 ) ); //zoom in
overviewMap->setNewExtent( QgsRectangle( 781662.375, 3339523.125, 793062.375, 3350923.125 ) );
mComposerMap->setNewExtent( QgsRectangle( 96, -152, 160, -120 ) ); //zoom in
overviewMap->setNewExtent( QgsRectangle( 0, -256, 256, 0 ) );
overviewMap->overview()->setFrameMap( mComposerMap->id() );
QgsCompositionChecker checker( "composermap_overview", mComposition );

@@ -121,9 +121,9 @@ void TestQgsComposerMapOverview::overviewMapRotated()
QgsComposerMap* overviewMap = new QgsComposerMap( mComposition, 20, 130, 70, 70 );
overviewMap->setFrameEnabled( true );
mComposition->addComposerMap( overviewMap );
mComposerMap->setNewExtent( QgsRectangle( 785462.375, 3341423.125, 789262.375, 3343323.125 ) ); //zoom in
mComposerMap->setNewExtent( QgsRectangle( 96, -144, 160, -112 ) ); //zoom in
mComposerMap->setMapRotation( 30 );
overviewMap->setNewExtent( QgsRectangle( 781662.375, 3339523.125, 793062.375, 3350923.125 ) );
overviewMap->setNewExtent( QgsRectangle( 0, -256, 256, 0 ) );
overviewMap->overview()->setFrameMap( mComposerMap->id() );
QgsCompositionChecker checker( "composermap_overview_rotated", mComposition );

@@ -138,9 +138,9 @@ void TestQgsComposerMapOverview::overviewMapRotated2()
QgsComposerMap* overviewMap = new QgsComposerMap( mComposition, 20, 130, 70, 70 );
overviewMap->setFrameEnabled( true );
mComposition->addComposerMap( overviewMap );
mComposerMap->setNewExtent( QgsRectangle( 785462.375, 3341423.125, 789262.375, 3343323.125 ) ); //zoom in
mComposerMap->setNewExtent( QgsRectangle( 96, -152, 160, -120 ) ); //zoom in
overviewMap->setMapRotation( 30 );
overviewMap->setNewExtent( QgsRectangle( 781662.375, 3339523.125, 793062.375, 3350923.125 ) );
overviewMap->setNewExtent( QgsRectangle( 0, -256, 256, 0 ) );
overviewMap->overview()->setFrameMap( mComposerMap->id() );
QgsCompositionChecker checker( "composermap_overview_rotated2", mComposition );

@@ -154,8 +154,8 @@ void TestQgsComposerMapOverview::overviewMapBlending()
QgsComposerMap* overviewMapBlend = new QgsComposerMap( mComposition, 20, 130, 70, 70 );
overviewMapBlend->setFrameEnabled( true );
mComposition->addComposerMap( overviewMapBlend );
mComposerMap->setNewExtent( QgsRectangle( 785462.375, 3341423.125, 789262.375, 3343323.125 ) ); //zoom in
overviewMapBlend->setNewExtent( QgsRectangle( 781662.375, 3339523.125, 793062.375, 3350923.125 ) );
mComposerMap->setNewExtent( QgsRectangle( 96, -152, 160, -120 ) ); //zoom in
overviewMapBlend->setNewExtent( QgsRectangle( 0, -256, 256, 0 ) );
overviewMapBlend->overview()->setFrameMap( mComposerMap->id() );
overviewMapBlend->overview()->setBlendMode( QPainter::CompositionMode_Multiply );

@@ -171,8 +171,8 @@ void TestQgsComposerMapOverview::overviewMapInvert()
QgsComposerMap* overviewMapInvert = new QgsComposerMap( mComposition, 20, 130, 70, 70 );
overviewMapInvert->setFrameEnabled( true );
mComposition->addComposerMap( overviewMapInvert );
mComposerMap->setNewExtent( QgsRectangle( 785462.375, 3341423.125, 789262.375, 3343323.125 ) ); //zoom in
overviewMapInvert->setNewExtent( QgsRectangle( 781662.375, 3339523.125, 793062.375, 3350923.125 ) );
mComposerMap->setNewExtent( QgsRectangle( 96, -152, 160, -120 ) ); //zoom in
overviewMapInvert->setNewExtent( QgsRectangle( 0, -256, 256, 0 ) );
overviewMapInvert->overview()->setFrameMap( mComposerMap->id() );
overviewMapInvert->overview()->setInverted( true );

@@ -188,8 +188,8 @@ void TestQgsComposerMapOverview::overviewMapCenter()
QgsComposerMap* overviewMapCenter = new QgsComposerMap( mComposition, 20, 130, 70, 70 );
overviewMapCenter->setFrameEnabled( true );
mComposition->addComposerMap( overviewMapCenter );
mComposerMap->setNewExtent( QgsRectangle( 785462.375 + 5000, 3341423.125, 789262.375 + 5000, 3343323.125 ) ); //zoom in
overviewMapCenter->setNewExtent( QgsRectangle( 781662.375, 3339523.125, 793062.375, 3350923.125 ) );
mComposerMap->setNewExtent( QgsRectangle( 192, -288, 320, -224 ) );
overviewMapCenter->setNewExtent( QgsRectangle( 0, -256, 256, 0 ) );
overviewMapCenter->overview()->setFrameMap( mComposerMap->id() );
overviewMapCenter->overview()->setCentered( true );

@@ -65,10 +65,10 @@ void TestQgsComposerRotation::initTestCase()
QgsApplication::initQgis();

//create maplayers from testdata and add to layer registry
QFileInfo rasterFileInfo( QString( TEST_DATA_DIR ) + QDir::separator() + "landsat.tif" );
QFileInfo rasterFileInfo( QString( TEST_DATA_DIR ) + QDir::separator() + "rgb256x256.png" );
mRasterLayer = new QgsRasterLayer( rasterFileInfo.filePath(),
rasterFileInfo.completeBaseName() );
QgsMultiBandColorRenderer* rasterRenderer = new QgsMultiBandColorRenderer( mRasterLayer->dataProvider(), 2, 3, 4 );
QgsMultiBandColorRenderer* rasterRenderer = new QgsMultiBandColorRenderer( mRasterLayer->dataProvider(), 1, 2, 3 );
mRasterLayer->setRenderer( rasterRenderer );

QgsMapLayerRegistry::instance()->addMapLayers( QList<QgsMapLayer*>() << mRasterLayer );
@@ -180,10 +180,10 @@ void TestQgsComposerRotation::oldLabelRotationApi()
void TestQgsComposerRotation::mapRotation()
{
//test map rotation
QgsComposerMap* composerMap = new QgsComposerMap( mComposition, 20, 20, 200, 100 );
QgsComposerMap* composerMap = new QgsComposerMap( mComposition, 20, 20, 100, 50 );
composerMap->setFrameEnabled( true );
mComposition->addItem( composerMap );
composerMap->setNewExtent( QgsRectangle( 781662.375, 3339523.125, 793062.375, 3345223.125 ) );
composerMap->setNewExtent( QgsRectangle( 0, -192, 256, -64 ) );
composerMap->setMapRotation( 90 );

QgsCompositionChecker checker( "composerrotation_maprotation", mComposition );
@@ -196,10 +196,10 @@ void TestQgsComposerRotation::mapRotation()
void TestQgsComposerRotation::mapItemRotation()
{
//test map item rotation
QgsComposerMap* composerMap = new QgsComposerMap( mComposition, 20, 20, 200, 100 );
QgsComposerMap* composerMap = new QgsComposerMap( mComposition, 20, 50, 100, 50 );
composerMap->setFrameEnabled( true );
mComposition->addItem( composerMap );
composerMap->setNewExtent( QgsRectangle( 781662.375, 3339523.125, 793062.375, 3345223.125 ) );
composerMap->setNewExtent( QgsRectangle( 0, -192, 256, -64 ) );
composerMap->setItemRotation( 90, true );

QgsCompositionChecker checker( "composerrotation_mapitemrotation", mComposition );
@@ -45,12 +45,12 @@ class TestQgsComposerMap(TestCase):
def __init__(self, methodName):
"""Run once on class initialisation."""
unittest.TestCase.__init__(self, methodName)
myPath = os.path.join(TEST_DATA_DIR, 'landsat.tif')
myPath = os.path.join(TEST_DATA_DIR, 'rgb256x256.png')
rasterFileInfo = QFileInfo(myPath)
mRasterLayer = QgsRasterLayer(rasterFileInfo.filePath(),
rasterFileInfo.completeBaseName())
rasterRenderer = QgsMultiBandColorRenderer(
mRasterLayer.dataProvider(), 2, 3, 4)
mRasterLayer.dataProvider(), 1, 2, 3)
mRasterLayer.setRenderer(rasterRenderer)
#pipe = mRasterLayer.pipe()
#assert pipe.set(rasterRenderer), 'Cannot set pipe renderer'
@@ -73,11 +73,9 @@ def testOverviewMap(self):
overviewMap.setFrameEnabled(True)
self.mComposition.addComposerMap(overviewMap)
# zoom in
myRectangle = QgsRectangle(785462.375, 3341423.125,
789262.375, 3343323.125)
myRectangle = QgsRectangle(96, -152, 160, -120)
self.mComposerMap.setNewExtent(myRectangle)
myRectangle2 = QgsRectangle(781662.375, 3339523.125,
793062.375, 3350923.125)
myRectangle2 = QgsRectangle(0, -256, 256, 0)
overviewMap.setNewExtent(myRectangle2)
overviewMap.setOverviewFrameMap(self.mComposerMap.id())
checker = QgsCompositionChecker('composermap_overview', self.mComposition)
@@ -90,11 +88,9 @@ def testOverviewMapBlend(self):
overviewMap.setFrameEnabled(True)
self.mComposition.addComposerMap(overviewMap)
# zoom in
myRectangle = QgsRectangle(785462.375, 3341423.125,
789262.375, 3343323.125)
myRectangle = QgsRectangle(96, -152, 160, -120)
self.mComposerMap.setNewExtent(myRectangle)
myRectangle2 = QgsRectangle(781662.375, 3339523.125,
793062.375, 3350923.125)
myRectangle2 = QgsRectangle(0, -256, 256, 0)
overviewMap.setNewExtent(myRectangle2)
overviewMap.setOverviewFrameMap(self.mComposerMap.id())
overviewMap.setOverviewBlendMode(QPainter.CompositionMode_Multiply)
@@ -108,11 +104,9 @@ def testOverviewMapInvert(self):
overviewMap.setFrameEnabled(True)
self.mComposition.addComposerMap(overviewMap)
# zoom in
myRectangle = QgsRectangle(785462.375, 3341423.125,
789262.375, 3343323.125)
myRectangle = QgsRectangle(96, -152, 160, -120)
self.mComposerMap.setNewExtent(myRectangle)
myRectangle2 = QgsRectangle(781662.375, 3339523.125,
793062.375, 3350923.125)
myRectangle2 = QgsRectangle(0, -256, 256, 0)
overviewMap.setNewExtent(myRectangle2)
overviewMap.setOverviewFrameMap(self.mComposerMap.id())
overviewMap.setOverviewInverted(True)
@@ -126,11 +120,9 @@ def testOverviewMapCenter(self):
overviewMap.setFrameEnabled(True)
self.mComposition.addComposerMap(overviewMap)
# zoom in
myRectangle = QgsRectangle(785462.375+5000, 3341423.125,
789262.375+5000, 3343323.125)
myRectangle = QgsRectangle(192, -288, 320, -224)
self.mComposerMap.setNewExtent(myRectangle)
myRectangle2 = QgsRectangle(781662.375, 3339523.125,
793062.375, 3350923.125)
myRectangle2 = QgsRectangle(0, -256, 256, 0)
overviewMap.setNewExtent(myRectangle2)
overviewMap.setOverviewFrameMap(self.mComposerMap.id())
overviewMap.setOverviewInverted(False)
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit fb344ff

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