fix QgsGeometry::asMultiPoint() (followup 6bbd17c2; fixes #9423)

This commit is contained in:
Juergen E. Fischer 2014-01-25 10:28:17 +01:00
parent 9439eb8663
commit 781e34a5bc
2 changed files with 11 additions and 1 deletions

View File

@ -5367,7 +5367,6 @@ QgsMultiPoint QgsGeometry::asMultiPoint() const
QgsMultiPoint points( nPoints );
for ( int i = 0; i < nPoints; i++ )
{
wkbPtr += 1 + sizeof( int );
points[i] = asPoint( wkbPtr, hasZValue );
}

View File

@ -752,6 +752,17 @@ class TestQgsGeometry(TestCase):
if not TestQgsGeometry.wkbPtr:
return
# #9423
points = [ QgsPoint(10, 30), QgsPoint(40, 20), QgsPoint(30,10), QgsPoint(20,10) ]
wkt = "MULTIPOINT (10 30, 40 20, 30 10, 20 10)"
multipoint = QgsGeometry.fromWkt(wkt)
assert multipoint.isMultipart(), "Expected MULTIPOINT to be multipart"
assert multipoint.wkbType() == QGis.WKBMultiPoint, "Expected wkbType to be WKBMultipoint"
i = 0
for p in multipoint.asMultiPoint():
assert p == points[i], "Expected %s at %d, got %s" % (points[i].toString(), i, p.toString())
i+=1
multipoint = QgsGeometry.fromWkt( "MULTIPOINT(5 5)" )
assert multipoint.vertexAt( 0 ) == QgsPoint(5,5), "MULTIPOINT fromWkt failed"