# Class ImageRequest

Object
ImageRequest

public class ImageRequest extends Object
A request for a two-dimensional view of a grid coverage. Those requests can be used for reading or rendering and image in a background thread.

Since:
  1.1
See Also:
  - `GridView​.setImage(ImageRequest)`
  - `CoverageExplorer​.setCoverage(ImageRequest)`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ImageRequest(GridCoverage source, GridExtent slice)`
  Creates a new request for loading an image from the specified coverage.
  `ImageRequest(GridCoverageResource source, GridGeometry domain, int... range)`
  Creates a new request for loading an image from the specified resource.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `final Optional<GridCoverage>`
  `getCoverage()`
  Returns the coverage specified at construction time, or an empty value if none.
  `final Optional<GridGeometry>`
  `getDomain()`
  Returns the desired grid extent and resolution, or an empty value for reading the full domain.
  `final Optional<int[]>`
  `getRange()`
  Returns the 0-based indices of sample dimensions to read, or an empty value for reading them all.
  `final Optional<GridCoverageResource>`
  `getResource()`
  Returns the resource specified at construction time, or an empty value if none.
  `final Optional<GridExtent>`
  `getSliceExtent()`
  Returns the subspace of the grid coverage extent to render.

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### ImageRequest

    public ImageRequest(GridCoverageResource source, GridGeometry domain, int... range)
    Creates a new request for loading an image from the specified resource. If `domain` and `range` arguments are null, then the full coverage will be loaded. For loading a smaller amount of data, sub-domain or sub-range can be specified as documented in the read method javadoc.
    Parameters:
      `source` - source of the image to load.
      `domain` - desired grid extent and resolution, or `null` for reading the whole domain.
      `range` - 0-based indices of sample dimensions to read, or `null` or an empty sequence for reading them all.
    See Also:
      - `GridCoverageResource​.read(GridGeometry, int...)`

  - ### ImageRequest

    public ImageRequest(GridCoverage source, GridExtent slice)
    Creates a new request for loading an image from the specified coverage. If the `sliceExtent` argument is null, then the full coverage will be rendered in the first two dimensions having a size greater than 1 cell. For rendering a smaller amount of data, or for rendering data along other dimensions, a slice extent can be specified as documented in the render method javadoc.
    Parameters:
      `source` - source of the image to load.
      `slice` - a subspace of the grid coverage extent to render, or `null` for the whole extent.
    See Also:
      - `GridCoverage​.render(GridExtent)`

- ## Method Details

  - ### getResource

    public final Optional<GridCoverageResource> getResource()
    Returns the resource specified at construction time, or an empty value if none.
    Returns:
      the resource to read.

  - ### getCoverage

    public final Optional<GridCoverage> getCoverage()
    Returns the coverage specified at construction time, or an empty value if none.
    Returns:
      the coverage to render.

  - ### getDomain

    public final Optional<GridGeometry> getDomain()
    Returns the desired grid extent and resolution, or an empty value for reading the full domain. This is the `domain` argument specified to the following constructor:

    > `ImageRequest(GridCoverageResource, GridGeometry, int[])`

    This argument will be forwarded verbatim to the following method (see its javadoc for more explanation):

    > `GridCoverageResource​.read(GridGeometry, int...)`

    This property is always empty if this image request has been created with the `ImageRequest(GridCoverage, GridExtent)` constructor, since no read operation will happen in such case.
    Returns:
      the desired grid extent and resolution of the coverage.

  - ### getRange

    public final Optional<int[]> getRange()
    Returns the 0-based indices of sample dimensions to read, or an empty value for reading them all. This is the `range` argument specified to the following constructor:

    > `ImageRequest(GridCoverageResource, GridGeometry, int[])`

    This argument will be forwarded verbatim to the following method (see its javadoc for more explanation):

    > `GridCoverageResource​.read(GridGeometry, int...)`

    This property is always empty if this image request has been created with the `ImageRequest(GridCoverage, GridExtent)` constructor, since no read operation will happen in such case.
    Returns:
      the 0-based indices of sample dimensions to read.

  - ### getSliceExtent

    public final Optional<GridExtent> getSliceExtent()
    Returns the subspace of the grid coverage extent to render. This is the `sliceExtent` argument specified to the following constructor:

    > `ImageRequest(GridCoverage, GridExtent)`

    This argument will be forwarded verbatim to the following method (see its javadoc for more explanation):

    > `GridCoverage​.render(GridExtent)`

    If non-empty, then all dimensions except two should have a size of 1 cell.
    Returns:
      subspace of the grid coverage extent to render.
    See Also:
      - `GridCoverage​.render(GridExtent)`