IMapProjection

Description

interface Tinman.Terrain.Mapping.IMapProjection

Extended by

MapProjectionBase abstract

Base interface for classes that provide a projection method between two dataset spaces.

Depending on the map type of a dataset, the dataset space is defined as follows:

  • MapType.Rect:
    Dataset coordinates are two-dimensional: (x,y), where x resp. y must lie within the range [0..width-1] resp. [0..height-1], where width and height are the dataset width and height, given in dataset samples.

  • MapType.Cube:
    Dataset coordinates are three-dimensional: (x,y,z), where x, y and z represent cubemap coordinates (see Cubemap). Cubemap coordinates will wrap around at the cubemap edges.

A dataset has a certain pixel coverage semantic (see MapInfo.Coverage). Raster space (as defined by MapInfo) is defined per cubemap face, taking into account the dataset sample coverage semantic.

Interpolation of a dataset sample S at coordinates (x,y) follows these rules:

(x0,y0)   (x1,y0)   x0 := floor(x)
   A---------B      y0 := floor(y)
   |         |      x1 := floor(x) + 1
   |    S    |      y1 := floor(y) + 1
   |  (x,y)  |
   C---------D      fx := x - floor(x)
(x0,y1)   (x2,y1)   fy := y - floor(y)

(x,y) := Coordinates of sample in raster space:
         0 <= x <= raster width
         0 <= y <= raster height

Linear interpolation of the sample S at (x,y) would then be performed as:

S :=   (A * (1-fx) + B * fx) * (1-fy)
     + (C * (1-fx) + D * fx) * fy

Wrapping (according to values of SourceWrapX, SourceWrapY, TargetWrapX and TargetWrapY) must be performed by the class that implements IMapProjection in these cases:

  • x0 is less than zero.

  • y0 is less than zero.

  • x1 is greater than the raster width.

  • y1 is greater than the raster height.

Since IMapProjection instances operate on dataset coordinates, pixel coverage offsets must be applied by implementors (see MapInfo.Coverage).

It may not be possible to project a given set of dataset coordinates to the target dataset space. In this case, the projection methods will return an undefined vector (see Vec3D.IsUndefined).

Public / Methods

Reverse


public method Reverse → ()

returns → IMapProjection

The reverse map projection.

Returns the reverse map projection.

Transform

2 overloads


public method Transform1 → (3)

in : float64

Source dataset X-coordinate.

in : float64

Source dataset Y-coordinate.

in : float64

Source dataset Z-coordinate. Only used if source raster is a cubemap (see MapInfo.Type). Will be ignored otherwise.

returns → Vec3D

The target dataset coordinates. Vec3D.Z will be zero if target raster is not a cubemap (see MapInfo.Type). In case that the projection cannot be performed, Vec3D.Undefined is returned.

Transform the given dataset coordinates.


public method Transform2 → (4)

in : float64

Source dataset X-coordinate.

in : float64

Source dataset Y-coordinate.

in : float64

Source dataset Z-coordinate.

in : float64

Source dataset height value.

returns → Vec4D

The target dataset coordinates. Vec3D.Z will be zero if target raster is not a cubemap (see MapInfo.Type). The target dataset height value is stored in Vec4D.W. In case that the projection cannot be performed, Vec4D.Undefined is returned.

Transform the given raster coordinates.

Public / Attributes

Source


public attribute Source → (get)

value : MapInfo

The source raster.

The source raster definition.

SourceWrapX


public attribute SourceWrapX → (get)

value : MapWrap

The wrapping behaviour.

The source raster wrapping behaviour along the map X-axis.

Wrapping is only applied to rectangular maps (see MapInfo.Type).

SourceWrapY


public attribute SourceWrapY → (get)

value : MapWrap

The wrapping behaviour.

The source raster wrapping behaviour along the map Y-axis.

Wrapping is only applied to rectangular maps (see MapInfo.Type).

Target


public attribute Target → (get)

value : MapInfo

The target raster.

The target raster definition.

TargetWrapX


public attribute TargetWrapX → (get)

value : MapWrap

The wrapping behaviour.

The target raster wrapping behaviour along the map X-axis.

Wrapping is only applied to rectangular maps (see MapInfo.Type).

TargetWrapY


public attribute TargetWrapY → (get)

value : MapWrap

The wrapping behaviour.

The target raster wrapping behaviour along the map Y-axis.

Wrapping is only applied to rectangular maps (see MapInfo.Type).

Extensions

Append


public static method Append → (1)

other in : IMapProjection

[not-null]
The map projection to append to this one.

returns → IMapProjection

The resulting map projection.

Appends the given map projection to this one.

This method does not check if the output coordinates of this projection have the same meaning as the input coordinates of other in; the calling code must make sure that the resulting projection has a correct meaning.

IsFromTo


public static method IsFromTo → (2)

source in : MapType

The source raster type.

target in : MapType

The target raster type.

returns → bool

true if the map projection transforms from source in to target in, false if not.

Checks if this map projection has the given source and target raster types.

Transform

2 overloads


public static method Transform1 → (1)

in : Vec3D

Source dataset coordinates. Vec3D.Z is only used if source raster is a cubemap (see MapInfo.Type). Will be ignored otherwise.

returns → Vec3D

The target dataset coordinates. Vec3D.Z will be zero if target raster is not a cubemap (see MapInfo.Type). In case that the projection cannot be performed, Vec3D.Undefined is returned.

Transform the given dataset coordinates.


public static method Transform2 → (1)

in : Vec4D

Source dataset coordinates and height value. Vec4D.Z is only used if source raster is a cubemap (see MapInfo.Type). Will be ignored otherwise. Vec4D.W is the source dataset height value.

returns → Vec4D

The target dataset coordinates. Vec3D.Z will be zero if target raster is not a cubemap (see MapInfo.Type). The target dataset height value is stored in Vec4D.W. In case that the projection cannot be performed, Vec4D.Undefined is returned.

Transform the given raster coordinates.