[Qgis-developer] R: Re: Automate snapping after insert of a new feature

francescoboccacci at libero.it francescoboccacci at libero.it
Thu Apr 23 01:15:37 PDT 2015


Hi Giovanni,
thanks for you reply. I tried to use your solution but the QgsPoint returned by sbappedVertx has a strange coordinate

reault[1][0.096699529....][0].snappedVertex
(6.79039e-313,2.8142e-320)


new_geom = QgsGeometry.fromPolyline([f.geometry().asPolyline()[0],a[1][7.715400893466547][0].snappedVertex])
after i tried to create a new geometry to use with l.cangeGeometry(ID FEATURE, new_geom)

Any suggestion?

Thanks

Francesco






----Messaggio originale----

Da: giohappy at gmail.com

Data: 22/04/2015 21.54

A: "francescoboccacci at libero.it"<francescoboccacci at libero.it>

Cc: "qgis-developer"<qgis-developer at lists.osgeo.org>

Ogg: Re: [Qgis-developer] Automate snapping after insert of a new feature



Can't you use the the snapped point (QgsSnappingResult.snappedVertex) to replace the original vertex position?
giovanni
2015-04-22 11:01 GMT+02:00 francescoboccacci at libero.it <francescoboccacci at libero.it>:
Hi all,
i have a question for you. I'd like to have a new function in my plugin that makes an autime snapping if a start point or end point of a new feature inserted is closed to a vertex or segment base on a values setted ina configuration file.
>From plugin console:

l = iface.activeLayer()  --activeLayer
f = l.selectedFeatures()[0] -- new fetaure inserted
start = f.geometry().asPolyline()[0] -- get the start point (the point that i would like to snap to a segment)
result = l.snapWithContext(start,10,QgsSnapper.SnapToVertexAndSegment) -- i use
result
(0, {0.0: [<qgis._core.QgsSnappingResult object at 0x0000000018B9C400>], 0.09699529788394015: [<qgis._core.QgsSnappingResult object at 0x0000000018B9C620>]})

I notice that the key 0.09699529788394015 is the effective distance between my start point and the segment.
My question is:
How can i modify the feature geometry to snap to the segment according to result?

Thanks

Francesco

_______________________________________________

Qgis-developer mailing list

Qgis-developer at lists.osgeo.org

http://lists.osgeo.org/mailman/listinfo/qgis-developer


-- 
Giovanni Allegri
http://about.me/giovanniallegriGis3W - http://gis3w.itIkare - http://ikare.it
Twitter: https://twitter.com/_giohappy_blog: http://blog.spaziogis.it
GEO+ geomatica in Italia http://bit.ly/GEOplus





-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20150423/d30e48da/attachment-0001.html>


More information about the Qgis-developer mailing list