@@ -611,6 +611,7 @@ void TestQgsGeometry::point()
611
611
612
612
// bad WKT
613
613
QVERIFY ( !p14.fromWkt ( " Polygon()" ) );
614
+ QVERIFY ( !p14.fromWkt ( " Point(1 )" ) );
614
615
615
616
// asGML2
616
617
QgsPoint exportPoint ( 1 , 2 );
@@ -626,6 +627,9 @@ void TestQgsGeometry::point()
626
627
QCOMPARE ( elemToString ( exportPoint.asGML3 ( doc ) ), expectedGML3 );
627
628
QString expectedGML3prec3 ( QStringLiteral ( " <Point xmlns=\" gml\" ><pos xmlns=\" gml\" srsDimension=\" 2\" >0.333 0.667</pos></Point>" ) );
628
629
QCOMPARE ( elemToString ( exportPointFloat.asGML3 ( doc, 3 ) ), expectedGML3prec3 );
630
+ QgsPoint exportPointZ ( 1 , 2 , 3 );
631
+ QString expectedGML2Z ( QStringLiteral ( " <Point xmlns=\" gml\" ><pos xmlns=\" gml\" srsDimension=\" 3\" >1 2 3</pos></Point>" ) );
632
+ QGSCOMPAREGML ( elemToString ( exportPointZ.asGML3 ( doc, 3 ) ), expectedGML2Z );
629
633
630
634
// asJSON
631
635
QString expectedJson ( QStringLiteral ( " {\" type\" : \" Point\" , \" coordinates\" : [1, 2]}" ) );
@@ -4010,9 +4014,15 @@ void TestQgsGeometry::ellipse()
4010
4014
QGSCOMPARENEARPOINT ( q.at ( 1 ), pts.at ( 1 ), 2 );
4011
4015
QGSCOMPARENEARPOINT ( q.at ( 2 ), pts.at ( 2 ), 2 );
4012
4016
QGSCOMPARENEARPOINT ( q.at ( 3 ), pts.at ( 3 ), 2 );
4017
+
4018
+ QVERIFY ( QgsEllipse ( QgsPoint ( 0 , 0 ), 5 , 2 , 0 ).points ( 2 ).isEmpty () ); // segments too low
4019
+
4013
4020
// linestring
4014
4021
QgsLineString *l = new QgsLineString ();
4015
4022
4023
+ l = QgsEllipse ( QgsPoint ( 0 , 0 ), 5 , 2 , 0 ).toLineString ( 2 );
4024
+ QVERIFY ( l->isEmpty () ); // segments too low
4025
+
4016
4026
l = QgsEllipse ( QgsPoint ( 0 , 0 ), 5 , 2 , 0 ).toLineString ( 4 );
4017
4027
QCOMPARE ( l->numPoints (), 4 );
4018
4028
QgsPointSequence pts_l;
@@ -4022,6 +4032,9 @@ void TestQgsGeometry::ellipse()
4022
4032
// polygon
4023
4033
QgsPolygonV2 *p1 = new QgsPolygonV2 ();
4024
4034
4035
+ p1 = QgsEllipse ( QgsPoint ( 0 , 0 ), 5 , 2 , 0 ).toPolygon ( 2 );
4036
+ QVERIFY ( p1->isEmpty () ); // segments too low
4037
+
4025
4038
p1 = QgsEllipse ( QgsPoint ( 0 , 0 ), 5 , 2 , 0 ).toPolygon ( 4 );
4026
4039
q = QgsEllipse ( QgsPoint ( 0 , 0 ), 5 , 2 , 0 ).quadrant ();
4027
4040
QCOMPARE ( p1->vertexAt ( QgsVertexId ( 0 , 0 , 0 ) ), q.at ( 0 ) );
@@ -4420,6 +4433,18 @@ void TestQgsGeometry::regularPolygon()
4420
4433
QCOMPARE ( rp8.interiorAngle (), 60.0 );
4421
4434
QCOMPARE ( rp8.centralAngle (), 120.0 );
4422
4435
4436
+ // points
4437
+ rp8 = QgsRegularPolygon (); // empty
4438
+ QgsPointSequence points = rp8.points ();
4439
+ QVERIFY ( points.isEmpty () );
4440
+ rp8 = QgsRegularPolygon ( QgsPoint (), QgsPoint ( 0 , 5 ), 3 , QgsRegularPolygon::InscribedCircle );
4441
+ points = rp8.points ();
4442
+ QCOMPARE ( points.count (), 3 );
4443
+ QCOMPARE ( points.at ( 0 ), QgsPoint ( 0 , 5 ) );
4444
+ QGSCOMPARENEAR ( points.at ( 1 ).x (), 4.33 , 0.01 );
4445
+ QGSCOMPARENEAR ( points.at ( 1 ).y (), -2.4999 , 0.01 );
4446
+ QGSCOMPARENEAR ( points.at ( 2 ).x (), -4.33 , 0.01 );
4447
+ QGSCOMPARENEAR ( points.at ( 2 ).y (), -2.4999 , 0.01 );
4423
4448
4424
4449
// test conversions
4425
4450
// circle
@@ -4435,13 +4460,17 @@ void TestQgsGeometry::regularPolygon()
4435
4460
4436
4461
QgsRegularPolygon rp10 = QgsRegularPolygon ( QgsPoint ( 0 , 0 ), QgsPoint ( 0 , 4 ), 4 );
4437
4462
QList<QgsTriangle> rp10_tri = rp10.triangulate ();
4438
- QCOMPARE ( rp10_tri.length (), ( int ) rp10.numberSides () );
4463
+ QCOMPARE ( rp10_tri.length (), static_cast < int >( rp10.numberSides () ) );
4439
4464
QVERIFY ( rp10_tri.at ( 0 ) == QgsTriangle ( QgsPoint ( 0 , 0 ), QgsPoint ( 0 , 4 ), rp10.center () ) );
4440
4465
QVERIFY ( rp10_tri.at ( 1 ) == QgsTriangle ( QgsPoint ( 0 , 4 ), QgsPoint ( 4 , 4 ), rp10.center () ) );
4441
4466
QVERIFY ( rp10_tri.at ( 2 ) == QgsTriangle ( QgsPoint ( 4 , 4 ), QgsPoint ( 4 , 0 ), rp10.center () ) );
4442
4467
QVERIFY ( rp10_tri.at ( 3 ) == QgsTriangle ( QgsPoint ( 4 , 0 ), QgsPoint ( 0 , 0 ), rp10.center () ) );
4443
4468
4469
+ QVERIFY ( QgsRegularPolygon ().triangulate ().isEmpty () );
4470
+
4444
4471
// polygon
4472
+ QVERIFY ( QgsRegularPolygon ().toPolygon ()->isEmpty () );
4473
+
4445
4474
QgsPointSequence ptsPol;
4446
4475
std::unique_ptr< QgsPolygonV2 > pol ( new QgsPolygonV2 () );
4447
4476
pol.reset ( rp10.toPolygon () );
@@ -4457,6 +4486,7 @@ void TestQgsGeometry::regularPolygon()
4457
4486
QVERIFY ( ptsPol.at ( 4 ) == QgsPoint ( 0 , 0 ) );
4458
4487
ptsPol.pop_back ();
4459
4488
4489
+ QVERIFY ( QgsRegularPolygon ( QgsPoint (), QgsPoint ( 0 , 5 ), 1 , QgsRegularPolygon::InscribedCircle ).toLineString ()->isEmpty () );
4460
4490
std::unique_ptr< QgsLineString > l ( new QgsLineString () );
4461
4491
l.reset ( rp10.toLineString () );
4462
4492
QCOMPARE ( l->numPoints (), 4 );
0 commit comments