@@ -52,10 +52,12 @@ class TestQgsRasterLayer: public QObject
52
52
53
53
void isValid ();
54
54
void pseudoColor ();
55
+ void landsatBasic ();
55
56
void checkDimensions ();
56
57
private:
57
58
bool render (QString theFileName);
58
59
QgsRasterLayer * mpRasterLayer;
60
+ QgsRasterLayer * mpLandsatRasterLayer;
59
61
QgsMapRender * mpMapRenderer;
60
62
QString mReport ;
61
63
};
@@ -77,13 +79,18 @@ void TestQgsRasterLayer::initTestCase()
77
79
std::cout << " User DB PATH: " << QgsApplication::qgisUserDbFilePath ().toLocal8Bit ().data () << std::endl;
78
80
79
81
// create a raster layer that will be used in all tests...
80
- QString myFileName (TEST_DATA_DIR); // defined in CmakeLists.txt
81
- myFileName = myFileName + QDir::separator () + " tenbytenraster.asc" ;
82
+ QString myTestDir (TEST_DATA_DIR); // defined in CmakeLists.txt
83
+ QString myFileName = myTestDir + QDir::separator () + " tenbytenraster.asc" ;
84
+ QString myLandsatFileName = myTestDir + QDir::separator () + " landsat_clip.tif" ;
82
85
QFileInfo myRasterFileInfo ( myFileName );
83
86
mpRasterLayer = new QgsRasterLayer ( myRasterFileInfo.filePath (),
84
87
myRasterFileInfo.completeBaseName () );
88
+ QFileInfo myLandsatRasterFileInfo ( myLandsatFileName );
89
+ mpLandsatRasterLayer = new QgsRasterLayer ( myLandsatRasterFileInfo.filePath (),
90
+ myLandsatRasterFileInfo.completeBaseName () );
85
91
// Register the layer with the registry
86
92
QgsMapLayerRegistry::instance ()->addMapLayer (mpRasterLayer);
93
+ QgsMapLayerRegistry::instance ()->addMapLayer (mpLandsatRasterLayer);
87
94
// add the test layer to the maprender
88
95
mpMapRenderer = new QgsMapRender ();
89
96
QStringList myLayers;
@@ -109,20 +116,30 @@ void TestQgsRasterLayer::cleanupTestCase()
109
116
void TestQgsRasterLayer::isValid ()
110
117
{
111
118
QVERIFY ( mpRasterLayer->isValid () );
119
+ mpMapRenderer->setExtent (mpRasterLayer->extent ());
112
120
QVERIFY ( render (" raster" ) );
113
121
}
114
122
115
123
void TestQgsRasterLayer::pseudoColor ()
116
124
{
117
- mpRasterLayer->setDrawingStyle (QgsRasterLayer::SINGLE_BAND_PSEUDO_COLOR);
118
- mpRasterLayer->setColorShadingAlgorithm (QgsRasterLayer::PSEUDO_COLOR);
119
- mpRasterLayer->setContrastEnhancementAlgorithm (
120
- QgsContrastEnhancement::STRETCH_TO_MINMAX, false );
121
- mpRasterLayer->setMinimumValue (mpRasterLayer->getGrayBandName (),0.0 , false );
122
- mpRasterLayer->setMaximumValue (mpRasterLayer->getGrayBandName (),0.0 );
123
- QVERIFY (render (" raster_pseudo" ));
125
+ mpRasterLayer->setDrawingStyle (QgsRasterLayer::SINGLE_BAND_PSEUDO_COLOR);
126
+ mpRasterLayer->setColorShadingAlgorithm (QgsRasterLayer::PSEUDO_COLOR);
127
+ mpRasterLayer->setContrastEnhancementAlgorithm (
128
+ QgsContrastEnhancement::STRETCH_TO_MINMAX, false );
129
+ mpRasterLayer->setMinimumValue (mpRasterLayer->getGrayBandName (),0.0 , false );
130
+ mpRasterLayer->setMaximumValue (mpRasterLayer->getGrayBandName (),10.0 );
131
+ mpMapRenderer->setExtent (mpRasterLayer->extent ());
132
+ QVERIFY (render (" raster_pseudo" ));
124
133
}
125
134
135
+ void TestQgsRasterLayer::landsatBasic ()
136
+ {
137
+ QStringList myLayers;
138
+ myLayers << mpLandsatRasterLayer->getLayerID ();
139
+ mpMapRenderer->setLayerSet (myLayers);
140
+ mpMapRenderer->setExtent (mpLandsatRasterLayer->extent ());
141
+ QVERIFY (render (" landsat_basic" ));
142
+ }
126
143
void TestQgsRasterLayer::checkDimensions ()
127
144
{
128
145
QVERIFY ( mpRasterLayer->getRasterXDim () == 10 );
@@ -135,7 +152,6 @@ void TestQgsRasterLayer::checkDimensions()
135
152
bool TestQgsRasterLayer::render (QString theTestType)
136
153
{
137
154
mReport += " <h2>" + theTestType + " </h2>\n " ;
138
- mpMapRenderer->setExtent (mpRasterLayer->extent ());
139
155
QString myDataDir (TEST_DATA_DIR); // defined in CmakeLists.txt
140
156
QString myTestDataDir = myDataDir + QDir::separator ();
141
157
QgsRenderChecker myChecker;
0 commit comments