26
26
// qgis includes...
27
27
#include < qgsapplication.h>
28
28
#include < qgsgeometry.h>
29
+ #include < qgspoint.h>
29
30
30
31
/* * \ingroup UnitTests
31
32
* This is a unit test for the different geometry operations on vector features.
@@ -41,6 +42,7 @@ class TestQgsGeometry: public QObject
41
42
void cleanup ();// will be called after every testfunction.
42
43
43
44
void intersectionCheck ();
45
+ void unionCheck ();
44
46
private:
45
47
QgsPoint mPoint1 ; /* +1 +A */
46
48
QgsPoint mPoint2 ; /* / \ / \ */
@@ -143,6 +145,24 @@ void TestQgsGeometry::intersectionCheck()
143
145
QVERIFY ( !mpPolygonGeometryA->intersects (mpPolygonGeometryC));
144
146
}
145
147
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
+ }
146
166
147
167
QTEST_MAIN (TestQgsGeometry)
148
168
#include " moc_testqgsgeometry.cxx"
0 commit comments