Skip to content

Commit be71066

Browse files
committed
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
1 parent 30d7423 commit be71066

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 "qgscompoundcurvev2.h"
3031
#include <qgsgeometry.h>
3132
#include "qgsgeometryutils.h"
3233
#include <qgspoint.h>
@@ -60,6 +61,7 @@ class TestQgsGeometry : public QObject
6061
void isEmpty();
6162
void pointV2(); //test QgsPointV2
6263
void lineStringV2(); //test QgsLineStringV2
64+
void compoundCurveV2(); //test QgsCompoundCurveV2
6365
void polygonV2(); //test QgsPolygonV2
6466

6567
void fromQgsPoint();
@@ -2140,6 +2142,31 @@ void TestQgsGeometry::lineStringV2()
21402142
QVERIFY( l39.numPoints() == 0 );
21412143
}
21422144

2145+
void TestQgsGeometry::compoundCurveV2()
2146+
{
2147+
//test that area of a compound curve ring is equal to a closed linestring with the same vertices
2148+
QgsCompoundCurveV2 cc;
2149+
QgsLineStringV2* l1 = new QgsLineStringV2();
2150+
l1->setPoints( QgsPointSequenceV2() << QgsPointV2( 1, 1 ) << QgsPointV2( 0, 2 ) );
2151+
cc.addCurve( l1 );
2152+
QgsLineStringV2* l2 = new QgsLineStringV2();
2153+
l2->setPoints( QgsPointSequenceV2() << QgsPointV2( 0, 2 ) << QgsPointV2( -1, 0 ) << QgsPointV2( 0, -1 ) );
2154+
cc.addCurve( l2 );
2155+
QgsLineStringV2* l3 = new QgsLineStringV2();
2156+
l3->setPoints( QgsPointSequenceV2() << QgsPointV2( 0, -1 ) << QgsPointV2( 1, 1 ) );
2157+
cc.addCurve( l3 );
2158+
2159+
double ccArea = 0.0;
2160+
cc.sumUpArea( ccArea );
2161+
2162+
QgsLineStringV2 ls;
2163+
ls.setPoints( QgsPointSequenceV2() << QgsPointV2( 1, 1 ) << QgsPointV2( 0, 2 ) << QgsPointV2( -1, 0 ) << QgsPointV2( 0, -1 )
2164+
<< QgsPointV2( 1, 1 ) );
2165+
double lsArea = 0.0;
2166+
ls.sumUpArea( lsArea );
2167+
QVERIFY( qgsDoubleNear( ccArea, lsArea ) );
2168+
}
2169+
21432170
void TestQgsGeometry::polygonV2()
21442171
{
21452172
//test constructor

0 commit comments

Comments
 (0)