Skip to content

Commit 41fafd6

Browse files
p0ciskm-kuhn
authored andcommittedOct 19, 2016
[processing] support MultiPoint geometries in Delaunay triangulation
1 parent ee9e1c3 commit 41fafd6

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed
 

‎python/plugins/processing/algs/qgis/Delaunay.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,16 @@ def processAlgorithm(self, progress):
8282
total = 100.0 / len(features)
8383
for current, inFeat in enumerate(features):
8484
geom = inFeat.geometry()
85-
point = geom.asPoint()
86-
x = point.x()
87-
y = point.y()
88-
pts.append((x, y))
89-
ptNdx += 1
90-
ptDict[ptNdx] = inFeat.id()
85+
if geom.isMultipart():
86+
points = geom.asMultiPoint()
87+
else:
88+
points = [ geom.asPoint() ]
89+
for n, point in enumerate(points):
90+
x = point.x()
91+
y = point.y()
92+
pts.append((x, y))
93+
ptNdx += 1
94+
ptDict[ptNdx] = (inFeat.id(), n)
9195
progress.setPercentage(int(current * total))
9296

9397
if len(pts) < 3:
@@ -111,10 +115,14 @@ def processAlgorithm(self, progress):
111115
attrs = []
112116
step = 0
113117
for index in indicies:
114-
request = QgsFeatureRequest().setFilterFid(ptDict[ids[index]])
118+
fid, n = ptDict[ids[index]]
119+
request = QgsFeatureRequest().setFilterFid(fid)
115120
inFeat = next(layer.getFeatures(request))
116121
geom = inFeat.geometry()
117-
point = QgsPoint(geom.asPoint())
122+
if geom.isMultipart():
123+
point = QgsPoint(geom.asMultiPoint()[n])
124+
else:
125+
point = QgsPoint(geom.asPoint())
118126
polygon.append(point)
119127
if step <= 3:
120128
attrs.append(ids[index])

0 commit comments

Comments
 (0)
Please sign in to comment.