Skip to content

Commit 70c5949

Browse files
committed
fix QgsGeometry::moveVertex on polygon (fixes #9442)
1 parent db277ce commit 70c5949

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

src/core/qgsgeometry.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1323,7 +1323,6 @@ bool QgsGeometry::moveVertex( double x, double y, int atVertex )
13231323

13241324
for ( int linenr = 0, pointIndex = 0; linenr < nLines; ++linenr )
13251325
{
1326-
wkbPtr += 1 + sizeof( int );
13271326
if ( moveVertex( wkbPtr, x, y, atVertex, hasZValue, pointIndex, true ) )
13281327
{
13291328
mDirtyGeos = true;
@@ -1676,9 +1675,7 @@ bool QgsGeometry::insertVertex( double x, double y, int beforeVertex )
16761675
dstPtr << nRings;
16771676

16781677
for ( int ringnr = 0, pointIndex = 0; ringnr < nRings; ++ringnr )
1679-
{
16801678
inserted |= insertVertex( srcPtr, dstPtr, beforeVertex, x, y, hasZValue, pointIndex, true );
1681-
}
16821679

16831680
break;
16841681
}
@@ -2665,7 +2662,6 @@ int QgsGeometry::translate( double dx, double dy )
26652662
{
26662663
int nRings;
26672664
wkbPtr >> nRings;
2668-
26692665
for ( int index = 0; index < nRings; ++index )
26702666
{
26712667
int nPoints;

tests/src/python/test_qgsgeometry.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -821,6 +821,31 @@ def testMoveVertex(self):
821821
wkt = polyline.exportToWkt()
822822
assert compareWkt( expwkt, wkt ), "Expected:\n%s\nGot:\n%s\n" % (expwkt, wkt )
823823

824+
# 5-+-4
825+
# | |
826+
# 6 2-3
827+
# | |
828+
# 0-1
829+
polygon = QgsGeometry.fromWkt( "POLYGON((0 0,1 0,1 1,2 1,2 2,0 2,0 0))" )
830+
831+
assert not polygon.moveVertex( 3, 4, -10 ), "move vertex unexpectedly succeeded"
832+
assert not polygon.moveVertex( 3, 4, 7 ), "move vertex unexpectedly succeeded"
833+
834+
assert polygon.moveVertex( 1, 2, 0 ), "move vertex failed"
835+
expwkt = "POLYGON((1 2,1 0,1 1,2 1,2 2,0 2,1 2))"
836+
wkt = polygon.exportToWkt()
837+
assert compareWkt( expwkt, wkt ), "Expected:\n%s\nGot:\n%s\n" % (expwkt, wkt )
838+
839+
assert polygon.moveVertex( 3, 4, 3 ), "move vertex failed"
840+
expwkt = "POLYGON((1 2,1 0,1 1,3 4,2 2,0 2,1 2))"
841+
wkt = polygon.exportToWkt()
842+
assert compareWkt( expwkt, wkt ), "Expected:\n%s\nGot:\n%s\n" % (expwkt, wkt )
843+
844+
assert polygon.moveVertex( 2, 3, 6 ), "move vertex failed"
845+
expwkt = "POLYGON((2 3,1 0,1 1,3 4,2 2,0 2,2 3))"
846+
wkt = polygon.exportToWkt()
847+
assert compareWkt( expwkt, wkt ), "Expected:\n%s\nGot:\n%s\n" % (expwkt, wkt )
848+
824849
# 5-+-4 0-+-9
825850
# | | | |
826851
# 6 2-3 1-2!+

0 commit comments

Comments
 (0)