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 (usuallyAngle
orLength
).
- 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 betweenaverages
values and the actual value.private final double
private static final long
Serial number for inter-operability with different versions.Fields inherited from class org.apache.sis.internal.referencing.provider.DatumShiftGridFile
accuracy, CACHE, scanlineStride, subgrids
Fields inherited from class org.apache.sis.referencing.datum.DatumShiftGrid
INTERPOLATED_DIMENSIONS
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
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 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.boolean
Returnstrue
if the given object is a grid containing the same data than this grid.double
getCellMean
(int dim) Returns the average translation parameters from source to target.double
Suggests a precision for the translation values in this grid.double
getCellValue
(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 int
Returns the number of shift dimensions.int
hashCode()
Returns a hash code value for this datum shift grid.void
interpolateInCell
(double gridX, double gridY, double[] vector) Copy ofDatumShiftGrid
rewritten 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, useSharedData
Methods 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 givengrid
unchanged.- Parameters:
grid
- the grid to compress.averages
- an "average" value for the offset in each dimension, ornull
if 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. Theother
object 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:
getCellPrecision
in 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:
getTranslationDimensions
in 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:
getCellMean
in 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:
getCellValue
in 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 ofDatumShiftGrid
rewritten in a way that reduce the number of arithmetic operations for efficiency reasons.- Overrides:
interpolateInCell
in 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
Returnstrue
if the given object is a grid containing the same data than this grid.- Overrides:
equals
in 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:
true
if the given object is non-null, an instance ofDatumShiftGridCompressed
and contains the same data.
-
hashCode
public int hashCode()Returns a hash code value for this datum shift grid.
-