@@ -1423,14 +1423,14 @@ def testAddPart(self):
1423
1423
]
1424
1424
1425
1425
polyline = QgsGeometry .fromPolyline (points [0 ])
1426
- self .assertEqual (polyline .addPoints (points [1 ][0 :1 ]), 2 , "addPoints with one point line unexpectedly succeeded." )
1427
- self .assertEqual (polyline .addPoints (points [1 ][0 :2 ]), 0 , "addPoints with two point line failed." )
1426
+ self .assertEqual (polyline .addPoints (points [1 ][0 :1 ]), QgsGeometry . InvalidInput , "addPoints with one point line unexpectedly succeeded." )
1427
+ self .assertEqual (polyline .addPoints (points [1 ][0 :2 ]), QgsGeometry . Success , "addPoints with two point line failed." )
1428
1428
expwkt = "MultiLineString ((0 0, 1 0, 1 1, 2 1, 2 0), (3 0, 3 1))"
1429
1429
wkt = polyline .exportToWkt ()
1430
1430
assert compareWkt (expwkt , wkt ), "Expected:\n %s\n Got:\n %s\n " % (expwkt , wkt )
1431
1431
1432
1432
polyline = QgsGeometry .fromPolyline (points [0 ])
1433
- self .assertEqual (polyline .addPoints (points [1 ]), 0 , "addPoints with %d point line failed." % len (points [1 ]))
1433
+ self .assertEqual (polyline .addPoints (points [1 ]), QgsGeometry . Success , "addPoints with %d point line failed." % len (points [1 ]))
1434
1434
expwkt = "MultiLineString ((0 0, 1 0, 1 1, 2 1, 2 0), (3 0, 3 1, 5 1, 5 0, 6 0))"
1435
1435
wkt = polyline .exportToWkt ()
1436
1436
assert compareWkt (expwkt , wkt ), "Expected:\n %s\n Got:\n %s\n " % (expwkt , wkt )
@@ -1439,7 +1439,7 @@ def testAddPart(self):
1439
1439
polyline = QgsGeometry .fromPolyline (points [0 ])
1440
1440
polyline .geometry ().addZValue (4.0 )
1441
1441
points2 = [QgsPoint (p [0 ], p [1 ], 3.0 , wkbType = QgsWkbTypes .PointZ ) for p in points [1 ]]
1442
- self .assertEqual (polyline .addPointsV2 (points2 ), 0 )
1442
+ self .assertEqual (polyline .addPointsV2 (points2 ), QgsGeometry . Success )
1443
1443
expwkt = "MultiLineStringZ ((0 0 4, 1 0 4, 1 1 4, 2 1 4, 2 0 4),(3 0 3, 3 1 3, 5 1 3, 5 0 3, 6 0 3))"
1444
1444
wkt = polyline .exportToWkt ()
1445
1445
assert compareWkt (expwkt , wkt ), "Expected:\n %s\n Got:\n %s\n " % (expwkt , wkt )
@@ -1456,34 +1456,34 @@ def testAddPart(self):
1456
1456
1457
1457
polygon = QgsGeometry .fromPolygon (points [0 ])
1458
1458
1459
- self .assertEqual (polygon .addPoints (points [1 ][0 ][0 :1 ]), 2 , "addPoints with one point ring unexpectedly succeeded." )
1460
- self .assertEqual (polygon .addPoints (points [1 ][0 ][0 :2 ]), 2 , "addPoints with two point ring unexpectedly succeeded." )
1461
- self .assertEqual (polygon .addPoints (points [1 ][0 ][0 :3 ]), 2 , "addPoints with unclosed three point ring unexpectedly succeeded." )
1462
- self .assertEqual (polygon .addPoints ([QgsPointXY (4 , 0 ), QgsPointXY (5 , 0 ), QgsPointXY (4 , 0 )]), 2 , "addPoints with 'closed' three point ring unexpectedly succeeded." )
1459
+ self .assertEqual (polygon .addPoints (points [1 ][0 ][0 :1 ]), QgsGeometry . InvalidInput , "addPoints with one point ring unexpectedly succeeded." )
1460
+ self .assertEqual (polygon .addPoints (points [1 ][0 ][0 :2 ]), QgsGeometry . InvalidInput , "addPoints with two point ring unexpectedly succeeded." )
1461
+ self .assertEqual (polygon .addPoints (points [1 ][0 ][0 :3 ]), QgsGeometry . InvalidInput , "addPoints with unclosed three point ring unexpectedly succeeded." )
1462
+ self .assertEqual (polygon .addPoints ([QgsPointXY (4 , 0 ), QgsPointXY (5 , 0 ), QgsPointXY (4 , 0 )]), QgsGeometry . InvalidInput , "addPoints with 'closed' three point ring unexpectedly succeeded." )
1463
1463
1464
- self .assertEqual (polygon .addPoints (points [1 ][0 ]), 0 , "addPoints failed" )
1464
+ self .assertEqual (polygon .addPoints (points [1 ][0 ]), QgsGeometry . Success , "addPoints failed" )
1465
1465
expwkt = "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)))"
1466
1466
wkt = polygon .exportToWkt ()
1467
1467
assert compareWkt (expwkt , wkt ), "Expected:\n %s\n Got:\n %s\n " % (expwkt , wkt )
1468
1468
1469
1469
mp = QgsGeometry .fromMultiPolygon (points [:1 ])
1470
1470
p = QgsGeometry .fromPolygon (points [1 ])
1471
1471
1472
- self .assertEqual (mp .addPartGeometry (p ), 0 )
1472
+ self .assertEqual (mp .addPartGeometry (p ), QgsGeometry . Success )
1473
1473
wkt = mp .exportToWkt ()
1474
1474
assert compareWkt (expwkt , wkt ), "Expected:\n %s\n Got:\n %s\n " % (expwkt , wkt )
1475
1475
1476
1476
mp = QgsGeometry .fromMultiPolygon (points [:1 ])
1477
1477
mp2 = QgsGeometry .fromMultiPolygon (points [1 :])
1478
- self .assertEqual (mp .addPartGeometry (mp2 ), 0 )
1478
+ self .assertEqual (mp .addPartGeometry (mp2 ), QgsGeometry . Success )
1479
1479
wkt = mp .exportToWkt ()
1480
1480
assert compareWkt (expwkt , wkt ), "Expected:\n %s\n Got:\n %s\n " % (expwkt , wkt )
1481
1481
1482
1482
# test adding a part with Z values
1483
1483
polygon = QgsGeometry .fromPolygon (points [0 ])
1484
1484
polygon .geometry ().addZValue (4.0 )
1485
1485
points2 = [QgsPoint (pi [0 ], pi [1 ], 3.0 , wkbType = QgsWkbTypes .PointZ ) for pi in points [1 ][0 ]]
1486
- self .assertEqual (polygon .addPointsV2 (points2 ), 0 )
1486
+ self .assertEqual (polygon .addPointsV2 (points2 ), QgsGeometry . Success )
1487
1487
expwkt = "MultiPolygonZ (((0 0 4, 1 0 4, 1 1 4, 2 1 4, 2 2 4, 0 2 4, 0 0 4)),((4 0 3, 5 0 3, 5 2 3, 3 2 3, 3 1 3, 4 1 3, 4 0 3)))"
1488
1488
wkt = polygon .exportToWkt ()
1489
1489
assert compareWkt (expwkt , wkt ), "Expected:\n %s\n Got:\n %s\n " % (expwkt , wkt )
@@ -1492,38 +1492,38 @@ def testAddPart(self):
1492
1492
empty = QgsGeometry ()
1493
1493
# if not default type specified, addPart should fail
1494
1494
result = empty .addPoints ([QgsPointXY (4 , 0 )])
1495
- assert result != 0 , 'Got return code {}' .format (result )
1495
+ assert result != QgsGeometry . Success , 'Got return code {}' .format (result )
1496
1496
result = empty .addPoints ([QgsPointXY (4 , 0 )], QgsWkbTypes .PointGeometry )
1497
- self .assertEqual (result , 0 , 'Got return code {}' .format (result ))
1497
+ self .assertEqual (result , QgsGeometry . Success , 'Got return code {}' .format (result ))
1498
1498
wkt = empty .exportToWkt ()
1499
1499
expwkt = 'MultiPoint ((4 0))'
1500
1500
assert compareWkt (expwkt , wkt ), "Expected:\n %s\n Got:\n %s\n " % (expwkt , wkt )
1501
1501
result = empty .addPoints ([QgsPointXY (5 , 1 )])
1502
- self .assertEqual (result , 0 , 'Got return code {}' .format (result ))
1502
+ self .assertEqual (result , QgsGeometry . Success , 'Got return code {}' .format (result ))
1503
1503
wkt = empty .exportToWkt ()
1504
1504
expwkt = 'MultiPoint ((4 0),(5 1))'
1505
1505
assert compareWkt (expwkt , wkt ), "Expected:\n %s\n Got:\n %s\n " % (expwkt , wkt )
1506
1506
# next try with lines
1507
1507
empty = QgsGeometry ()
1508
1508
result = empty .addPoints (points [0 ][0 ], QgsWkbTypes .LineGeometry )
1509
- self .assertEqual (result , 0 , 'Got return code {}' .format (result ))
1509
+ self .assertEqual (result , QgsGeometry . Success , 'Got return code {}' .format (result ))
1510
1510
wkt = empty .exportToWkt ()
1511
1511
expwkt = 'MultiLineString ((0 0, 1 0, 1 1, 2 1, 2 2, 0 2, 0 0))'
1512
1512
assert compareWkt (expwkt , wkt ), "Expected:\n %s\n Got:\n %s\n " % (expwkt , wkt )
1513
1513
result = empty .addPoints (points [1 ][0 ])
1514
- self .assertEqual (result , 0 , 'Got return code {}' .format (result ))
1514
+ self .assertEqual (result , QgsGeometry . Success , 'Got return code {}' .format (result ))
1515
1515
wkt = empty .exportToWkt ()
1516
1516
expwkt = 'MultiLineString ((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))'
1517
1517
assert compareWkt (expwkt , wkt ), "Expected:\n %s\n Got:\n %s\n " % (expwkt , wkt )
1518
1518
# finally try with polygons
1519
1519
empty = QgsGeometry ()
1520
1520
result = empty .addPoints (points [0 ][0 ], QgsWkbTypes .PolygonGeometry )
1521
- self .assertEqual (result , 0 , 'Got return code {}' .format (result ))
1521
+ self .assertEqual (result , QgsGeometry . Success , 'Got return code {}' .format (result ))
1522
1522
wkt = empty .exportToWkt ()
1523
1523
expwkt = 'MultiPolygon (((0 0, 1 0, 1 1, 2 1, 2 2, 0 2, 0 0)))'
1524
1524
assert compareWkt (expwkt , wkt ), "Expected:\n %s\n Got:\n %s\n " % (expwkt , wkt )
1525
1525
result = empty .addPoints (points [1 ][0 ])
1526
- self .assertEqual (result , 0 , 'Got return code {}' .format (result ))
1526
+ self .assertEqual (result , QgsGeometry . Success , 'Got return code {}' .format (result ))
1527
1527
wkt = empty .exportToWkt ()
1528
1528
expwkt = '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)))'
1529
1529
assert compareWkt (expwkt , wkt ), "Expected:\n %s\n Got:\n %s\n " % (expwkt , wkt )
0 commit comments