@@ -51,6 +51,18 @@ class TestQgsMapToPixelGeometrySimplifier : public QObject
51
51
public:
52
52
TestQgsMapToPixelGeometrySimplifier ();
53
53
54
+ private:
55
+ // Release return with delete []
56
+ unsigned char *
57
+ hex2bytes ( const char *hex, int *size )
58
+ {
59
+ QByteArray ba = QByteArray::fromHex ( hex );
60
+ unsigned char *out = new unsigned char [ba.size ()];
61
+ memcpy ( out, ba.data (), ba.size () );
62
+ *size = ba.size ();
63
+ return out;
64
+ }
65
+
54
66
private slots:
55
67
void initTestCase ();// will be called before the first testfunction is executed.
56
68
void cleanupTestCase ();// will be called after the last testfunction was executed.
@@ -60,7 +72,7 @@ class TestQgsMapToPixelGeometrySimplifier : public QObject
60
72
void testDefaultGeometry ();
61
73
void testLine1 ();
62
74
void testIsGeneralizableByMapBoundingBox ();
63
- void testMismatchWKB ();
75
+ void testWkbDimensionMismatch ();
64
76
65
77
};
66
78
@@ -147,9 +159,26 @@ TestQgsMapToPixelGeometrySimplifier::testIsGeneralizableByMapBoundingBox()
147
159
QVERIFY ( ! ret );
148
160
}
149
161
150
- void TestQgsMapToPixelGeometrySimplifier::testMismatchWKB ()
162
+ void TestQgsMapToPixelGeometrySimplifier::testWkbDimensionMismatch ()
151
163
{
152
- // TODO see http://hub.qgis.org/issues/12416
164
+ // 2D multilinestring containing 2 3DZ linestrings
165
+ // See http://hub.qgis.org/issues/12416
166
+ // NOTE: the first line needs to be 5 vertices or more, or
167
+ // simplification won't even be attempted
168
+ const char *hexwkb = " 010500000002000000010200008005000000000000000000000000000000000000000000000000000000000000000000F03F000000000000F03F00000000000000000000000000000040000000000000000000000000000000000000000000000840000000000000F03F0000000000000000000000000000244000000000000000008DEDB5A0F7C6B0BE010200008002000000000000000000000000000000000000000000000000000000000000000000000000000000000000008DEDB5A0F7C6B03E" ;
169
+ int size;
170
+ unsigned char *wkb = hex2bytes ( hexwkb, &size );
171
+ QgsGeometry g12416;
172
+ // NOTE: wkb onwership transferred to QgsGeometry
173
+ g12416.fromWkb ( wkb, size );
174
+ QString wkt = g12416.exportToWkt ();
175
+ QCOMPARE ( wkt, QString ( " MultiLineString ((0 0 0, 1 1 0, 2 0 0, 3 1 0, 10 0 -0.000001),(0 0 0, 0 0 0.000001))" ) );
176
+
177
+ int fl = QgsMapToPixelSimplifier::SimplifyGeometry;
178
+ int ret = QgsMapToPixelSimplifier::simplifyGeometry ( &g12416, fl, 20.0 );
179
+ // NOTE: currently false due to thrown exception, but fixing the
180
+ // simplification code might actually give a success
181
+ QVERIFY ( ! ret );
153
182
}
154
183
155
184
QTEST_MAIN ( TestQgsMapToPixelGeometrySimplifier )
0 commit comments