Skip to content
Permalink
Browse files

Add unit test that makes sure that the area of a closed compound curv…

…e ring is the same as a closed linestring with the same number of vertices
  • Loading branch information
mhugent committed Jan 4, 2017
1 parent 30d7423 commit be71066ff983347bba94845d66a319f65931b457
Showing with 27 additions and 0 deletions.
  1. +27 −0 tests/src/core/testqgsgeometry.cpp
@@ -27,6 +27,7 @@

//qgis includes...
#include <qgsapplication.h>
#include "qgscompoundcurvev2.h"
#include <qgsgeometry.h>
#include "qgsgeometryutils.h"
#include <qgspoint.h>
@@ -60,6 +61,7 @@ class TestQgsGeometry : public QObject
void isEmpty();
void pointV2(); //test QgsPointV2
void lineStringV2(); //test QgsLineStringV2
void compoundCurveV2(); //test QgsCompoundCurveV2
void polygonV2(); //test QgsPolygonV2

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

void TestQgsGeometry::compoundCurveV2()
{
//test that area of a compound curve ring is equal to a closed linestring with the same vertices
QgsCompoundCurveV2 cc;
QgsLineStringV2* l1 = new QgsLineStringV2();
l1->setPoints( QgsPointSequenceV2() << QgsPointV2( 1, 1 ) << QgsPointV2( 0, 2 ) );
cc.addCurve( l1 );
QgsLineStringV2* l2 = new QgsLineStringV2();
l2->setPoints( QgsPointSequenceV2() << QgsPointV2( 0, 2 ) << QgsPointV2( -1, 0 ) << QgsPointV2( 0, -1 ) );
cc.addCurve( l2 );
QgsLineStringV2* l3 = new QgsLineStringV2();
l3->setPoints( QgsPointSequenceV2() << QgsPointV2( 0, -1 ) << QgsPointV2( 1, 1 ) );
cc.addCurve( l3 );

double ccArea = 0.0;
cc.sumUpArea( ccArea );

QgsLineStringV2 ls;
ls.setPoints( QgsPointSequenceV2() << QgsPointV2( 1, 1 ) << QgsPointV2( 0, 2 ) << QgsPointV2( -1, 0 ) << QgsPointV2( 0, -1 )
<< QgsPointV2( 1, 1 ) );
double lsArea = 0.0;
ls.sumUpArea( lsArea );
QVERIFY( qgsDoubleNear( ccArea, lsArea ) );
}

void TestQgsGeometry::polygonV2()
{
//test constructor

0 comments on commit be71066

Please sign in to comment.
You can’t perform that action at this time.