@@ -463,12 +463,16 @@ def delaunay_triangulation( self ):
463
463
inFeat = QgsFeature ()
464
464
c = voronoi .Context ()
465
465
pts = []
466
+ ptDict = {}
467
+ ptNdx = - 1
466
468
while vprovider .nextFeature (inFeat ):
467
469
geom = QgsGeometry (inFeat .geometry ())
468
470
point = geom .asPoint ()
469
471
x = point .x ()
470
472
y = point .y ()
471
473
pts .append ((x , y ))
474
+ ptNdx += 1
475
+ ptDict [ptNdx ] = inFeat .id ()
472
476
if len (pts ) < 3 :
473
477
return False
474
478
uniqueSet = Set (item for item in pts )
@@ -488,7 +492,7 @@ def delaunay_triangulation( self ):
488
492
polygon = []
489
493
step = 0
490
494
for index in indicies :
491
- vprovider .featureAtId ( ids [index ], inFeat , True , allAttrs )
495
+ vprovider .featureAtId (ptDict [ ids [index ]] , inFeat , True , allAttrs )
492
496
geom = QgsGeometry (inFeat .geometry ())
493
497
point = QgsPoint (geom .asPoint ())
494
498
polygon .append (point )
@@ -517,26 +521,30 @@ def voronoi_polygons( self ):
517
521
width = extent .width ()
518
522
c = voronoi .Context ()
519
523
pts = []
524
+ ptDict = {}
525
+ ptNdx = - 1
520
526
while vprovider .nextFeature (inFeat ):
521
527
geom = QgsGeometry (inFeat .geometry ())
522
528
point = geom .asPoint ()
523
529
x = point .x ()- extent .xMinimum ()
524
530
y = point .y ()- extent .yMinimum ()
525
531
pts .append ((x , y ))
532
+ ptNdx += 1
533
+ ptDict [ptNdx ] = inFeat .id ()
526
534
self .vlayer = None
527
535
if len (pts ) < 3 :
528
536
return False
529
537
uniqueSet = Set (item for item in pts )
530
538
ids = [pts .index (item ) for item in uniqueSet ]
531
- sl = voronoi .SiteList ([voronoi .Site (* i , sitenum = j ) for j , i in enumerate (uniqueSet )])
539
+ sl = voronoi .SiteList ([voronoi .Site (i [ 0 ], i [ 1 ] , sitenum = j ) for j , i in enumerate (uniqueSet )])
532
540
voronoi .voronoi (sl , c )
533
541
inFeat = QgsFeature ()
534
542
nFeat = len (c .polygons )
535
543
nElement = 0
536
544
self .emit ( SIGNAL ( "runStatus(PyQt_PyObject)" ), 0 )
537
545
self .emit ( SIGNAL ( "runRange(PyQt_PyObject)" ), ( 0 , nFeat ) )
538
546
for site , edges in c .polygons .iteritems ():
539
- vprovider .featureAtId (ids [site ], inFeat , True , allAttrs )
547
+ vprovider .featureAtId (ptDict [ ids [site ] ], inFeat , True , allAttrs )
540
548
lines = self .clip_voronoi (edges , c , width , height , extent , extraX , extraY )
541
549
geom = QgsGeometry .fromMultiPoint (lines )
542
550
geom = QgsGeometry (geom .convexHull ())
0 commit comments