Skip to content
Permalink
Browse files
fix QgsGeometry::moveVertex on polygon (fixes #9442)
  • Loading branch information
jef-n committed Jan 30, 2014
1 parent db277ce commit 70c594984f71f997fe80335e4eac45f3f488f30d
Showing with 25 additions and 4 deletions.
  1. +0 −4 src/core/qgsgeometry.cpp
  2. +25 −0 tests/src/python/test_qgsgeometry.py
@@ -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;
@@ -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!+

0 comments on commit 70c5949

Please sign in to comment.