Skip to content

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
 

‎tests/src/core/testqgsgeometry.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
//qgis includes...
2727
#include <qgsapplication.h>
2828
#include <qgsgeometry.h>
29+
#include <qgspoint.h>
2930

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

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

148+
void TestQgsGeometry::unionCheck()
149+
{
150+
151+
// should be no union as A does not intersect C
152+
QgsGeometry * mypUnionGeometry = mpPolygonGeometryA->Union(mpPolygonGeometryC);
153+
QgsPolyline myPolyline = mypUnionGeometry->asPolyline();
154+
QVERIFY (myPolyline.size() == 0); //check that the union failed properly
155+
// should be a union as A intersect B
156+
mypUnionGeometry = mpPolygonGeometryA->Union(mpPolygonGeometryB);
157+
myPolyline = mypUnionGeometry->asPolyline();
158+
QVERIFY (myPolyline.size() > 0); //check that the union created a feature
159+
for (int i = 0; i < myPolyline.size(); i++)
160+
{
161+
QgsPoint myPoint = myPolyline.at(i);
162+
qDebug(myPoint.stringRep());
163+
}
164+
delete mypUnionGeometry;
165+
}
146166

147167
QTEST_MAIN(TestQgsGeometry)
148168
#include "moc_testqgsgeometry.cxx"

0 commit comments

Comments
 (0)
Please sign in to comment.