[Qgis-developer] Datum transformations

Martin Dobias wonder.sk at gmail.com
Sun Feb 23 21:03:27 PST 2014

Hi (Marco)

I have some suggestions for the implementation of datum transforms in
QGIS and I would like to hear your opinion about them.

In the 2.2 release, as far as I understand the logic is implemented like this:
- map renderer emits a signal asking for datum transform choice
- map canvas catches the signal and provides either the default
(defined in options) or asks the user in a dialog - and sends this
information back to map renderer
- map renderer stores the information about datum transforms and does
loading/saving in project file
- map renderer provides access to coordinate transforms (with correct
datum transform info)

The main issue I see here is the fact that in case of non-default
datum transforms - if some code in QGIS creates coordinate transform
without using transform provided by map renderer, it will be created
without the chosen datum transform and will therefore provide
incorrect results. This can lead to subtle bugs (for example,
QgsVectorFileWriter will not use the defined datum transforms, causing
offsets in reprojected data). Changing all the possible places where
coordinate transform may be used to call
QgsMapRenderer::transformation() seems impractical.

What do you think about:
- using QgsCoordinateTransformCache internally by
QgsCoordinateTransform anytime a new transform should be instantiated
- keeping the datum transform information in a helper class
(loaded/saved by project) and using it directly by
QgsCoordinateTransform - so any QGIS code will use the correct datum
- GUI: have a tab in project properties where non-default datum
transforms would be managed - instead of requiring the user to select
the datum transform immediately when the layer was added (and without
being able to change the decision later)

Currently the datum transforms do not work at all in master after the
merge of MTR because the QgsMapRenderer class is not used for
rendering anymore. Before trying to do anything in that area I would
like to hear your input.

I guess there is still a question what to do in cases when there are
more layers with the same CRS but with different datum transforms - I
am not sure how well the current implementation handles that case (if
there is a datum transform defined in options, it will be used for all
layers with given CRS) and how much we need such functionality.


More information about the Qgis-developer mailing list