Navigation Menu

Skip to content

Commit

Permalink
Union test
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@8181 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed Feb 26, 2008
1 parent cce210c commit 63da384
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/src/core/testqgsgeometry.cpp
Expand Up @@ -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.
Expand All @@ -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; /* / \ / \ */
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 63da384

Please sign in to comment.