Class DatumShiftGridFile.Float<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.DatumShiftGridFile.Float<C,T>
All Implemented Interfaces:
Serializable
Enclosing class:
DatumShiftGridFile<C extends javax.measure.Quantity<C>,T extends javax.measure.Quantity<T>>

static final class DatumShiftGridFile.Float<C extends javax.measure.Quantity<C>,T extends javax.measure.Quantity<T>> extends DatumShiftGridFile<C,T>
An implementation of DatumShiftGridFile which stores the offset values in float[] arrays. This class is in internal package (not public API) because it makes the following assumptions:
  • Values x₀, y₀, Δx and Δy given to the constructor are in degrees and needs to be converted to radians.
  • Single floating-point precision (float) is sufficient.
  • Values were defined in base 10, usually in ASCII files. This assumption has an impact on conversions from float to double performed by the getCellValue(int, int, int) method.
Since:
0.7
Version:
0.7
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      Serial number for inter-operability with different versions.
      See Also:
    • offsets

      final float[][] offsets
      The translation values. offsets.length is the number of dimensions, and offsets[dim].length shall be the same for all dim value. Component dim of the translation vector at coordinate gridX, gridY is offsets[dim][gridX + gridY*scanlineStride].
  • Constructor Details

    • Float

      Float(int dim, javax.measure.Unit<C> coordinateUnit, javax.measure.Unit<T> translationUnit, boolean isCellValueRatio, double x0, double y0, double Δx, double Δy, int nx, int ny, org.opengis.parameter.ParameterDescriptorGroup descriptor, Path... files) throws org.opengis.referencing.operation.NoninvertibleTransformException
      Creates a new datum shift grid with the given grid geometry, filename and number of shift dimensions. All double values given to this constructor will be converted from degrees to radians.
      Parameters:
      dim - number of dimensions of translation vectors.
      Throws:
      org.opengis.referencing.operation.NoninvertibleTransformException
    • Float

      private Float(DatumShiftGridFile<C,T> grid, float[][] offsets)
      Creates a new grid of the same geometry than the given grid but using a different data array.
  • Method Details

    • setData

      protected final DatumShiftGridFile<C,T> setData(Object[] other)
      Returns a new grid with the same geometry than this grid but different data arrays. This method is invoked by DatumShiftGridFile.useSharedData() when it detects that a newly created grid uses the same data than an existing grid. The other object is the old grid, so we can share existing data.
      Specified by:
      setData in class DatumShiftGridFile<C extends javax.measure.Quantity<C>,T extends javax.measure.Quantity<T>>
      Parameters:
      other - data from another DatumShiftGridFile that we can share.
      Returns:
      a new DatumShiftGridFile using the given data reference.
    • getData

      protected final Object[] getData()
      Returns direct references (not cloned) to the data arrays. This method is for cache management, DatumShiftGridFile.equals(Object) and DatumShiftGridFile.hashCode() implementations only and should not be invoked in other context.
      Specified by:
      getData in class DatumShiftGridFile<C extends javax.measure.Quantity<C>,T extends javax.measure.Quantity<T>>
      Returns:
      a direct (not cloned) reference to the internal data array.
    • getTranslationDimensions

      public final int getTranslationDimensions()
      Returns the number of shift dimensions.
      Specified by:
      getTranslationDimensions in class DatumShiftGrid<C extends javax.measure.Quantity<C>,T extends javax.measure.Quantity<T>>
      Returns:
      number of dimensions of translation vectors.
    • getCellValue

      public final double getCellValue(int dim, int gridX, int gridY)
      Returns the cell value at the given dimension and grid index. This method casts the float values to double by setting the extra decimal digits (not the binary digits) to 0. This is on the assumption that the float values were parsed from an ASCII file, or any other medium that format numbers in base 10.
      Specified by:
      getCellValue in class DatumShiftGrid<C extends javax.measure.Quantity<C>,T extends javax.measure.Quantity<T>>
      Parameters:
      dim - the dimension for which to get an average value.
      gridX - the grid index along the x axis, from 0 inclusive to nx exclusive.
      gridY - the grid index along the y axis, from 0 inclusive to ny exclusive.
      Returns:
      the offset at the given dimension in the grid cell at the given index.
    • getCellMean

      public double getCellMean(int dim)
      Returns the average translation parameters from source to target. There is no need to use double-double arithmetic here since all data have only single precision.
      Overrides:
      getCellMean in class DatumShiftGrid<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.