[Qgis-developer] Python Snapping

Maurício de Paulo mauricio.dev at gmail.com
Sat Nov 14 16:11:58 EST 2009


Hi Martin,
Actually, it depends on some still unknown factor. If i remember right I
found a 2 cm error with 100m coordinates.
Hum... my plugin is available in the comunity repository if you need to test
the snapping error. QgsAzimuth.
Mauricio de Paulo

2009/11/14 Martin Dobias <wonder.sk at gmail.com>

> 2009/11/12 Maurício de Paulo <mauricio.dev at gmail.com>:
> > Hi,
> > I've been working on the QgsAzimuth plugin and recently some users told
> me
> > of a limitation on the code I wrote.
> > The snapping is not with enough precision.
> > The following code is the event that I wrote that tries to use snap and
> if
> > not possible, use the captured pixel as coordinate. Is it the right way
> of
> > implementing a snap tool?
> >
> >  def canvasPressEvent(self,event):
> >     pixels=event.pos()
> >     snapper=QgsMapCanvasSnapper(self.canvas)
> >     snapped=snapper.snapToBackgroundLayers(pixels)
> >     if len(snapped[1])>0:
> >         xy=snapped[1][0].afterVertex
> >     else:
> >         #transforming pixels to x,y
> >         transform = self.canvas.getCoordinateTransform()
> >         xy = transform.toMapCoordinates(pixels) #captures the clicked
> > coordinate and transform
> >     self.emit(SIGNAL("finished(PyQt_PyObject)"),xy)     #return QgsPoint
> in
> > a signal
>
> Hi,
>
> could you quantify how big is the loss of precision (expected vs.
> obtained coordinates)?
> From a quick look the code for snapping should be fine.
>
> Martin
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/qgis-developer/attachments/20091114/f552641d/attachment.html


More information about the Qgis-developer mailing list