Skip to content

Commit

Permalink
[processing] support MultiPoint geometries in Delaunay triangulation
Browse files Browse the repository at this point in the history
  • Loading branch information
p0cisk authored and m-kuhn committed Oct 19, 2016
1 parent ee9e1c3 commit 41fafd6
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions python/plugins/processing/algs/qgis/Delaunay.py
Expand Up @@ -82,12 +82,16 @@ def processAlgorithm(self, progress):
total = 100.0 / len(features)
for current, inFeat in enumerate(features):
geom = inFeat.geometry()
point = geom.asPoint()
x = point.x()
y = point.y()
pts.append((x, y))
ptNdx += 1
ptDict[ptNdx] = inFeat.id()
if geom.isMultipart():
points = geom.asMultiPoint()
else:
points = [ geom.asPoint() ]
for n, point in enumerate(points):
x = point.x()
y = point.y()
pts.append((x, y))
ptNdx += 1
ptDict[ptNdx] = (inFeat.id(), n)
progress.setPercentage(int(current * total))

if len(pts) < 3:
Expand All @@ -111,10 +115,14 @@ def processAlgorithm(self, progress):
attrs = []
step = 0
for index in indicies:
request = QgsFeatureRequest().setFilterFid(ptDict[ids[index]])
fid, n = ptDict[ids[index]]
request = QgsFeatureRequest().setFilterFid(fid)
inFeat = next(layer.getFeatures(request))
geom = inFeat.geometry()
point = QgsPoint(geom.asPoint())
if geom.isMultipart():
point = QgsPoint(geom.asMultiPoint()[n])
else:
point = QgsPoint(geom.asPoint())
polygon.append(point)
if step <= 3:
attrs.append(ids[index])
Expand Down

0 comments on commit 41fafd6

Please sign in to comment.