Click or drag to resize

InterpolatingConverter Class

Class for performing a conversion inside a user specified area. It utilizes bilinear interpolation on a grid of pre-converted values.

The assumption is that the original conversion is fairly expensive, and accuracy is not as important as performance.

The conversion is pre-calculated on a grid inside the user specified area. The original expensive conversion will only be performed initially to create the pre-calculated grid values.

The accuracy of the bilinear interpolation depends on the grid spacing and the original conversion. The more non-linear the original conversion is, the smaller a grid spacing is required to get the same accuracy. Typical values of grid spacing dx to get app. 1 m accuracy:

  • Convert projection coordinates to another datum : dx ~ 100.000 m
  • Convert projection coordinates between two neighbouring UTM zones: dx ~ 10.000 m
  • Convert between geo and UTM projection coordinates at equator: dx ~ 20.000
  • Convert between geo and UTM projection coordinates at latitude ~ 55: dx ~ 5.000

Inheritance Hierarchy
SystemObject
  DHI.ProjectionsInterpolatingConverter

Namespace:  DHI.Projections
Assembly:  DHI.Projections (in DHI.Projections.dll) Version: 19.0.0.0 (11.1.1.1111)
Syntax
public class InterpolatingConverter

The InterpolatingConverter type exposes the following members.

Constructors
  NameDescription
Public methodInterpolatingConverter
Create new object
Top
Methods
  NameDescription
Public methodCalculateErrorEstimate
Calculate an estimate of the largest error for the provided dx and dy. The error estimate is calculated in the center of the domain, which may not be representative for the entire domain, so the error estimate is usually lower than the actual largest error.
Public methodCalculateGridSizeFromErrorEstimate
Calculate and return a grid size estimate based on a max error. This only returns an indication, the actual error will usually be larger than the max error, for the returned grid size.

Grid size cannot be larger than extent of area in x and y direction.

Public methodConvert
Convert the (x,y) coordinate
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodInitialize
Initialize buffer grid
Public methodSetupArea
Setup the region that the buffer should cover. You must also call SetupGridSize(Int32, Int32) or SetupGridSpacing(Double, Double).
Public methodSetupGrid
Setup manually region and buffer grid size
Public methodSetupGridSize
Set up the size of the pre-calculated grid.

Call first SetupArea(Double, Double, Double, Double) before calling this

Public methodSetupGridSpacing
Set up the grid spacing of the pre-calculated grid

Call first SetupArea(Double, Double, Double, Double) before calling this

Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Examples
The InterpolatingConverterConversion delegate must be set up. To use a reprojector object as the original conversion, do:
// Setup converter to use reprojector
Reprojector reprojector = new Reprojector(sourceProjection, targetProjection);
GridBufferConverter.Conversion conversion
    = delegate(ref double x, ref double y)
        {
          reprojector.Convert(ref x, ref y);
        };
GridBufferConverter converter = new GridBufferConverter(conversion);
// Define the area to work on and the size of the pre-calculated grid
converter.SetupArea(x0, y0, x1, y1);
converter.SetupGridSize(xCount, yCount);
converter.Initialize();

// Converter is now ready for use
converter.Convert(ref x, ref y);
See Also