@@ -3197,6 +3197,22 @@ void TestQgsGeometry::polygon()
3197
3197
<< QgsPoint ( QgsWkbTypes::Point , 0 , 10 ) << QgsPoint ( QgsWkbTypes::Point , 10 , 10 )
3198
3198
<< QgsPoint ( QgsWkbTypes::Point , 10 , 0 ) << QgsPoint ( QgsWkbTypes::Point , 0 , 0 ) );
3199
3199
exportPolygon.setExteriorRing ( ext );
3200
+
3201
+ // GML document for compare
3202
+ QDomDocument doc ( " gml" );
3203
+
3204
+ // as GML2
3205
+ QString expectedSimpleGML2 ( " <Polygon xmlns=\" gml\" ><outerBoundaryIs xmlns=\" gml\" ><LinearRing xmlns=\" gml\" ><coordinates xmlns=\" gml\" >0,0 0,10 10,10 10,0 0,0</coordinates></LinearRing></outerBoundaryIs></Polygon>" );
3206
+ QCOMPARE ( elemToString ( exportPolygon.asGML2 ( doc ) ), expectedSimpleGML2 );
3207
+
3208
+ // as GML3
3209
+ QString expectedSimpleGML3 ( " <Polygon xmlns=\" gml\" ><exterior xmlns=\" gml\" ><LinearRing xmlns=\" gml\" ><posList xmlns=\" gml\" srsDimension=\" 2\" >0 0 0 10 10 10 10 0 0 0</posList></LinearRing></exterior></Polygon>" );
3210
+ QCOMPARE ( elemToString ( exportPolygon.asGML3 ( doc ) ), expectedSimpleGML3 );
3211
+
3212
+ // as JSON
3213
+ QString expectedSimpleJson ( " {\" type\" : \" Polygon\" , \" coordinates\" : [[ [0, 0], [0, 10], [10, 10], [10, 0], [0, 0]]] }" );
3214
+ QCOMPARE ( exportPolygon.asJSON (), expectedSimpleJson );
3215
+
3200
3216
ring = new QgsLineString ();
3201
3217
ring->setPoints ( QgsPointSequence () << QgsPoint ( QgsWkbTypes::Point , 1 , 1 )
3202
3218
<< QgsPoint ( QgsWkbTypes::Point , 1 , 9 ) << QgsPoint ( QgsWkbTypes::Point , 9 , 9 )
@@ -3222,7 +3238,6 @@ void TestQgsGeometry::polygon()
3222
3238
QCOMPARE ( exportPolygonFloat.asJSON ( 3 ), expectedJsonPrec3 );
3223
3239
3224
3240
// as GML2
3225
- QDomDocument doc ( QStringLiteral ( " gml" ) );
3226
3241
QString expectedGML2 ( QStringLiteral ( " <Polygon xmlns=\" gml\" ><outerBoundaryIs xmlns=\" gml\" ><LinearRing xmlns=\" gml\" ><coordinates xmlns=\" gml\" >0,0 0,10 10,10 10,0 0,0</coordinates></LinearRing></outerBoundaryIs>" ) );
3227
3242
expectedGML2 += QStringLiteral ( " <innerBoundaryIs xmlns=\" gml\" ><LinearRing xmlns=\" gml\" ><coordinates xmlns=\" gml\" >1,1 1,9 9,9 9,1 1,1</coordinates></LinearRing></innerBoundaryIs></Polygon>" );
3228
3243
QCOMPARE ( elemToString ( exportPolygon.asGML2 ( doc ) ), expectedGML2 );
0 commit comments