Bug report #15421
QgsSnapper return only one result on multiple items
|Affected QGIS version:||master_2||Regression?:||No|
|Operating System:||windows||Easy fix?:||No|
|Pull Request or Patch supplied:||No||Resolution:||end of life|
|Crashes QGIS or corrupts data:||No||Copied to github as #:||23348|
I am trying to programmatically to snap to the nearest segment or segments. I have a layer with two lines (the corresponding SHAPE layer is attached):
- (0,0) -> (3,3)
- (1,1) -> (2,2)
These two lines has a common overlap corresponding to the second line.
I have set up the snapper as follows:
Setup the snap layer.
>>> sl = QgsSnapper.SnapLayer()
>>> sl.mLayer = iface.mapCanvas().currentLayer()
>>> sl.mTolerance = 25
>>> sl.mSnapTo = QgsSnapper.SnapToSegment
>>> sl.mUnitType = QgsTolerance.Pixels
Setup the snapper.
>>> sn = QgsSnapper(iface.mapCanvas().mapSettings())
I want more than one result if available.
>>> sn.setSnapMode = QgsSnapper.SnapWithResultsWithinTolerances
Snap using the center point of the common overlap - that should ensure both lines are detected.
>>> (retval, result) = sn.snapMapPoint(QgsPoint(1.5, 1.5))
The result, where I expect two items, but the following only gives me one.
According to https://github.com/qgis/QGIS/blob/master/src/core/qgssnapper.cpp#L108 using either
QgsSnapper.SnapWithResultsWithinTolerances should allow for more results.
What is going wrong for me here?
- Open QGIS.
- Load the attached layer.
- Paste the above code into the Python console.
#2 Updated by Giovanni Manghi over 2 years ago
- Resolution set to end of life
- Status changed from Open to Closed
End of life notice: QGIS 2.18 LTR