[Qgis-developer] Select datum transform in QGIS

Marco Hugentobler marco.hugentobler at sourcepole.ch
Thu Nov 7 07:39:35 PST 2013


Dear qgis devs

In QGIS, there is currently no possibility to choose the type of datum 
transform used in otf-reprojecting. Additionally, some national mapping 
agencies provide datum shift grids and they cannot be used conveniently 
in QGIS ( a user needs to make user defined crs and store the +nadgrids= 
parameter there).
Some proprietary systems pop up a dialog box in case there are several 
datum transformations available and let the user choose an appropriate 
one. Therefore, I've been in charge of implementing a similar solution 
for QGIS, and the code is ready for first testing / feedback now:

https://github.com/mhugent/Quantum-GIS/commits/datum_transform

Here a short summary of the changes:

- There is a new table in srs.db created from the gdal file 
'datum_shift.csv'. It contains 3/7 parameter towgs84 parameters. 
Additionally, there is also the possibility to extend srs.db with ntv2 
(grid shift) transformations (with the .gbs filename as first parameter).
- Once otf-reprojection is enabled and QGIS detects more than one 
possible datum transformation between the two CRS, the user is asked in 
a dialog which one to use. This is stored into the project file, so only 
needs to be entered if adding the layer or changing the layer / map CRS. 
The user is also asked if saving a layer in a different CRS and the 
datum transform is of course also picked up by QGIS server.

possible problems from user perspective:

- The dialogs asking for datum transform could be annoying. Does it need 
an option to suppress it (and should it be enabled / disabled by default)?
- The synchronisation of srs.db with datum_shift.csv makes the install 
time longer (maybe it can be solved more efficiently?)

technical details for devs:

- QgsCoordinateTransform currently contains srcCRS, destCRS. It is 
extended to hold optionally source datum transform / dest datum 
transform (int is coord_op_code in srs.db). In 
QgsCoordinateTransform::initialise, the datum transform strings are 
modified to match the choosen datum transforms.
- QgsCRSCache is extended to search by datum transform too (to avoid 
expensive lookups in the sqlite db every time)
- QgsMapRenderer stores the information about layer / datum 
transformation and reads / writes to project filename
- To receive the current QgsCoordinateTransformation for a layer, tools 
may query QgsMapRenderer::tr (or QgsMapRenderer::mapToLayerCoordinates 
etc.). Creating a new QgsCoordinateTransform from layerCRS and mapCRS is 
not correct in all cases any more.


What are your opinions / suggestions?

Regards,
Marco

-- 
Dr. Marco Hugentobler
Sourcepole -  Linux & Open Source Solutions
Weberstrasse 5, CH-8004 Zürich, Switzerland
marco.hugentobler at sourcepole.ch http://www.sourcepole.ch
Technical Advisor QGIS Project Steering Committee



More information about the Qgis-developer mailing list