[Qgis-developer] Python: How to allow for more results using QgsSnapper.snapMapPoint(...)

Casper Børgesen (CABO) CABO at NIRAS.DK
Tue Aug 9 09:34:20 PDT 2016


Hi

I'm playing around with the QGIS (d01bfd1) snap functionalities in python and I'm trying to get it return all the segments in the vicinity of the point of interest.

    sl = QgsSnapper.SnapLayer()
    sl.mLayer = canvas.currentLayer()
    sl.mTolerance = 50
    sl.snapTo = QgsSnapper.SnapToSegment

    snapper = QgsSnapper(canvas.mapSettings())
    snapper.setSnapLayers([sl])
    snapper.setSnapMode = QgsSnapper.SnapWithResultsWithinTolerances

         (retval, result) = snapper.snapMapPoint(point_of_interest_in_map_coordinates)

If I choose a point near two coinciding polygon edges I only get one result.

If I choose a point near a place where three different polygon edges meet at the same point, I still only get one result.

I though using the snap mode SnapWithResultsWithinTolerances (or even in this case SnapWithResultsForSamePosition) would allow the snapper to give me more than one result?


Regards Casper
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20160809/114dd282/attachment.html>


More information about the Qgis-developer mailing list