Class TilingScheme

java.lang.Object
noaa.coastwatch.io.tile.TilingScheme

public class TilingScheme extends Object
The tiling scheme class helps support the tiling of 2D data. A tiling scheme consists of a set of global row and column dimensions along with a set of tile row and column dimensions. The tiling scheme contains the TilePosition and Tile classes to aid in the manipulation of tile coordinates and data. A general tiling in 2D looks as follows:
              
              tile column
               dimension            tile position coordinates
              <--------->         /
                                 /
            ^ +---------*-------/-*---+    ^
            | |         *      /  *   |    | 
   tile row | |         *     v   *   |    |
  dimension | |  [0,0]  *  [0,1]  * [0,2]  |
            | |         *         *   |    |
            | |         *         *   |    |
            v *************************    |
              |         *         *   |    | global row dimension
              |         *         *   |    |
              |  [1,0]  *  [1,1]  * [1,2]  |
              |         *         *   |    | 
              |         *         *   |    |
              *************************    |
              |         *         *   |    |
 truncated -->|  [2,0]  *  [2,1]  * [2,2]  |
   tile       +---------*---------*---+    v

              <----------------------->
                    global column
                      dimension  
 
In the example above, the tile count in both dimensions is 3, even though some tiles are truncated due to the tile dimensions.
Since:
3.1.2
Author:
Peter Hollemans
  • Field Details

  • Constructor Details

    • TilingScheme

      public TilingScheme(int[] dims, int[] tileDims)
      Creates a new tiling scheme from the specified dimensions.
      Parameters:
      dims - the global dimensions as [rows, columns].
      tileDims - the tile dimensions as [rows, columns].
  • Method Details

    • getDimensions

      public int[] getDimensions()
      Gets the global dimensions as [rows, columns].
    • getTileDimensions

      public int[] getTileDimensions()
      Gets the tile dimensions as [rows, columns].
    • getTileDimensions

      @Deprecated public int[] getTileDimensions(TilingScheme.TilePosition pos)
      Deprecated.
      Gets the tile dimensions as [rows, columns] for the specified tile position. This method may return smaller dimensions than getTileDimensions() for tiles at the truncated positions.
      Parameters:
      pos - the tile position.
      Returns:
      the tile dimensions at the specified position.
    • getTileCount

      public int getTileCount()
      Gets the total tile count in this scheme.
      Returns:
      the total tile count.
      Since:
      3.8.1
    • getTileCounts

      public int[] getTileCounts()
      Gets the tile counts along each dimension.
      Returns:
      the tile counts as [rows, columns].
    • createTilePosition

      @Deprecated public TilingScheme.TilePosition createTilePosition(int row, int col)
      Deprecated.
      Creates a new tile position from global coordinates.
      Parameters:
      row - the data row coordinate.
      col - the data column coordinate.
      Throws:
      IndexOutOfBoundsException - if the coordinates do not reference a valid tile in the tiling scheme.
    • getTilePositionForCoords

      public TilingScheme.TilePosition getTilePositionForCoords(int row, int col)
      Gets a shared instance of a tile position whose tile contains the specified global coordinates.
      Parameters:
      row - the data row coordinate.
      col - the data column coordinate.
      Returns:
      the instance of the tile position containing the coordinates.
      Throws:
      IndexOutOfBoundsException - if the coordinates do not reference a valid tile in the tiling scheme.
      Since:
      3.8.1
    • getTilePositionForIndex

      public TilingScheme.TilePosition getTilePositionForIndex(int tileRow, int tileCol)
      Gets a tile position object using the tile position coordinates.
      Parameters:
      tileRow - the tile row index.
      tileCol - the tile column index.
      Returns:
      the instance of the tile position of the specified tile indices.
      Throws:
      IndexOutOfBoundsException - if the indices do not reference a valid tile in the tiling scheme.
      Since:
      3.8.1
      See Also:
    • getCoveringPositions

      public List<TilingScheme.TilePosition> getCoveringPositions(int[] start, int[] count)
      Gets a minimal list of tile positions that cover a subset of the global coordinates.
      Parameters:
      start - the data subset starting [row, column].
      count - the data subset dimension [rows, columns].
      Returns:
      the list of tile positions.
      Throws:
      IndexOutOfBoundsException - if the subset falls outside the grid dimensions.
      Since:
      3.8.1
    • getAllPositions

      public List<TilingScheme.TilePosition> getAllPositions()
      Gets a list of all tile positions for this tiling scheme.
      Returns:
      the list of all tile positions. Changes to the returned list have no effect on the tiling scheme.
      Since:
      3.8.1
    • main

      public static void main(String[] argv) throws Exception
      Tests this class.
      Parameters:
      argv - the array of command line parameters.
      Throws:
      Exception