[Qgis-developer] Snapping rounding errors with on-the-fly reprojection (#13745)

Daan Goedkoop dgoedkoop at gmx.net
Sat Nov 7 09:28:44 PST 2015


Hello everyone,

Last week I made a bug report (http://hub.qgis.org/issues/13745) and
got redirected to this mailing list.

To summarize, the issue here is as follows. When digitising, QGis
keeps a rubber band in map coordinates and a capture list in layer
coordinates. However, vertices of the capture list are added in a way
where they are first converted from on-screen pixel coordinates to map
coordinates, then snapped, and then transformed to layer coordinates.
This leads to floating point inaccuracies, so that the resulting layer
data are in fact not exactly snapped.

To test if this is really the problem, I have made some changes, so
that the capture list coordinates are directly snapped to the layer
coordinates. With these changes, snapping seems to work correctly,
without such floating point inaccuracies. I've put these changes here:
https://github.com/dgoedkoop/QGIS/tree/digitise_snap_crs

I think they are not (yet?) suitable for a pull request. There are
(still) some problems, such as:
- Snapping tolerance might not be converted between map / layer units
and might thus be completely wrong
- The snapping index is created and destroyed twice in every mapcanvas
mouse event. This is unacceptably slow. At least two snapping caches
are necessary, one for the map CRS and one for the current layer CRS.
- Might crash when digitising without any active layer
- I haven't looked at unit tests yet (only checked that the existing
ones compile at all.)

This is my first try for a little bit bigger contribution to an open
source project. And also the first time to write some C++ code. And
also the first time to use github forks. So I'd appreciate any
feedback!

Kind regards,
Daan Goedkoop


More information about the Qgis-developer mailing list