@@ -751,6 +751,12 @@ def testMultipoint(self):
751
751
752
752
def testMoveVertex (self ):
753
753
multipoint = QgsGeometry .fromWkt ( "MultiPoint ((5 0),(0 0),(0 4),(5 4),(5 1),(1 1),(1 3),(4 3),(4 2),(2 2))" )
754
+
755
+ #try moving invalid vertices
756
+ assert not multipoint .moveVertex ( 9 , 9 , - 1 ), "move vertex succeeded when it should have failed"
757
+ assert not multipoint .moveVertex ( 9 , 9 , 10 ), "move vertex succeeded when it should have failed"
758
+ assert not multipoint .moveVertex ( 9 , 9 , 11 ), "move vertex succeeded when it should have failed"
759
+
754
760
for i in range (0 ,10 ):
755
761
assert multipoint .moveVertex ( i + 1 , - 1 - i , i ), "move vertex %d failed" % i
756
762
expwkt = "MultiPoint ((1 -1),(2 -2),(3 -3),(4 -4),(5 -5),(6 -6),(7 -7),(8 -8),(9 -9),(10 -10))"
@@ -767,6 +773,12 @@ def testMoveVertex(self):
767
773
# |
768
774
# 1-+-+-+-+-0 !
769
775
polyline = QgsGeometry .fromWkt ( "LineString (5 0, 0 0, 0 4, 5 4, 5 1, 1 1, 1 3, 4 3, 4 2, 2 2)" )
776
+
777
+ #try moving invalid vertices
778
+ assert not polyline .moveVertex ( 9 , 9 , - 1 ), "move vertex succeeded when it should have failed"
779
+ assert not polyline .moveVertex ( 9 , 9 , 10 ), "move vertex succeeded when it should have failed"
780
+ assert not polyline .moveVertex ( 9 , 9 , 11 ), "move vertex succeeded when it should have failed"
781
+
770
782
assert polyline .moveVertex ( 5.5 , 4.5 , 3 ), "move vertex failed"
771
783
expwkt = "LineString (5 0, 0 0, 0 4, 5.5 4.5, 5 1, 1 1, 1 3, 4 3, 4 2, 2 2)"
772
784
wkt = polyline .exportToWkt ()
@@ -781,6 +793,7 @@ def testMoveVertex(self):
781
793
782
794
assert not polygon .moveVertex ( 3 , 4 , - 10 ), "move vertex unexpectedly succeeded"
783
795
assert not polygon .moveVertex ( 3 , 4 , 7 ), "move vertex unexpectedly succeeded"
796
+ assert not polygon .moveVertex ( 3 , 4 , 8 ), "move vertex unexpectedly succeeded"
784
797
785
798
assert polygon .moveVertex ( 1 , 2 , 0 ), "move vertex failed"
786
799
expwkt = "Polygon ((1 2, 1 0, 1 1, 2 1, 2 2, 0 2, 1 2))"
@@ -803,6 +816,11 @@ def testMoveVertex(self):
803
816
# | | | |
804
817
# 0-1 7-8
805
818
polygon = QgsGeometry .fromWkt ( "MultiPolygon (((0 0, 1 0, 1 1, 2 1, 2 2, 0 2, 0 0)),((4 0, 5 0, 5 2, 3 2, 3 1, 4 1, 4 0)))" )
819
+
820
+ assert not polygon .moveVertex ( 3 , 4 , - 10 ), "move vertex unexpectedly succeeded"
821
+ assert not polygon .moveVertex ( 3 , 4 , 14 ), "move vertex unexpectedly succeeded"
822
+ assert not polygon .moveVertex ( 3 , 4 , 15 ), "move vertex unexpectedly succeeded"
823
+
806
824
assert polygon .moveVertex ( 6 , 2 , 9 ), "move vertex failed"
807
825
expwkt = "MultiPolygon (((0 0, 1 0, 1 1, 2 1, 2 2, 0 2, 0 0)),((4 0, 5 0, 6 2, 3 2, 3 1, 4 1, 4 0)))"
808
826
wkt = polygon .exportToWkt ()
0 commit comments