Class TiledGridCoverage.TileIterator

Enclosing class:
Tiled­Grid­Coverage

protected final class TiledGridCoverage.TileIterator extends TiledGridCoverage.AOI
An iterator over the tiles to read. Instances of this class are computed by Tiled­Grid­Coverage​.render(Grid­Extent) and given to Tiled­Grid­Coverage​.read­Tiles(Tile­Iterator). The latter is the method that subclasses need to override.
Since:
1.7
  • Field Details

  • Method Details

    • getFullRegionInResourceCoordinates

      public GridExtent getFullRegionInResourceCoordinates()
      Returns the extent of the full region to read (all tiles) in units of the originating resource. The returned extent does not change during the iteration process (this method is not available in Tiled­Grid­Coverage​.Snapshot for that reason). This method is typically invoked only at the beginning of the iteration process, when knowing in advance the full read region allows some optimizations.

      The returned region is based on the user's request in her/his call to Tiled­Grid­Coverage​.render(Grid­Extent), but is not necessarily identical. The render method may have expanded or clipped the user's request. The returned extent may be larger than the actual resource extent because it may be rounded to an integer number of chunks.

      Returns:
      extent of all tiles to be traversed by this iterator, in units of the originating resource.
    • resourceToImage

      public Rectangle resourceToImage(Rectangle bounds, boolean tight)
      Converts cell coordinates from the originating resource to pixel coordinates. If tight is true, this method returns the smallest bounding box of interest for a reader which will apply subsampling. See image­To­Resource(Rectangle, boolean) for a discussion of the trade-off.
      Parameters:
      bounds - the coordinates to convert.
      tight - whether to return the smallest bounding box.
      Returns:
      the converted coordinates.
      Throws:
      Arithmetic­Exception - if the result cannot be expressed as 32-bits integers.
    • imageToResource

      public Rectangle imageToResource(Rectangle bounds, boolean tight)
      Converts cell coordinates from pixel coordinates to the originating resource. If tight is true, this method returns the smallest bounding box of interest for a reader which will apply subsampling. If false, this method uses a more straightforward calculation which may result in a larger bounding box, with right and bottom areas possibly containing pixels that should be skipped by subsampling.

      The latter case is sometime desirable when the caller may compute scale factors as the ratio of the size of different rectangles. For such calculations, tight bounding boxes may be confusing.

      Parameters:
      bounds - the coordinates to convert.
      tight - whether to return the smallest bounding box, at the cost of less straightforward rectangle size.
      Returns:
      the image coordinates converted to resource coordinates.
      Throws:
      Arithmetic­Exception - if the result cannot be expressed as 32-bits integers.
    • next

      public boolean next()
      Moves the iterator position to next tile. This method should be invoked in a loop as below:
      do {
          // Process current tile.
      } while (domain.next());
      
      Returns:
      true on success, or false if the iteration is finished.