@@ -51,10 +51,13 @@ class TestQgsInvertedPolygon : public QObject
51
51
void graduatedSubRenderer ();
52
52
void preprocess ();
53
53
void projectionTest ();
54
+ #if defined(GDAL_VERSION_NUM) && GDAL_VERSION_MAJOR >= 2
55
+ void curvedPolygons ();
56
+ #endif
54
57
55
58
private:
56
59
bool mTestHasError ;
57
- bool setQml ( const QString& qmlFile );
60
+ bool setQml ( QgsVectorLayer* vlayer, const QString& qmlFile );
58
61
bool imageCheck ( const QString& theType, const QgsRectangle* = 0 );
59
62
QgsMapSettings mMapSettings ;
60
63
QgsVectorLayer * mpPolysLayer;
@@ -93,8 +96,7 @@ void TestQgsInvertedPolygon::initTestCase()
93
96
mpPolysLayer->setSimplifyMethod ( simplifyMethod );
94
97
95
98
// Register the layer with the registry
96
- QgsMapLayerRegistry::instance ()->addMapLayers (
97
- QList<QgsMapLayer *>() << mpPolysLayer );
99
+ QgsMapLayerRegistry::instance ()->addMapLayers ( QList<QgsMapLayer *>() << mpPolysLayer );
98
100
99
101
mMapSettings .setLayers ( QStringList () << mpPolysLayer->id () );
100
102
mReport += " <h1>Inverted Polygon Renderer Tests</h1>\n " ;
@@ -117,22 +119,22 @@ void TestQgsInvertedPolygon::cleanupTestCase()
117
119
void TestQgsInvertedPolygon::singleSubRenderer ()
118
120
{
119
121
mReport += " <h2>Inverted polygon renderer, single sub renderer test</h2>\n " ;
120
- QVERIFY ( setQml ( " inverted_polys_single.qml" ) );
122
+ QVERIFY ( setQml ( mpPolysLayer, " inverted_polys_single.qml" ) );
121
123
QVERIFY ( imageCheck ( " inverted_polys_single" ) );
122
124
}
123
125
124
126
void TestQgsInvertedPolygon::graduatedSubRenderer ()
125
127
{
126
128
mReport += " <h2>Inverted polygon renderer, graduated sub renderer test</h2>\n " ;
127
- QVERIFY ( setQml ( " inverted_polys_graduated.qml" ) );
129
+ QVERIFY ( setQml ( mpPolysLayer, " inverted_polys_graduated.qml" ) );
128
130
QVERIFY ( imageCheck ( " inverted_polys_graduated" ) );
129
131
}
130
132
131
133
void TestQgsInvertedPolygon::preprocess ()
132
134
{
133
135
// FIXME will have to find some overlapping polygons
134
136
mReport += " <h2>Inverted polygon renderer, preprocessing test</h2>\n " ;
135
- QVERIFY ( setQml ( " inverted_polys_preprocess.qml" ) );
137
+ QVERIFY ( setQml ( mpPolysLayer, " inverted_polys_preprocess.qml" ) );
136
138
QVERIFY ( imageCheck ( " inverted_polys_preprocess" ) );
137
139
}
138
140
@@ -142,25 +144,44 @@ void TestQgsInvertedPolygon::projectionTest()
142
144
mMapSettings .setDestinationCrs ( QgsCoordinateReferenceSystem ( " EPSG:2154" ) );
143
145
mMapSettings .setCrsTransformEnabled ( true );
144
146
QgsRectangle extent ( QgsPoint ( -8639421 , 8382691 ), QgsPoint ( -3969110 , 12570905 ) );
145
- QVERIFY ( setQml ( " inverted_polys_single.qml" ) );
147
+ QVERIFY ( setQml ( mpPolysLayer, " inverted_polys_single.qml" ) );
146
148
QVERIFY ( imageCheck ( " inverted_polys_projection" , &extent ) );
147
- QVERIFY ( setQml ( " inverted_polys_preprocess.qml" ) );
149
+ QVERIFY ( setQml ( mpPolysLayer, " inverted_polys_preprocess.qml" ) );
148
150
QVERIFY ( imageCheck ( " inverted_polys_projection2" , &extent ) );
149
151
mMapSettings .setCrsTransformEnabled ( false );
150
152
}
151
153
154
+ #if defined(GDAL_VERSION_NUM) && GDAL_VERSION_MAJOR >= 2
155
+ // This test relies on GDAL support of curved polygons
156
+ void TestQgsInvertedPolygon::curvedPolygons ()
157
+ {
158
+ QString myCurvedPolysFileName = mTestDataDir + " curved_polys.gpkg" ;
159
+ QFileInfo myCurvedPolyFileInfo ( myCurvedPolysFileName );
160
+ QgsVectorLayer* curvedLayer = new QgsVectorLayer ( myCurvedPolyFileInfo.filePath () + " |layername=polys" ,
161
+ myCurvedPolyFileInfo.completeBaseName (), " ogr" );
162
+ curvedLayer->setSimplifyMethod ( simplifyMethod );
163
+ QgsMapLayerRegistry::instance ()->addMapLayers ( QList<QgsMapLayer *>() << curvedLayer );
164
+
165
+ mReport += " <h2>Inverted polygon renderer, curved polygons test</h2>\n " ;
166
+ mMapSettings .setLayers ( QStringList () << curvedLayer->id () );
167
+ QVERIFY ( setQml ( mpCurvedPolysLayer, " inverted_polys_single.qml" ) );
168
+ QVERIFY ( imageCheck ( " inverted_polys_curved" ) );
169
+ mMapSettings .setLayers ( QStringList () << curvedLayer->id () );
170
+ }
171
+ #endif
172
+
152
173
//
153
174
// Private helper functions not called directly by CTest
154
175
//
155
176
156
- bool TestQgsInvertedPolygon::setQml ( const QString& qmlFile )
177
+ bool TestQgsInvertedPolygon::setQml ( QgsVectorLayer* vlayer, const QString& qmlFile )
157
178
{
158
179
// load a qml style and apply to our layer
159
180
// the style will correspond to the renderer
160
181
// type we are testing
161
182
bool myStyleFlag = false ;
162
183
QString myFileName = mTestDataDir + qmlFile;
163
- QString error = mpPolysLayer ->loadNamedStyle ( myFileName, myStyleFlag );
184
+ QString error = vlayer ->loadNamedStyle ( myFileName, myStyleFlag );
164
185
if ( !myStyleFlag )
165
186
{
166
187
qDebug ( " %s" , error.toLocal8Bit ().constData () );
0 commit comments