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

getWorldCenter()[source]

Gets the center of the extent in world coords

getWorldExtent()[source]

Gets the extent in world coords as a 4 element tuple. To be implmented by derived class

setDisplaySize(width, height)[source]

Set display size in units of display coordinate system

setWorldCenter(wldX, wldY)[source]

Sets the center of the extent in world coords

setWorldExtent(extent)[source]

Sets the extent 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

setGeoTransformAndSize(transform, xsize, ysize)[source]

Set the GDAL geotransform array and size

setTopLeftPixel(leftcol, toprow)[source]

Set row/col of the top/left pixel to display. Args are pixel row/column numbers

setWorldExtent(extent)[source]

Sets the world extent as a 4 element tuple

setZoomFactor(imgPixPerWinPix)[source]

Set the zoom to the given value of imgPixPerWinPix. Will then recalcBottomRight().

world2display(wldX, wldY)[source]

Convert world (x, y) to display coordinates. Returns a tuple of int values (x, y) in display coordinate system

world2pixel(x, y)[source]

Convert world x,y coordinates to raster row/col. Returns a tuple (col, row), as floats.

class tuiview.coordinatemgr.VectorCoordManager[source]

Manages coords for a vector layer

display2world(dspX, dspY)[source]

convert display coords to world coords

getFullWorldExtent()[source]

full extent of dataset

getWorldExtent()[source]

Get extent in world coords

recalc()[source]

Recalculate self.metersperpix Called when extents or display size changes

recalcBottomRight()[source]

I don’t think we need to do anything here

setDisplaySize(width, height)[source]

derived implementation - calls recalculates extent

setFullWorldExtent(extent)[source]

sets the full extent of dataset

setWorldExtent(extent)[source]

Set extent in world coords

world2display(wldX, wldY)[source]

convert world coords to display coords returns None if outside May have C implementation also. Not sure yet.