Class Tile

  • Direct Known Subclasses:
    ImageTile, TerrainTile

    public class Tile
    extends java.lang.Object
    Geographically rectangular tile within a LevelSet, typically representing terrain or imagery. Provides a base class for tiles used by tiled image layers and elevation models. Applications typically do not interact with this class.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      int column
      The tile's column within its level.
      Level level
      The level at which this tile lies within a LevelSet.
      int row
      The tile's row within its level.
      Sector sector
      The sector spanned by this tile.
      java.lang.String tileKey
      A key that uniquely identifies this tile within a level set.
    • Constructor Summary

      Constructors 
      Constructor Description
      Tile​(Sector sector, Level level, int row, int column)
      Constructs a tile with a specified sector, level, row and column.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.Collection<Tile> assembleTilesForLevel​(Level level, TileFactory tileFactory, java.util.Collection<Tile> result)
      Creates all tiles for a specified level within a LevelSet.
      static int computeColumn​(double tileDelta, double longitude, double origin)
      Computes a column number for a tile within a level given the tile's longitude.
      static int computeLastColumn​(double tileDelta, double maxLongitude, double origin)
      Computes the last column number for a tile within a level given the tile's maximum longitude.
      static int computeLastRow​(double tileDelta, double maxLatitude, double origin)
      Computes the last row number for a tile within a level given the tile's maximum latitude.
      static int computeRow​(double tileDelta, double latitude, double origin)
      Computes a row number for a tile within a level given the tile's latitude.
      boolean intersectsFrustum​(RenderContext rc, Frustum frustum)
      Indicates whether this tile's Cartesian extent intersects a specified frustum.
      boolean intersectsSector​(Sector sector)
      Indicates whether this tile intersects a specified sector.
      boolean mustSubdivide​(RenderContext rc, double detailFactor)
      Indicates whether this tile should be subdivided based on the current navigation state and a specified detail factor.
      Tile[] subdivide​(TileFactory tileFactory)
      Returns the four children formed by subdividing this tile.
      Tile[] subdivideToCache​(TileFactory tileFactory, LruMemoryCache<java.lang.String,​Tile[]> cache, int cacheSize)
      Returns the four children formed by subdividing this tile, drawing those children from a specified cache.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • sector

        public final Sector sector
        The sector spanned by this tile.
      • level

        public final Level level
        The level at which this tile lies within a LevelSet.
      • row

        public final int row
        The tile's row within its level.
      • column

        public final int column
        The tile's column within its level.
      • tileKey

        public final java.lang.String tileKey
        A key that uniquely identifies this tile within a level set. Tile keys are not unique to a specific level set.
    • Constructor Detail

      • Tile

        public Tile​(Sector sector,
                    Level level,
                    int row,
                    int column)
        Constructs a tile with a specified sector, level, row and column.
        Parameters:
        sector - the sector spanned by the tile
        level - the tile's level in a LevelSet
        row - the tile's row within the specified level
        column - the tile's column within the specified level
        Throws:
        java.lang.IllegalArgumentException - if either the sector or the level is null
    • Method Detail

      • computeRow

        public static int computeRow​(double tileDelta,
                                     double latitude,
                                     double origin)
        Computes a row number for a tile within a level given the tile's latitude.
        Parameters:
        tileDelta - the level's tile delta in degrees
        latitude - the tile's minimum latitude in degrees
        origin - the origin of the grid
        Returns:
        the computed row number
      • computeColumn

        public static int computeColumn​(double tileDelta,
                                        double longitude,
                                        double origin)
        Computes a column number for a tile within a level given the tile's longitude.
        Parameters:
        tileDelta - the level's tile delta in degrees
        longitude - the tile's minimum longitude in degrees
        origin - the origin of the grid
        Returns:
        The computed column number
      • computeLastRow

        public static int computeLastRow​(double tileDelta,
                                         double maxLatitude,
                                         double origin)
        Computes the last row number for a tile within a level given the tile's maximum latitude.
        Parameters:
        tileDelta - the level's tile delta in degrees
        maxLatitude - the tile's maximum latitude in degrees
        origin - the origin of the grid
        Returns:
        the computed row number
      • computeLastColumn

        public static int computeLastColumn​(double tileDelta,
                                            double maxLongitude,
                                            double origin)
        Computes the last column number for a tile within a level given the tile's maximum longitude.
        Parameters:
        tileDelta - the level's tile delta in degrees
        maxLongitude - the tile's maximum longitude in degrees
        origin - the origin of the grid
        Returns:
        The computed column number
      • assembleTilesForLevel

        public static java.util.Collection<Tile> assembleTilesForLevel​(Level level,
                                                                       TileFactory tileFactory,
                                                                       java.util.Collection<Tile> result)
        Creates all tiles for a specified level within a LevelSet.
        Parameters:
        level - the level to create the tiles for
        tileFactory - the tile factory to use for creating tiles.
        result - an pre-allocated Collection in which to store the results
        Returns:
        the result argument populated with the tiles for the specified level
        Throws:
        java.lang.IllegalArgumentException - If any argument is null
      • intersectsFrustum

        public boolean intersectsFrustum​(RenderContext rc,
                                         Frustum frustum)
        Indicates whether this tile's Cartesian extent intersects a specified frustum.
        Parameters:
        rc - the current render context
        frustum - the frustum of interest
        Returns:
        true if the specified frustum intersects this tile's extent, otherwise false
        Throws:
        java.lang.IllegalArgumentException - If the frustum is null
      • intersectsSector

        public boolean intersectsSector​(Sector sector)
        Indicates whether this tile intersects a specified sector.
        Parameters:
        sector - the sector of interest
        Returns:
        true if the specified sector intersects this tile's sector, otherwise false
        Throws:
        java.lang.IllegalArgumentException - If the sector is null
      • mustSubdivide

        public boolean mustSubdivide​(RenderContext rc,
                                     double detailFactor)
        Indicates whether this tile should be subdivided based on the current navigation state and a specified detail factor.
        Parameters:
        rc - the current render context
        detailFactor - the detail factor to consider
        Returns:
        true if the tile should be subdivided, otherwise false
      • subdivide

        public Tile[] subdivide​(TileFactory tileFactory)
        Returns the four children formed by subdividing this tile. This tile's sector is subdivided into four quadrants as follows: Southwest; Southeast; Northwest; Northeast. A new tile is then constructed for each quadrant and configured with the next level within this tile's LevelSet and its corresponding row and column within that level. This returns null if this tile's level is the last level within its LevelSet.
        Parameters:
        tileFactory - the tile factory to use to create the children
        Returns:
        an array containing the four child tiles, or null if this tile's level is the last level
        Throws:
        java.lang.IllegalArgumentException - If the tile factory is null
      • subdivideToCache

        public Tile[] subdivideToCache​(TileFactory tileFactory,
                                       LruMemoryCache<java.lang.String,​Tile[]> cache,
                                       int cacheSize)
        Returns the four children formed by subdividing this tile, drawing those children from a specified cache. The cache is checked for a child collection prior to subdividing. If one exists in the cache it is returned rather than creating a new collection of children. If a new collection is created in the same manner as subdivide(TileFactory) and added to the cache.
        Parameters:
        tileFactory - the tile factory to use to create the children
        cache - a memory cache that may contain pre-existing child tiles.
        cacheSize - the cached size of the four child tiles
        Returns:
        an array containing the four child tiles, or null if this tile's level is the last level
        Throws:
        java.lang.IllegalArgumentException - If any argument is null