-
Notifications
You must be signed in to change notification settings - Fork 9
Coordinate_Transformations
Plugin enables user to set default coordinate transformation methods for defined region. Methods may be stored in QGIS configuration, or to QGIS project too. These methods are defined in plugin configuration (by it's maintainers). Each transformation references region(s) for which it is used. User then can choose region (list of regions is generated from configuration) for which he/she wants to set default transformation methods. Transformation methods for chosen region are then added into QGIS configuration or project. They are then visible in QGIS default transformation settings window (Settings → Options → Transformations) in case they are saved to QGIS configuration, or in Project Properties window (Project → Properties → Transformations) in case they are saved to QGIS projects. If there are some shift grids necessary, plugin will automatically download and apply them.
Transformation methods are configured in crs_trans/crs_trans.ini
file. There is documentation how to define coordinate transformation at the beginning of this file.
Some transformations needs shift grid file to be present. These grids are defined in crs_trans/grids.ini
. There is documentation how to define shift grid at the beginning of this file.
Plugin checks content of these configuration files once it initialises and tries to provide helpful warning messages once some inconsistency is found.
Configuration and all classes related to coordinate transformations logic are stored inside crs_trans/
folder. These include:
-
crs_trans.ini
- transformation methods configuration, -
grids.ini
- shift grids configuration, -
CoordinateTransformation.py
- defines class of the same name which contains all logic around single coordinate transformation method, -
CoordinateTransformationList.py
- defines class of the same name which contains all logic around group of coordinate transformation methods, -
ShiftGrid.py
- defines class of the same name which contains all logic around single shift grid, -
ShiftGridList.py
- defines class of the same name which contains all logic around group of shift grids, -
graph_generate.py
- generates Graphviz graph of configured transformation methods (see bellow for more information).
Main class GeoDataDialog
contains two methods and two variables associated with coordinate transformations:
-
load_shift_grids
method loads all available grids intogrids
variable (which is of typeShiftGridList
), -
load_crs_transformations
method loads all available transformation methods intotransformations
variable (which is of typeCoordinateTransformationList
). Note that in order to successfully initialize transformations, shift grids needs to be leaded first.
To get list of available regions (for which there are transformations defined) inside GeoDataDialog
class, one needs to call:
self.transformations.getRegions()
This will return list of available region codes. To apply transformations for chosen region, following code can be called from GeoDataDialog
class:
self.transformations.applyTransformations(region_code, destination)
where region_code
represents one of strings from list returned by getRegions()
method and destination
is string containing either CONFIGURATION
(in which case transformations are saved to QGIS configuration), or PROJECT
(in which case transformations are saved to current QGIS project).
Note this method may be called even without any argument. In that case, all available transformations are applied. However, if there are multiple transformation methods defined for the same pair of coordinate systems for different regions (i.e. transformation method from EPSG:5514 to EPSG:4328 is defined for Czechia, Slovakia and Czechoslovania), only last one defined in crs_trans.ini
will be actually applied as QGIS default. If destination
is omitted, value CONFIGURATION
is used.
Script crs_trans/graph_generate.py
generates Graphviz graph (source code file and PNG image) of transformation methods defined inside crs_trans.ini
file (note it understands only configuration of plugin, not of QGIS itself).
This script is completely independent from other parts of this plugin (also, plugin is completely independent from this script). However it requires Graphviz and Pyhton Graphviz library (neither of which is required by plugin itself).
Script provides CLI and its usage can be invoked by:
./graph_generate.py --help