fix QgsGeometry::moveVertex on polygon (fixes #9442)

This commit is contained in:
Juergen E. Fischer 2014-01-30 19:01:13 +01:00
parent db277ce74c
commit 70c594984f
2 changed files with 25 additions and 4 deletions

View File

@ -1323,7 +1323,6 @@ bool QgsGeometry::moveVertex( double x, double y, int atVertex )
for ( int linenr = 0, pointIndex = 0; linenr < nLines; ++linenr )
{
wkbPtr += 1 + sizeof( int );
if ( moveVertex( wkbPtr, x, y, atVertex, hasZValue, pointIndex, true ) )
{
mDirtyGeos = true;
@ -1676,9 +1675,7 @@ bool QgsGeometry::insertVertex( double x, double y, int beforeVertex )
dstPtr << nRings;
for ( int ringnr = 0, pointIndex = 0; ringnr < nRings; ++ringnr )
{
inserted |= insertVertex( srcPtr, dstPtr, beforeVertex, x, y, hasZValue, pointIndex, true );
}
break;
}
@ -2665,7 +2662,6 @@ int QgsGeometry::translate( double dx, double dy )
{
int nRings;
wkbPtr >> nRings;
for ( int index = 0; index < nRings; ++index )
{
int nPoints;

View File

@ -821,6 +821,31 @@ class TestQgsGeometry(TestCase):
wkt = polyline.exportToWkt()
assert compareWkt( expwkt, wkt ), "Expected:\n%s\nGot:\n%s\n" % (expwkt, wkt )
# 5-+-4
# | |
# 6 2-3
# | |
# 0-1
polygon = QgsGeometry.fromWkt( "POLYGON((0 0,1 0,1 1,2 1,2 2,0 2,0 0))" )
assert not polygon.moveVertex( 3, 4, -10 ), "move vertex unexpectedly succeeded"
assert not polygon.moveVertex( 3, 4, 7 ), "move vertex unexpectedly succeeded"
assert polygon.moveVertex( 1, 2, 0 ), "move vertex failed"
expwkt = "POLYGON((1 2,1 0,1 1,2 1,2 2,0 2,1 2))"
wkt = polygon.exportToWkt()
assert compareWkt( expwkt, wkt ), "Expected:\n%s\nGot:\n%s\n" % (expwkt, wkt )
assert polygon.moveVertex( 3, 4, 3 ), "move vertex failed"
expwkt = "POLYGON((1 2,1 0,1 1,3 4,2 2,0 2,1 2))"
wkt = polygon.exportToWkt()
assert compareWkt( expwkt, wkt ), "Expected:\n%s\nGot:\n%s\n" % (expwkt, wkt )
assert polygon.moveVertex( 2, 3, 6 ), "move vertex failed"
expwkt = "POLYGON((2 3,1 0,1 1,3 4,2 2,0 2,2 3))"
wkt = polygon.exportToWkt()
assert compareWkt( expwkt, wkt ), "Expected:\n%s\nGot:\n%s\n" % (expwkt, wkt )
# 5-+-4 0-+-9
# | | | |
# 6 2-3 1-2!+