@@ -1351,15 +1351,15 @@ def testAddPart(self):
1351
1351
points = [QgsPoint (0 , 0 ), QgsPoint (1 , 0 )]
1352
1352
1353
1353
point = QgsGeometry .fromPoint (points [0 ])
1354
- self .assertEqual (point .addPart ([points [1 ]]), 0 )
1354
+ self .assertEqual (point .addPoints ([points [1 ]]), 0 )
1355
1355
expwkt = "MultiPoint ((0 0), (1 0))"
1356
1356
wkt = point .exportToWkt ()
1357
1357
assert compareWkt (expwkt , wkt ), "Expected:\n %s\n Got:\n %s\n " % (expwkt , wkt )
1358
1358
1359
1359
# test adding a part with Z values
1360
1360
point = QgsGeometry .fromPoint (points [0 ])
1361
1361
point .geometry ().addZValue (4.0 )
1362
- self .assertEqual (point .addPart ([QgsPointV2 (QgsWkbTypes .PointZ , points [1 ][0 ], points [1 ][1 ], 3.0 )]), 0 )
1362
+ self .assertEqual (point .addPointsV2 ([QgsPointV2 (QgsWkbTypes .PointZ , points [1 ][0 ], points [1 ][1 ], 3.0 )]), 0 )
1363
1363
expwkt = "MultiPointZ ((0 0 4), (1 0 3))"
1364
1364
wkt = point .exportToWkt ()
1365
1365
assert compareWkt (expwkt , wkt ), "Expected:\n %s\n Got:\n %s\n " % (expwkt , wkt )
@@ -1373,14 +1373,14 @@ def testAddPart(self):
1373
1373
]
1374
1374
1375
1375
polyline = QgsGeometry .fromPolyline (points [0 ])
1376
- self .assertEqual (polyline .addPart (points [1 ][0 :1 ]), 2 , "addPart with one point line unexpectedly succeeded." )
1377
- self .assertEqual (polyline .addPart (points [1 ][0 :2 ]), 0 , "addPart with two point line failed." )
1376
+ self .assertEqual (polyline .addPoints (points [1 ][0 :1 ]), 2 , "addPoints with one point line unexpectedly succeeded." )
1377
+ self .assertEqual (polyline .addPoints (points [1 ][0 :2 ]), 0 , "addPoints with two point line failed." )
1378
1378
expwkt = "MultiLineString ((0 0, 1 0, 1 1, 2 1, 2 0), (3 0, 3 1))"
1379
1379
wkt = polyline .exportToWkt ()
1380
1380
assert compareWkt (expwkt , wkt ), "Expected:\n %s\n Got:\n %s\n " % (expwkt , wkt )
1381
1381
1382
1382
polyline = QgsGeometry .fromPolyline (points [0 ])
1383
- self .assertEqual (polyline .addPart (points [1 ]), 0 , "addPart with %d point line failed." % len (points [1 ]))
1383
+ self .assertEqual (polyline .addPoints (points [1 ]), 0 , "addPoints with %d point line failed." % len (points [1 ]))
1384
1384
expwkt = "MultiLineString ((0 0, 1 0, 1 1, 2 1, 2 0), (3 0, 3 1, 5 1, 5 0, 6 0))"
1385
1385
wkt = polyline .exportToWkt ()
1386
1386
assert compareWkt (expwkt , wkt ), "Expected:\n %s\n Got:\n %s\n " % (expwkt , wkt )
@@ -1389,7 +1389,7 @@ def testAddPart(self):
1389
1389
polyline = QgsGeometry .fromPolyline (points [0 ])
1390
1390
polyline .geometry ().addZValue (4.0 )
1391
1391
points2 = [QgsPointV2 (QgsWkbTypes .PointZ , p [0 ], p [1 ], 3.0 ) for p in points [1 ]]
1392
- self .assertEqual (polyline .addPart (points2 ), 0 )
1392
+ self .assertEqual (polyline .addPointsV2 (points2 ), 0 )
1393
1393
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))"
1394
1394
wkt = polyline .exportToWkt ()
1395
1395
assert compareWkt (expwkt , wkt ), "Expected:\n %s\n Got:\n %s\n " % (expwkt , wkt )
@@ -1406,12 +1406,12 @@ def testAddPart(self):
1406
1406
1407
1407
polygon = QgsGeometry .fromPolygon (points [0 ])
1408
1408
1409
- self .assertEqual (polygon .addPart (points [1 ][0 ][0 :1 ]), 2 , "addPart with one point ring unexpectedly succeeded." )
1410
- self .assertEqual (polygon .addPart (points [1 ][0 ][0 :2 ]), 2 , "addPart with two point ring unexpectedly succeeded." )
1411
- self .assertEqual (polygon .addPart (points [1 ][0 ][0 :3 ]), 2 , "addPart with unclosed three point ring unexpectedly succeeded." )
1412
- self .assertEqual (polygon .addPart ([QgsPoint (4 , 0 ), QgsPoint (5 , 0 ), QgsPoint (4 , 0 )]), 2 , "addPart with 'closed' three point ring unexpectedly succeeded." )
1409
+ self .assertEqual (polygon .addPoints (points [1 ][0 ][0 :1 ]), 2 , "addPoints with one point ring unexpectedly succeeded." )
1410
+ self .assertEqual (polygon .addPoints (points [1 ][0 ][0 :2 ]), 2 , "addPoints with two point ring unexpectedly succeeded." )
1411
+ self .assertEqual (polygon .addPoints (points [1 ][0 ][0 :3 ]), 2 , "addPoints with unclosed three point ring unexpectedly succeeded." )
1412
+ self .assertEqual (polygon .addPoints ([QgsPoint (4 , 0 ), QgsPoint (5 , 0 ), QgsPoint (4 , 0 )]), 2 , "addPoints with 'closed' three point ring unexpectedly succeeded." )
1413
1413
1414
- self .assertEqual (polygon .addPart (points [1 ][0 ]), 0 , "addPart failed" )
1414
+ self .assertEqual (polygon .addPoints (points [1 ][0 ]), 0 , "addPoints failed" )
1415
1415
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)))"
1416
1416
wkt = polygon .exportToWkt ()
1417
1417
assert compareWkt (expwkt , wkt ), "Expected:\n %s\n Got:\n %s\n " % (expwkt , wkt )
@@ -1433,46 +1433,46 @@ def testAddPart(self):
1433
1433
polygon = QgsGeometry .fromPolygon (points [0 ])
1434
1434
polygon .geometry ().addZValue (4.0 )
1435
1435
points2 = [QgsPointV2 (QgsWkbTypes .PointZ , pi [0 ], pi [1 ], 3.0 ) for pi in points [1 ][0 ]]
1436
- self .assertEqual (polygon .addPart (points2 ), 0 )
1436
+ self .assertEqual (polygon .addPointsV2 (points2 ), 0 )
1437
1437
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)))"
1438
1438
wkt = polygon .exportToWkt ()
1439
1439
assert compareWkt (expwkt , wkt ), "Expected:\n %s\n Got:\n %s\n " % (expwkt , wkt )
1440
1440
1441
1441
# Test adding parts to empty geometry, should become first part
1442
1442
empty = QgsGeometry ()
1443
1443
# if not default type specified, addPart should fail
1444
- result = empty .addPart ([QgsPoint (4 , 0 )])
1444
+ result = empty .addPoints ([QgsPoint (4 , 0 )])
1445
1445
assert result != 0 , 'Got return code {}' .format (result )
1446
- result = empty .addPart ([QgsPoint (4 , 0 )], QgsWkbTypes .PointGeometry )
1446
+ result = empty .addPoints ([QgsPoint (4 , 0 )], QgsWkbTypes .PointGeometry )
1447
1447
self .assertEqual (result , 0 , 'Got return code {}' .format (result ))
1448
1448
wkt = empty .exportToWkt ()
1449
1449
expwkt = 'MultiPoint ((4 0))'
1450
1450
assert compareWkt (expwkt , wkt ), "Expected:\n %s\n Got:\n %s\n " % (expwkt , wkt )
1451
- result = empty .addPart ([QgsPoint (5 , 1 )])
1451
+ result = empty .addPoints ([QgsPoint (5 , 1 )])
1452
1452
self .assertEqual (result , 0 , 'Got return code {}' .format (result ))
1453
1453
wkt = empty .exportToWkt ()
1454
1454
expwkt = 'MultiPoint ((4 0),(5 1))'
1455
1455
assert compareWkt (expwkt , wkt ), "Expected:\n %s\n Got:\n %s\n " % (expwkt , wkt )
1456
1456
# next try with lines
1457
1457
empty = QgsGeometry ()
1458
- result = empty .addPart (points [0 ][0 ], QgsWkbTypes .LineGeometry )
1458
+ result = empty .addPoints (points [0 ][0 ], QgsWkbTypes .LineGeometry )
1459
1459
self .assertEqual (result , 0 , 'Got return code {}' .format (result ))
1460
1460
wkt = empty .exportToWkt ()
1461
1461
expwkt = 'MultiLineString ((0 0, 1 0, 1 1, 2 1, 2 2, 0 2, 0 0))'
1462
1462
assert compareWkt (expwkt , wkt ), "Expected:\n %s\n Got:\n %s\n " % (expwkt , wkt )
1463
- result = empty .addPart (points [1 ][0 ])
1463
+ result = empty .addPoints (points [1 ][0 ])
1464
1464
self .assertEqual (result , 0 , 'Got return code {}' .format (result ))
1465
1465
wkt = empty .exportToWkt ()
1466
1466
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))'
1467
1467
assert compareWkt (expwkt , wkt ), "Expected:\n %s\n Got:\n %s\n " % (expwkt , wkt )
1468
1468
# finally try with polygons
1469
1469
empty = QgsGeometry ()
1470
- result = empty .addPart (points [0 ][0 ], QgsWkbTypes .PolygonGeometry )
1470
+ result = empty .addPoints (points [0 ][0 ], QgsWkbTypes .PolygonGeometry )
1471
1471
self .assertEqual (result , 0 , 'Got return code {}' .format (result ))
1472
1472
wkt = empty .exportToWkt ()
1473
1473
expwkt = 'MultiPolygon (((0 0, 1 0, 1 1, 2 1, 2 2, 0 2, 0 0)))'
1474
1474
assert compareWkt (expwkt , wkt ), "Expected:\n %s\n Got:\n %s\n " % (expwkt , wkt )
1475
- result = empty .addPart (points [1 ][0 ])
1475
+ result = empty .addPoints (points [1 ][0 ])
1476
1476
self .assertEqual (result , 0 , 'Got return code {}' .format (result ))
1477
1477
wkt = empty .exportToWkt ()
1478
1478
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)))'
0 commit comments