Skip to content
Permalink
Browse files

Union test

git-svn-id: http://svn.osgeo.org/qgis/trunk@8181 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux
timlinux committed Feb 26, 2008
1 parent ad919f2 commit e938c883b0794e0fdd6057b5d543b11726283696
Showing with 20 additions and 0 deletions.
  1. +20 −0 tests/src/core/testqgsgeometry.cpp
@@ -26,6 +26,7 @@
//qgis includes...
#include <qgsapplication.h>
#include <qgsgeometry.h>
#include <qgspoint.h>

/** \ingroup UnitTests
* This is a unit test for the different geometry operations on vector features.
@@ -41,6 +42,7 @@ class TestQgsGeometry: public QObject
void cleanup();// will be called after every testfunction.

void intersectionCheck();
void unionCheck();
private:
QgsPoint mPoint1; /* +1 +A */
QgsPoint mPoint2; /* / \ / \ */
@@ -143,6 +145,24 @@ void TestQgsGeometry::intersectionCheck()
QVERIFY ( !mpPolygonGeometryA->intersects(mpPolygonGeometryC));
}

void TestQgsGeometry::unionCheck()
{

// should be no union as A does not intersect C
QgsGeometry * mypUnionGeometry = mpPolygonGeometryA->Union(mpPolygonGeometryC);
QgsPolyline myPolyline = mypUnionGeometry->asPolyline();
QVERIFY (myPolyline.size() == 0); //check that the union failed properly
// should be a union as A intersect B
mypUnionGeometry = mpPolygonGeometryA->Union(mpPolygonGeometryB);
myPolyline = mypUnionGeometry->asPolyline();
QVERIFY (myPolyline.size() > 0); //check that the union created a feature
for (int i = 0; i < myPolyline.size(); i++)
{
QgsPoint myPoint = myPolyline.at(i);
qDebug(myPoint.stringRep());
}
delete mypUnionGeometry;
}

QTEST_MAIN(TestQgsGeometry)
#include "moc_testqgsgeometry.cxx"

0 comments on commit e938c88

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