Skip to content

Commit 7107c16

Browse files
mhugentnyalldawson
authored andcommitted
Add unit test that makes sure that the area of a closed compound curve ring is the same as a closed linestring with the same number of vertices
(forward port from be71066)
1 parent abc0919 commit 7107c16

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

tests/src/core/testqgsgeometry.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
//qgis includes...
2929
#include <qgsapplication.h>
30+
#include "qgscompoundcurve.h"
3031
#include <qgsgeometry.h>
3132
#include "qgsgeometryutils.h"
3233
#include <qgspoint.h>
@@ -69,6 +70,7 @@ class TestQgsGeometry : public QObject
6970
void point(); //test QgsPointV2
7071
void lineString(); //test QgsLineString
7172
void polygon(); //test QgsPolygonV2
73+
void compoundCurve(); //test QgsCompoundCurve
7274
void multiPoint();
7375
void multiLineString();
7476
void multiPolygon();
@@ -3092,6 +3094,31 @@ void TestQgsGeometry::polygon()
30923094

30933095
}
30943096

3097+
void TestQgsGeometry::compoundCurve()
3098+
{
3099+
//test that area of a compound curve ring is equal to a closed linestring with the same vertices
3100+
QgsCompoundCurve cc;
3101+
QgsLineString* l1 = new QgsLineString();
3102+
l1->setPoints( QgsPointSequence() << QgsPointV2( 1, 1 ) << QgsPointV2( 0, 2 ) );
3103+
cc.addCurve( l1 );
3104+
QgsLineString* l2 = new QgsLineString();
3105+
l2->setPoints( QgsPointSequence() << QgsPointV2( 0, 2 ) << QgsPointV2( -1, 0 ) << QgsPointV2( 0, -1 ) );
3106+
cc.addCurve( l2 );
3107+
QgsLineString* l3 = new QgsLineString();
3108+
l3->setPoints( QgsPointSequence() << QgsPointV2( 0, -1 ) << QgsPointV2( 1, 1 ) );
3109+
cc.addCurve( l3 );
3110+
3111+
double ccArea = 0.0;
3112+
cc.sumUpArea( ccArea );
3113+
3114+
QgsLineString ls;
3115+
ls.setPoints( QgsPointSequence() << QgsPointV2( 1, 1 ) << QgsPointV2( 0, 2 ) << QgsPointV2( -1, 0 ) << QgsPointV2( 0, -1 )
3116+
<< QgsPointV2( 1, 1 ) );
3117+
double lsArea = 0.0;
3118+
ls.sumUpArea( lsArea );
3119+
QVERIFY( qgsDoubleNear( ccArea, lsArea ) );
3120+
}
3121+
30953122
void TestQgsGeometry::multiPoint()
30963123
{
30973124
//boundary

0 commit comments

Comments
 (0)