Class ResidualGrid

java.lang.Object
org.apache.sis.referencing.datum.DatumShiftGrid<javax.measure.quantity.Dimensionless,javax.measure.quantity.Dimensionless>
org.apache.sis.referencing.operation.builder.ResidualGrid
All Implemented Interfaces:
Serializable

final class ResidualGrid extends DatumShiftGrid<javax.measure.quantity.Dimensionless,javax.measure.quantity.Dimensionless>
The residuals after an affine approximation has been created for a set of matching control point pairs.
Since:
0.8
Version:
1.1
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      For cross-version compatibility.
      See Also:
    • SOURCE_DIMENSION

      static final int SOURCE_DIMENSION
      Number of source dimensions of the residual grid.
      See Also:
    • PARAMETERS

      private static final org.opengis.parameter.ParameterDescriptorGroup PARAMETERS
      The parameter descriptors for the "Localization grid" operation. Current implementation is fixed to 2 dimensions.
      See Also:
    • scanlineStride

      private final int scanlineStride
      Number of cells between the start of adjacent rows in the grid. This is usually getGridSize(0), stored as a field for performance reasons. Value could be greater than getGridSize(0) if there is some elements to ignore at the end of each row.
    • offsets

      private final float[] offsets
      The residual data, as translations to apply on the result of affine transform. In this flat array, index of target dimension varies fastest, then column index, then row index. Single precision instead of double is presumed sufficient because this array contains only differences, not absolute positions. Absolute positions will be computed by adding double values to those offsets.
    • gridToTarget

      final LinearTransform gridToTarget
      Conversion from translated coordinates (after the datum shift has been applied) to "real world" coordinates. If we were doing NADCON or NTv2 transformations with DatumShiftGrid.isCellValueRatio() = true (source and target coordinates in the same coordinate system with axis units in degrees), that conversion would be the inverse of DatumShiftGrid.getCoordinateToGrid(). But in this ResidualGrid case, we need to override with the linear regression computed by LocalizationGridBuilder.
    • accuracy

      private final double accuracy
      The best translation accuracy that we can expect from this file.
      See Also:
    • periodVector

      private final double[] periodVector
      If grid coordinates in some target dimensions are cyclic, the period in number of cells. For each scalar value in the LocalizationGridBuilder.periods array (in units of target CRS), the corresponding period in number of cells is a vector. For example, a 360° shift in longitude does not necessarily correspond to an horizontal or vertical offset in grid indices; it may be a combination of both if the grid is inclined.

      We should have as many vectors as non-zero values in LocalizationGridBuilder.periods. Each periodVector (in cell units) should be computed from a periods vector with exactly one non-zero value (in CRS units) for allowing shifts in different CRS dimensions to be applied independently. Consequently, this field should actually be of type double[][]. But current version uses only one vector for avoiding the complexity of searching how to combine multiple vectors. It is okay for the usual case where only one CRS axis has wraparound range, but may need to be revisited in the future.

      This array is null if no period has been specified, or if a period has been specified but we cannot convert it from CRS units to a constant number of cells.

      See Also:
  • Constructor Details

    • ResidualGrid

      ResidualGrid(LinearTransform sourceToGrid, LinearTransform gridToTarget, int nx, int ny, float[] residuals, double precision, double[] periods, ProjectedTransformTry linearizer) throws org.opengis.referencing.operation.TransformException
      Creates a new residual grid.
      Parameters:
      sourceToGrid - conversion from the "real world" source coordinates to grid indices including fractional parts.
      gridToTarget - conversion from grid coordinates to the final "real world" coordinates.
      residuals - the residual data, as translations to apply on the result of affine transform.
      precision - desired precision of inverse transformations in unit of grid cells.
      periods - if grid coordinates in some dimensions are cyclic, their periods in units of target CRS.
      linearizer - the linearizer that have been applied, or null if none.
      Throws:
      org.opengis.referencing.operation.TransformException
  • Method Details

    • getParameterValues

      public void getParameterValues(Parameters parameters)
      Sets the parameters of the InterpolatedTransform which uses that localization grid. The given parameters must have been created from PARAMETERS descriptor. This method sets the matrix parameters using views over the offsets array.
      Specified by:
      getParameterValues in class DatumShiftGrid<javax.measure.quantity.Dimensionless,javax.measure.quantity.Dimensionless>
      Parameters:
      parameters - the parameter group where to set the values.
    • getParameterDescriptors

      public org.opengis.parameter.ParameterDescriptorGroup getParameterDescriptors()
      Returns a description of the values in this grid. Grid values may be given as matrices or tensors. Current implementation provides values in the form of Matrix objects on the assumption that the number of grid dimensions is 2.
      Note: the number of grid dimensions determines the parameter type: if that number is greater than 2, then parameters would need to be represented by tensors instead than matrices. By contrast, the number of dimensions of translation vectors only determines how many matrix or tensor parameters appear.
      Specified by:
      getParameterDescriptors in class DatumShiftGrid<javax.measure.quantity.Dimensionless,javax.measure.quantity.Dimensionless>
      Returns:
      a description of the values in this grid.
    • getTranslationDimensions

      public int getTranslationDimensions()
      Returns the number of dimensions of the translation vectors interpolated by this shift grid.
      Specified by:
      getTranslationDimensions in class DatumShiftGrid<javax.measure.quantity.Dimensionless,javax.measure.quantity.Dimensionless>
      Returns:
      number of dimensions of translation vectors.
    • getCellPrecision

      public double getCellPrecision()
      Returns the desired precision in iterative calculation performed by inverse transform. The returned value is in unit of grid cell, i.e. a value of 1 is the size of one cell. This unit of measurement is fixed by DatumShiftGrid.isCellValueRatio() = true.
      Specified by:
      getCellPrecision in class DatumShiftGrid<javax.measure.quantity.Dimensionless,javax.measure.quantity.Dimensionless>
      Returns:
      an estimation of cell value precision.
    • getCellValue

      public double getCellValue(int dim, int gridX, int gridY)
      Returns the cell value at the given dimension and grid index. Those values are components of translation vectors.
      Specified by:
      getCellValue in class DatumShiftGrid<javax.measure.quantity.Dimensionless,javax.measure.quantity.Dimensionless>
      Parameters:
      dim - the dimension of the translation vector component to get, from 0 inclusive to DatumShiftGrid.getTranslationDimensions() exclusive.
      gridX - the grid index on the x axis, from 0 inclusive to gridSize[0] exclusive.
      gridY - the grid index on the y axis, from 0 inclusive to gridSize[1] exclusive.
      Returns:
      the translation for the given dimension in the grid cell at the given index.
    • replaceOutsideGridCoordinates

      protected void replaceOutsideGridCoordinates(double[] gridCoordinates)
      Invoked when a gridX or gridY coordinate is outside the range of valid grid coordinates. If the coordinate outside the range is a longitude value and if we handle those values as cyclic, brings that coordinate inside the range.
      Overrides:
      replaceOutsideGridCoordinates in class DatumShiftGrid<javax.measure.quantity.Dimensionless,javax.measure.quantity.Dimensionless>
      Parameters:
      gridCoordinates - on input, the cell indices of the point which is outside the grid. On output, the cell indices of an equivalent point inside the grid if possible. Coordinate values are modified in-place.
      See Also:
    • equals

      public boolean equals(Object other)
      Returns true if the given object is a grid containing the same data than this grid.
      Overrides:
      equals in class DatumShiftGrid<javax.measure.quantity.Dimensionless,javax.measure.quantity.Dimensionless>
      Parameters:
      other - the other object to compare with this datum shift grid.
      Returns:
      true if the given object is non-null, of the same class than this DatumShiftGrid and contains the same data.
    • hashCode

      public int hashCode()
      Returns a hash code value for this datum shift grid.
      Overrides:
      hashCode in class DatumShiftGrid<javax.measure.quantity.Dimensionless,javax.measure.quantity.Dimensionless>
      Returns:
      a hash code based on metadata.