|
27 | 27 |
|
28 | 28 | //qgis includes... |
29 | 29 | #include <qgsapplication.h> |
| 30 | +#include "qgscompoundcurvev2.h" |
30 | 31 | #include <qgsgeometry.h> |
31 | 32 | #include "qgsgeometryutils.h" |
32 | 33 | #include <qgspoint.h> |
@@ -60,6 +61,7 @@ class TestQgsGeometry : public QObject |
60 | 61 | void isEmpty(); |
61 | 62 | void pointV2(); //test QgsPointV2 |
62 | 63 | void lineStringV2(); //test QgsLineStringV2 |
| 64 | + void compoundCurveV2(); //test QgsCompoundCurveV2 |
63 | 65 | void polygonV2(); //test QgsPolygonV2 |
64 | 66 |
|
65 | 67 | void fromQgsPoint(); |
@@ -2140,6 +2142,31 @@ void TestQgsGeometry::lineStringV2() |
2140 | 2142 | QVERIFY( l39.numPoints() == 0 ); |
2141 | 2143 | } |
2142 | 2144 |
|
| 2145 | +void TestQgsGeometry::compoundCurveV2() |
| 2146 | +{ |
| 2147 | + //test that area of a compound curve ring is equal to a closed linestring with the same vertices |
| 2148 | + QgsCompoundCurveV2 cc; |
| 2149 | + QgsLineStringV2* l1 = new QgsLineStringV2(); |
| 2150 | + l1->setPoints( QgsPointSequenceV2() << QgsPointV2( 1, 1 ) << QgsPointV2( 0, 2 ) ); |
| 2151 | + cc.addCurve( l1 ); |
| 2152 | + QgsLineStringV2* l2 = new QgsLineStringV2(); |
| 2153 | + l2->setPoints( QgsPointSequenceV2() << QgsPointV2( 0, 2 ) << QgsPointV2( -1, 0 ) << QgsPointV2( 0, -1 ) ); |
| 2154 | + cc.addCurve( l2 ); |
| 2155 | + QgsLineStringV2* l3 = new QgsLineStringV2(); |
| 2156 | + l3->setPoints( QgsPointSequenceV2() << QgsPointV2( 0, -1 ) << QgsPointV2( 1, 1 ) ); |
| 2157 | + cc.addCurve( l3 ); |
| 2158 | + |
| 2159 | + double ccArea = 0.0; |
| 2160 | + cc.sumUpArea( ccArea ); |
| 2161 | + |
| 2162 | + QgsLineStringV2 ls; |
| 2163 | + ls.setPoints( QgsPointSequenceV2() << QgsPointV2( 1, 1 ) << QgsPointV2( 0, 2 ) << QgsPointV2( -1, 0 ) << QgsPointV2( 0, -1 ) |
| 2164 | + << QgsPointV2( 1, 1 ) ); |
| 2165 | + double lsArea = 0.0; |
| 2166 | + ls.sumUpArea( lsArea ); |
| 2167 | + QVERIFY( qgsDoubleNear( ccArea, lsArea ) ); |
| 2168 | +} |
| 2169 | + |
2143 | 2170 | void TestQgsGeometry::polygonV2() |
2144 | 2171 | { |
2145 | 2172 | //test constructor |
|
0 commit comments