Skip to content

Commit 1a95297

Browse files
committed
Fix #7073
1 parent 1ebdb69 commit 1a95297

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

python/plugins/fTools/tools/doIntersectLines.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ def compute(self, line1, line2, field1, field2, outPath, progressBar):
148148

149149
index = ftools_utils.createIndex( provider2 )
150150

151+
singlelayer_tempList = []
151152
fit1 = provider1.getFeatures( QgsFeatureRequest().setSubsetOfAttributes([index1]) )
152153
while fit1.nextFeature(inFeat):
153154
inGeom = inFeat.geometry()
@@ -169,10 +170,19 @@ def compute(self, line1, line2, field1, field2, outPath, progressBar):
169170
tempList.append(tempGeom.asPoint())
170171

171172
for j in tempList:
172-
outFeat.setGeometry(tempGeom.fromPoint(j))
173-
outFeat.setAttribute(0, v1)
174-
outFeat.setAttribute(1, v2)
175-
writer.addFeature(outFeat)
173+
# if same layer, avoid insert duplicated points
174+
if line1 == line2:
175+
if not j in singlelayer_tempList:
176+
singlelayer_tempList.append(j)
177+
outFeat.setGeometry(tempGeom.fromPoint(j))
178+
outFeat.setAttribute(0, v1)
179+
outFeat.setAttribute(1, v2)
180+
writer.addFeature(outFeat)
181+
else:
182+
outFeat.setGeometry(tempGeom.fromPoint(j))
183+
outFeat.setAttribute(0, v1)
184+
outFeat.setAttribute(1, v2)
185+
writer.addFeature(outFeat)
176186

177187
start = start + add
178188
progressBar.setValue(start)

0 commit comments

Comments
 (0)