Class TranslatedGridCoverage


final class TranslatedGridCoverage extends DerivedGridCoverage
A grid coverage with the same data than the source coverage, with only a translation applied on grid coordinates.
Since:
1.3
Version:
1.3
  • Field Details

    • translation

      private final long[] translation
      The translation to apply on the argument given to render(GridExtent) before to delegate to the source. This is the conversion from this coverage to the source coverage.
  • Constructor Details

    • TranslatedGridCoverage

      private TranslatedGridCoverage(GridCoverage source, GridGeometry domain, long[] translation)
      Constructs a new grid coverage which will delegate the rendering operation to the given source. This coverage will take the same sample dimensions than the source. The domain size must be the same than the source grid geometry size.
      Parameters:
      source - the source on which to delegate rendering operations.
      domain - the grid extent, CRS and conversion from cell indices to CRS.
      translation - translation to apply on the argument given to render(GridExtent).
  • Method Details

    • create

      static GridCoverage create(GridCoverage source, GridGeometry domain, long[] translation, boolean allowSourceReplacement)
      Returns a grid coverage which will use the domain grid geometry. This coverage will take the same sample dimensions than the source.

      If domain is non-null, then it should have the same size than the source grid geometry size. If this is not the case, then this method returns null.

      Parameters:
      source - the source on which to delegate rendering operations.
      domain - the geometry of the grid coverage to return, or null for automatic.
      translation - translation to apply on the argument given to render(GridExtent).
      Returns:
      the coverage, or null if domain is non-null but does not have the expected size. May be the source returned as-is.
    • createConvertedValues

      protected final GridCoverage createConvertedValues(boolean converted)
      Returns a grid coverage that contains real values or sample values, depending if converted is true or false respectively. This method delegates to the source and wraps the result in a TranslatedGridCoverage with the same translation.
      Overrides:
      createConvertedValues in class GridCoverage
      Parameters:
      converted - true for a coverage containing converted values, or false for a coverage containing packed values.
      Returns:
      a new coverage containing converted or packed values, depending on converted argument value. May be this but never null.
    • render

      public RenderedImage render(GridExtent sliceExtent) throws CannotEvaluateException
      Returns a two-dimensional slice of grid data as a rendered image. This method translates the sliceExtent argument, then delegates to the source. It is okay to use the source result as-is because image coordinates are relative to the request; the rendered image shall not be translated.
      Specified by:
      render in class GridCoverage
      Parameters:
      sliceExtent - a subspace of this grid coverage extent where all dimensions except two have a size of 1 cell. May be null if this grid coverage has only two dimensions with a size greater than 1 cell.
      Returns:
      the grid slice as a rendered image. Image location is relative to sliceExtent.
      Throws:
      CannotEvaluateException - if this method cannot produce the rendered image for another reason.