Skip to content

Commit

Permalink
fix QgsGeometry::moveVertex on polygon (fixes #9442)
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Jan 30, 2014
1 parent db277ce commit 70c5949
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
4 changes: 0 additions & 4 deletions src/core/qgsgeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -2665,7 +2662,6 @@ int QgsGeometry::translate( double dx, double dy )
{
int nRings;
wkbPtr >> nRings;

for ( int index = 0; index < nRings; ++index )
{
int nPoints;
Expand Down
25 changes: 25 additions & 0 deletions tests/src/python/test_qgsgeometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,31 @@ def testMoveVertex(self):
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!+
Expand Down

0 comments on commit 70c5949

Please sign in to comment.