ValueGrid

Description

sealed class Tinman.Terrain.Georef.ValueGrid

Derived from

SerializableBase abstract

The ValueGrid class represents an axis-aligned grid of evenly spaced points in a geographic coordinate system, to provide correction values (such as height offsets) for interpolation by specific IDatumTransform implementations.

Each grid point stores a tuple of one or more correction values. A grid cell may also have an undefined tuple. The geographic coordinates of each grid point may be inferred from the grid bounds, the row and column counts and the grid coordinates of the point. Here is an example for a 5x4 grid:

  0   1   2   3   4
0 #---#---#---#---#   \
  |   |   |   |   |   | # := regular tuple
1 #---#---#---#---#   | o := undefined tuple
  |   |   | x |   |   |
2 o---#---#---#---#   | 4 tuple rows
  |   |   |   |   |   | y := latitude
3 o---o---#---#---#   /

  \_______________/
   5 tuple columns
   x := longitude

The grid point (0|0) corresponds to LatLonRange.Start of Bounds and (4|3) corresponds to LatLonRange.End. The point x at (2.5|1.5) can be interpolated from the surrounding grid points (2|1), (3|1), (2|2) and (3|2). If one or more of the surrounding grid points have an undefined value, the interpolated value will also be undefined.

Public / Constructors

From​Array


public static method FromArray → (9)

geographic in : CoordinateSystem

[not-null]
See Geographic.

bounds in : LatLonRange

See Bounds.

gridSize in : Vec2I

See GridSize.

tupleSize in : int32

[>=1]
See TupleSize.

values in : float64 [ ]

[not-null]
An array that holds the grid point tuple values.

offset in : int32

[0..values.Length]
Offset into values in to the grid point at (0|0).

rowStride in : int32

The array index offset from grid point (X|Y) to (X|Y+1).

columnStride opt : int32 = 1

The array index offset from grid point (X|Y) to (X+1|Y).

tupleStride opt : int32 = 1

The array index offset from one grid point tuple value to the next one.

returns → ValueGrid

The created ValueGrid object.

Creates a new instance of ValueGrid.

For the grid point at (X|Y), the given values in array is indexed as follows:

values[offset + Y * rowStride + X * columnStride + index * tupleStride]

where index if the zero-based tuple value index. If the computed array index is outside the array bounds, the value Maths.NanD is used. If a value in the array is not a regular number (see Maths.IsNumber), it will also be replaced by Maths.NanD.

From​File


public static method FromFile → (6)

geographic in : CoordinateSystem

[not-null]
See Geographic.

textFile in : Path

[not-null]
Path to the text file.

tupleSize opt : int32 = 1

[>=1]
The tuple size. Parsing will stop (i.e. ignoring the remainder of the current line) when enough values have been read. If a line contains not enough values, Maths.NanD is used instead.

format opt : int32 = 0

A set of flags for configuring the file format (see FromText).

noData opt : float64 = Maths.MinDouble

The special value that is used to represent points with no value data.

tolerance opt : float64 = 1E-6

The maximum error (in degrees) to tolerate (see FromText).

returns → ValueGrid

The created ValueGrid object.

Builds a ValueGrid from a text file that contains grid point data.

This method delegates to FromText, after reading textFile in with Path.ReadAllText.

ValidatingException

If textFile in is malformed.

IOException

If an I/O error has occurred.

From​Text


public static method FromText → (6)

geographic in : CoordinateSystem

[not-null]
See Geographic.

pointList in : string

[not-null]
The textual point list (see remarks).

tupleSize opt : int32 = 1

[>=1]
The tuple size. Parsing will stop (i.e. ignoring the remainder of the current line) when enough values have been read. If a line contains not enough values, Maths.NanD is used instead.

format opt : int32 = 0

A set of flags for configuring the file format:
0x01 : flip geographic coordinates (i.e. longitude, latitude).

noData opt : float64 = Maths.MinDouble

The special value that is used to represent points with no value data.

tolerance opt : float64 = 1E-6

The maximum error (in degrees) to tolerate. The regular grid defines positions implicitly. The error is defined as the absolute difference between a point in the list and its nearest grid point.

returns → ValueGrid

The created ValueGrid object.

Builds a ValueGrid from a text file that contains grid point data.

The given point list text is read line-by-line. Empty and whitespace-only lines are ignored. Each line of text must have the following format:

   One or more characters that classify as whitespace
   |
1.1 2.2 3.3 4.4 ...
|   |   |   |   \__ Additional tuple values (index >=2)
|   |   |   \__ Second tuple value (index 1)
|   |   \__ First tuple value (index 0)
|   \__ Second geographic coordinate (default: longitude)
\__ First geographic coordinate (default: latitude)

After consuming the point list, this method delegates to FromArray to build the value grid.

ValidatingException

If pointList in is malformed or some points do not lie within the given tolerance opt.

Public / Methods

Coordinates

3 overloads


[Pure]
public method Coordinates1 → (2)

in : int32

The X-coordinate of the grid point.

in : int32

The Y-coordinate of the grid point.

returns → LatLon

The geographic coordinates.

Computes the coordinates of a grid point.


[Pure]
public method Coordinates2 → (1)

coordinates in : LatLon

The geographic coordinates of the grid point.

returns → Vec2D

The grid coordinates.

Computes the coordinates of a grid point.


[Pure]
public method Coordinates3 → (2)

latitude in : float64

The geographic latitude in degrees.

longitude in : float64

The geographic longitude in degrees.

returns → Vec2D

The grid coordinates.

Computes the coordinates of a grid point.

Interpolate


[Pure]
public method Interpolate → (2)

grid in : Vec2D

The grid coordinates.

index opt : int32 = 0

The zero-based value index.

returns → float64

The interpolated value or Maths.NanD if index opt is not a valid value index (see TupleSize or if one or more surrounding grid points have undefined values.

Interpolates the value at the given geographic coordinates.

Interpolate2


[Pure]
public method Interpolate2 → (2)

grid in : Vec2D

The grid coordinates.

index opt : int32 = 0

The zero-based value index.

returns → Vec2D

The interpolated values:
Vec2D.X : for index opt
Vec2D.Y : for index opt + 1

Interpolates the values at the given geographic coordinates.

This method behaves like Interpolate for each component of the returned vector.

Interpolate3


[Pure]
public method Interpolate3 → (2)

grid in : Vec2D

The grid coordinates.

index opt : int32 = 0

The zero-based value index.

returns → Vec3D

The interpolated values:
Vec3D.X : for index opt
Vec3D.Y : for index opt + 1
Vec3D.Z : for index opt + 2

Interpolates the values at the given geographic coordinates.

This method behaves like Interpolate for each component of the returned vector.

Interpolate4


[Pure]
public method Interpolate4 → (2)

grid in : Vec2D

The grid coordinates.

index opt : int32 = 0

The zero-based value index.

returns → Vec4D

The interpolated values:
Vec4D.X : for index opt
Vec4D.Y : for index opt + 1
Vec4D.Z : for index opt + 2
Vec4D.W : for index opt + 3

Interpolates the values at the given geographic coordinates.

This method behaves like Interpolate for each component of the returned vector.

Range


[Constant]
public method Range → (1)

index opt : int32 = 0

[0..ValueGrid.TupleSize-1]
The value index.

returns → RangeD

The value range.

Returns the range of the given grid point tuple values.

Value


[Pure]
public method Value → (3)

in : int32

The X-coordinate of the grid point.

in : int32

The Y-coordinate of the grid point.

index opt : int32 = 0

The zero-based value index.

returns → float64

The grid point tuple value or Maths.NanD if the value is undefined or any of in, in and index opt is out of range.

Returns a value of a grid point.

Public / Attributes

Bounds


[Constant]
public attribute Bounds → (get)

value : LatLonRange

The geographic bounds.

The geographic bounds of the grid.

Geographic


[Constant]
public attribute Geographic → (get)

value : CoordinateSystem

[not-null]
The geographic coordinate system.

The geographic coordinate system of the grid.

The ValueGrid class works with latitude and longitude angles in degrees. So, CoordinateSystem.HorizontalUnit and CoordinateSystem.Flags need to be applied (for example, via ICoordinateTransform.GeographicToMap).

Grid​Size


[Constant]
public attribute GridSize → (get)

value : Vec2I

Vec2I.X : the column count,
Vec2I.Y : the row count

The row and column counts of the grid.

Grid​Step


[Constant]
public attribute GridStep → (get)

value : LatLon

The step distance.

The step distance between adjacent grid points.

Tuple​Size


[Constant]
public attribute TupleSize → (get)

value : int32

[>=1]
The tuple size.

The size of the value tuple of a grid point.

Serialization

Serial​Id


public static readonly attribute SerialId → (ISerialTypeInfo)

Serialization information about this type.