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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate final class
View over one target dimension of the localization grid. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final double
The best translation accuracy that we can expect from this file.(package private) final LinearTransform
Conversion from translated coordinates (after the datum shift has been applied) to "real world" coordinates.private final float[]
The residual data, as translations to apply on the result of affine transform.private static final org.opengis.parameter.ParameterDescriptorGroup
The parameter descriptors for the "Localization grid" operation.private final double[]
If grid coordinates in some target dimensions are cyclic, the period in number of cells.private final int
Number of cells between the start of adjacent rows in the grid.private static final long
For cross-version compatibility.(package private) static final int
Number of source dimensions of the residual grid.Fields inherited from class org.apache.sis.referencing.datum.DatumShiftGrid
INTERPOLATED_DIMENSIONS
-
Constructor Summary
ConstructorsConstructorDescriptionResidualGrid
(LinearTransform sourceToGrid, LinearTransform gridToTarget, int nx, int ny, float[] residuals, double precision, double[] periods, ProjectedTransformTry linearizer) Creates a new residual grid. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returnstrue
if the given object is a grid containing the same data than this grid.double
Returns the desired precision in iterative calculation performed by inverse transform.double
getCellValue
(int dim, int gridX, int gridY) Returns the cell value at the given dimension and grid index.org.opengis.parameter.ParameterDescriptorGroup
Returns a description of the values in this grid.void
getParameterValues
(Parameters parameters) Sets the parameters of theInterpolatedTransform
which uses that localization grid.int
Returns the number of dimensions of the translation vectors interpolated by this shift grid.int
hashCode()
Returns a hash code value for this datum shift grid.protected void
replaceOutsideGridCoordinates
(double[] gridCoordinates) Invoked when agridX
orgridY
coordinate is outside the range of valid grid coordinates.Methods inherited from class org.apache.sis.referencing.datum.DatumShiftGrid
derivativeInCell, getCellMean, getCoordinateToGrid, getCoordinateUnit, getDomainOfValidity, getDomainOfValidity, getGridSize, getGridSize, getTranslationUnit, interpolateAt, interpolateInCell, isCellInGrid, isCellValueRatio, toString
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDFor cross-version compatibility.- See Also:
-
SOURCE_DIMENSION
static final int SOURCE_DIMENSIONNumber of source dimensions of the residual grid.- See Also:
-
PARAMETERS
private static final org.opengis.parameter.ParameterDescriptorGroup PARAMETERSThe parameter descriptors for the "Localization grid" operation. Current implementation is fixed to 2 dimensions.- See Also:
-
scanlineStride
private final int scanlineStrideNumber of cells between the start of adjacent rows in the grid. This is usuallygetGridSize(0)
, stored as a field for performance reasons. Value could be greater thangetGridSize(0)
if there is some elements to ignore at the end of each row. -
offsets
private final float[] offsetsThe 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 addingdouble
values to those offsets. -
gridToTarget
Conversion from translated coordinates (after the datum shift has been applied) to "real world" coordinates. If we were doing NADCON or NTv2 transformations withDatumShiftGrid.isCellValueRatio()
=true
(source and target coordinates in the same coordinate system with axis units in degrees), that conversion would be the inverse ofDatumShiftGrid.getCoordinateToGrid()
. But in thisResidualGrid
case, we need to override with the linear regression computed byLocalizationGridBuilder
. -
accuracy
private final double accuracyThe best translation accuracy that we can expect from this file.- See Also:
-
periodVector
private final double[] periodVectorIf grid coordinates in some target dimensions are cyclic, the period in number of cells. For each scalar value in theLocalizationGridBuilder.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
. EachperiodVector
(in cell units) should be computed from aperiods
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 typedouble[][]
. 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, ornull
if none.- Throws:
org.opengis.referencing.operation.TransformException
-
-
Method Details
-
getParameterValues
Sets the parameters of theInterpolatedTransform
which uses that localization grid. The givenparameters
must have been created fromPARAMETERS
descriptor. This method sets the matrix parameters using views over theoffsets
array.- Specified by:
getParameterValues
in classDatumShiftGrid<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 ofMatrix
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 classDatumShiftGrid<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 classDatumShiftGrid<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 byDatumShiftGrid.isCellValueRatio()
=true
.- Specified by:
getCellPrecision
in classDatumShiftGrid<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 classDatumShiftGrid<javax.measure.quantity.Dimensionless,
javax.measure.quantity.Dimensionless> - Parameters:
dim
- the dimension of the translation vector component to get, from 0 inclusive toDatumShiftGrid.getTranslationDimensions()
exclusive.gridX
- the grid index on the x axis, from 0 inclusive togridSize[0]
exclusive.gridY
- the grid index on the y axis, from 0 inclusive togridSize[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 agridX
orgridY
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 classDatumShiftGrid<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
Returnstrue
if the given object is a grid containing the same data than this grid.- Overrides:
equals
in classDatumShiftGrid<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 thisDatumShiftGrid
and contains the same data.
-
hashCode
public int hashCode()Returns a hash code value for this datum shift grid.- Overrides:
hashCode
in classDatumShiftGrid<javax.measure.quantity.Dimensionless,
javax.measure.quantity.Dimensionless> - Returns:
- a hash code based on metadata.
-