Class TileOrganizer

java.lang.Object
org.apache.sis.internal.referencing.j2d.TileOrganizer

public class TileOrganizer extends Object
Creates a collection of Tiles from their grid to CRS affine transforms. When the Rectangle that describe the destination region is known for each tiles, the Tile(Rectangle, Dimension) constructor should be invoked directly. But in some cases the destination rectangle is not known directly. Instead we have a set of tiles, all of them with an upper-left corner located at (0,0), but different grid to CRS affine transforms read from World Files. This TileOrganizer class infers the destination regions automatically from the set of affine transforms.
Since:
1.1
Version:
1.1
Author:
Martin Desruisseaux (Geomatys)
  • Constructor Details

    • TileOrganizer

      public TileOrganizer(Point location)
      Creates an initially empty tile collection with the given location.
      Parameters:
      location - the location, or null for (0,0).
  • Method Details

    • getLocation

      public Point getLocation()
      Returns the location of the tile collections to be created. The location is often (0,0) as expected in BufferedImage, but does not have to.
      Returns:
      origin of the tile collections to be created.
    • add

      public boolean add(Tile tile)
      Adds a tile to the collection of tiles to process. Each tile can be added only once.
      Parameters:
      tile - the tile to add.
      Returns:
      true if the tile has been successfully added, or false if the tile does not need to be processed by this class.
    • tiles

      public Map<Tile,Tile[]> tiles() throws IOException
      Returns the tiles. Keys are pyramid geometry (containing mosaic bounds and grid to CRS transforms) and values are the tiles in that pyramid. This method usually returns a singleton map, but more entries may be present if this method was not able to build a single pyramid using all provided tiles.

      Invoking this method clear the collection. On return, this instance is empty. This is because current implementation modify its workspace directly for efficiency.

      Returns:
      all tiles added to this TileOrganizer, grouped by pyramids.
      Throws:
      IOException - if a call to Tile.getSize() or Tile.getRegion() failed, and unavailableSize(Tile, IOException) did not consumed the exception.
    • unavailableSize

      protected boolean unavailableSize(Tile tile, IOException exception)
      Invoked when an I/O error occurred in Tile.getSize() or Tile.getRegion(). This error is non-fatal since TileOrganizer can fallback on calculation based on tile location only (without size).

      The default implementation returns false, which instructs the caller to let the exception propagate.

      Parameters:
      tile - the tile on which an error occurred.
      exception - the error that occurred.
      Returns:
      true if the exception has been consumed, or false for re-throwing it.
    • toString

      public String toString()
      Returns a string representation of the tiles contained in this object. Since this method is for debugging purpose, only the first tiles may be formatted in order to avoid consuming to much space in the debugger.
      Overrides:
      toString in class Object