Class DatumShiftGridCompressed<C extends javax.measure.Quantity<C>,T extends javax.measure.Quantity<T>>
java.lang.Object
org.apache.sis.referencing.datum.DatumShiftGrid<C,T>
org.apache.sis.internal.referencing.provider.DatumShiftGridFile<C,T>
org.apache.sis.internal.referencing.provider.DatumShiftGridCompressed<C,T>
- Type Parameters:
C- dimension of the coordinate unit (usuallyAngle).T- dimension of the translation unit (usuallyAngleorLength).
- All Implemented Interfaces:
Serializable
final class DatumShiftGridCompressed<C extends javax.measure.Quantity<C>,T extends javax.measure.Quantity<T>>
extends DatumShiftGridFile<C,T>
A datum shift grid which store the values in
short[] array.
In addition to using half the space of float[] arrays, it can also (ironically)
increase the precision in the common case where the shifts are specified with no more than
5 digits in base 10 in ASCII files.- Since:
- 0.7
- Version:
- 1.1
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.sis.internal.referencing.provider.DatumShiftGridFile
DatumShiftGridFile.Double<C extends javax.measure.Quantity<C>,T extends javax.measure.Quantity<T>>, DatumShiftGridFile.Float<C extends javax.measure.Quantity<C>, T extends javax.measure.Quantity<T>> -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final double[]An "average" value for the offset in each dimension.private final short[][]Differences betweenaveragesvalues and the actual value.private final doubleprivate static final longSerial number for inter-operability with different versions.Fields inherited from class org.apache.sis.internal.referencing.provider.DatumShiftGridFile
accuracy, CACHE, scanlineStride, subgridsFields inherited from class org.apache.sis.referencing.datum.DatumShiftGrid
INTERPOLATED_DIMENSIONS -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateDatumShiftGridCompressed(DatumShiftGridFile<C, T> grid, double[] averages, short[][] data, double scale) Creates a new datum shift grid for the same geometry than the given grid but different data. -
Method Summary
Modifier and TypeMethodDescription(package private) static <C extends javax.measure.Quantity<C>,T extends javax.measure.Quantity<T>>
DatumShiftGridFile<C,T> compress(DatumShiftGridFile.Float<C, T> grid, double[] averages, double scale) Tries to compress the given grid.booleanReturnstrueif the given object is a grid containing the same data than this grid.doublegetCellMean(int dim) Returns the average translation parameters from source to target.doubleSuggests a precision for the translation values in this grid.doublegetCellValue(int dim, int gridX, int gridY) Returns the cell value at the given grid index.protected final Object[]getData()Returns direct references (not cloned) to the data arrays.final intReturns the number of shift dimensions.inthashCode()Returns a hash code value for this datum shift grid.voidinterpolateInCell(double gridX, double gridY, double[] vector) Copy ofDatumShiftGridrewritten in a way that reduce the number of arithmetic operations for efficiency reasons.protected final DatumShiftGridFile<C,T> Returns a new grid with the same geometry than this grid but different data arrays.Methods inherited from class org.apache.sis.internal.referencing.provider.DatumShiftGridFile
castTo, createGeodeticTransformation, getParameterDescriptors, getParameterValues, replaceOutsideGridCoordinates, setSubGrids, toString, useSharedDataMethods inherited from class org.apache.sis.referencing.datum.DatumShiftGrid
derivativeInCell, getCoordinateToGrid, getCoordinateUnit, getDomainOfValidity, getDomainOfValidity, getGridSize, getGridSize, getTranslationUnit, interpolateAt, isCellInGrid, isCellValueRatio
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDSerial number for inter-operability with different versions.- See Also:
-
averages
private final double[] averagesAn "average" value for the offset in each dimension.- See Also:
-
data
private final short[][] data -
scale
private final double scale
-
-
Constructor Details
-
DatumShiftGridCompressed
private DatumShiftGridCompressed(DatumShiftGridFile<C, T> grid, double[] averages, short[][] data, double scale) Creates a new datum shift grid for the same geometry than the given grid but different data.
-
-
Method Details
-
compress
static <C extends javax.measure.Quantity<C>,T extends javax.measure.Quantity<T>> DatumShiftGridFile<C,T> compress(DatumShiftGridFile.Float<C, T> grid, double[] averages, double scale) Tries to compress the given grid. If this operation succeed, a new grid is returned. Otherwise this method returns the givengridunchanged.- Parameters:
grid- the grid to compress.averages- an "average" value for the offset in each dimension, ornullif unknown.scale- the factor by which to multiply each compressed value before to add to the average value.- Returns:
- the grid to use (may or may not be compressed).
-
setData
Returns a new grid with the same geometry than this grid but different data arrays. This method is invoked byDatumShiftGridFile.useSharedData()when it detects that a newly created grid uses the same data than an existing grid. Theotherobject is the old grid, so we can share existing data. -
getCellPrecision
public double getCellPrecision()Suggests a precision for the translation values in this grid.- Overrides:
getCellPrecisionin classDatumShiftGridFile<C extends javax.measure.Quantity<C>,T extends javax.measure.Quantity<T>> - Returns:
- a precision for the translation values in this grid.
-
getData
Returns direct references (not cloned) to the data arrays. This method is for cache management,equals(Object)andhashCode()implementations only and should not be invoked in other context. -
getTranslationDimensions
public final int getTranslationDimensions()Returns the number of shift dimensions.- Specified by:
getTranslationDimensionsin classDatumShiftGrid<C extends javax.measure.Quantity<C>,T extends javax.measure.Quantity<T>> - Returns:
- number of dimensions of translation vectors.
-
getCellMean
public double getCellMean(int dim) Returns the average translation parameters from source to target.- Overrides:
getCellMeanin classDatumShiftGrid<C extends javax.measure.Quantity<C>,T extends javax.measure.Quantity<T>> - Parameters:
dim- the dimension for which to get an average value.- Returns:
- a value close to the average for the given dimension.
-
getCellValue
public double getCellValue(int dim, int gridX, int gridY) Returns the cell value at the given grid index.- Specified by:
getCellValuein classDatumShiftGrid<C extends javax.measure.Quantity<C>,T extends javax.measure.Quantity<T>> - 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.
-
interpolateInCell
public void interpolateInCell(double gridX, double gridY, double[] vector) Copy ofDatumShiftGridrewritten in a way that reduce the number of arithmetic operations for efficiency reasons.- Overrides:
interpolateInCellin classDatumShiftGrid<C extends javax.measure.Quantity<C>,T extends javax.measure.Quantity<T>> - Parameters:
gridX- first grid coordinate of the point for which to get the translation.gridY- second grid coordinate of the point for which to get the translation.vector- a pre-allocated array where to write the translation vector.- See Also:
-
equals
Returnstrueif the given object is a grid containing the same data than this grid.- Overrides:
equalsin classDatumShiftGridFile<C extends javax.measure.Quantity<C>,T extends javax.measure.Quantity<T>> - Parameters:
other- the other object to compare with this datum shift grid.- Returns:
trueif the given object is non-null, an instance ofDatumShiftGridCompressedand contains the same data.
-
hashCode
public int hashCode()Returns a hash code value for this datum shift grid.
-