coordinatemgr¶
This module contains the CoordManager class, which manages the relationship between coordinates for display and coordinates in the raster
- class tuiview.coordinatemgr.CoordManager[source]¶
base class for the layer’s coordmgr instance. Derived separately for vector and raster layers.
- getFullWorldExtent()[source]¶
Gets the full extent of the dataset in world coords as a 4 element tuple. To be implmented by derived class
- class tuiview.coordinatemgr.RasterCoordManager[source]¶
Manage the relationship between the coordinate system used for display and the other coordinate systems used in the raster file. An instance of this class represents the current relationship for a single raster, for a single display.
Methods are provided for updating the transformation(s), and for transforming between the different coordinate systems.
- Coordinate systems involved are:
- display coords - this notionally corresponds to the screen pixels,
although technically it is the units which Qt exposes as its viewport coordinates
- pixel coords - this is the pixel row/column coordinates in the
raster file, using the GDAL conventions
- world coords - this is the projected coordinate system of the raster
file, using the GDAL coordinates.
In all cases, coordinate pairs are given with the horizontal coordinate first, i.e. (x, y), even when referring to row/col pairs. Thus, a row/col pair will be given as (col, row).
- calcZoomFactor(right, bottom)[source]¶
Calculate the zoom factor, given the currently set top/left pixel to display, and the bottom/right pixel desired in display, for the currently set display size.
The zoom factor is calculated to come as close as possible to display the given section of the raster, with the current display size, but will correct for any difference in aspect ratio between the display window and the desired region of the raster. This means that the given bottom/right values are not always actually displayed. One of them, either bottom or right, will be maintained, but the other will be adjusted to match the aspect ratio of the display. For this reason, the bottom/right values are not stored on the object, but instead the calculated zoom factor is stored. The whole of the desired region will be fitted into the display window.
- display2pixel(x, y)[source]¶
Convert from display units to raster row/col. Returns a tuple (col, row), as floats.
- display2world(dspX, dspY)[source]¶
Convert display (x, y) to world coordinates. Returns a tuple of floats (x, y), in the world coordinate system
- getFullWorldExtent()[source]¶
Gets the full extent of the dataset in world coords as a 4 element tuple.
- getWorldExtent()[source]¶
Get the extent of the displayed area in world coords A 4 element tuple is returned.
- pixel2display(col, row)[source]¶
Convert raster row/col to display units. Returns a tuple of (x, y). These are int values, as that appears to be all Qt will ever deal with.
- pixel2displayF(col, row)[source]¶
Convert raster row/col to display units. Returns a tuple of (x, y). This version returns floats
- pixel2world(col, row)[source]¶
Convert raster row/col to world coordinate system. Returns a tuple of floats (x, y)
- recalcBottomRight()[source]¶
Called when the window shape has changed. The pixBottom and pixRight values are recalculated, based on the new window shape and the existing zoom factor
- setTopLeftPixel(leftcol, toprow)[source]¶
Set row/col of the top/left pixel to display. Args are pixel row/column numbers
- setZoomFactor(imgPixPerWinPix)[source]¶
Set the zoom to the given value of imgPixPerWinPix. Will then recalcBottomRight().