Class Tile

java.lang.Object
com.geodesk.geom.Tile

public class Tile extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    bottomRight(Bounds bbox, int zoom)
    Returns the bottom-right tile occupied by a bounding box.
    static int
    bottomY(int tile)
    Returns the bottom (lowest) y-coordinate that lies within the given tile.
    static Box
    bounds(int tile)
     
    static TileBox
    childrenOfTileAtZoom(int tile, int zoom)
     
    static int
    column(int tile)
     
    static int
    columnFromXZ(int x, int zoom)
     
    static int
    fromBounds(Bounds bbox, int zoom)
    Returns the tile occupied by the given bounding box, or -1 if its extends across multiple tiles.
    static int
    fromColumnRowZoom(int col, int row, int zoom)
    Creates a tile number.
    static int
    Parses a tile number from a String.
    static int
    fromXYZ(double x, double y, int zoom)
     
    static int
    fromXYZ(int x, int y, int zoom)
    Determines the tile to which a coordinate belongs; coordinates must be in the projection used by the Mercator class.
    static Box
    intersection(int tile, Bounds bounds)
    Calculates a new BoundingBox that represents the area of overlap between the given bounds and the bounding box of a tile
    static Envelope
    intersection(int tile, Envelope env)
     
    static boolean
    isBlack(int tile)
    Checks whether the tile would be black, if we imagine the tile grid being laid out like a checkerboard (with the top left tile being white).
    static boolean
    isValid(int tile)
    Checks if the given number represents a valid tile number
    static int
    leftX(int tile)
    Returns the leftmost (lowest) x-coordinate that lies within the given tile
    static int
    neighbor(int fromTile, Heading direction)
    Returns the tile number of an adjacent tile that lies in the specified direction.
    static Polygon
    polygon(int tile)
     
    static int
    relative(int tile, int deltaCol, int deltaRow)
     
    static int
    rightX(int tile)
    Returns the rightmost (highest) x-coordinate that lies within the given tile
    static int
    row(int tile)
     
    static int
    rowFromYZ(int y, int zoom)
     
    static long
    sizeAtZoom(int zoom)
    Returns the width/height of a tile at the given zoom level
    static int
    tilesAtZoom(int zoom)
     
    static int
    topLeft(Bounds bbox, int zoom)
    Returns the top-left tile occupied by a bounding box.
    static int
    topY(int tile)
     
    static String
    toString(int tile)
     
    static int
    zoom(int tile)
     
    static int
    zoomedOut(int tile, int zoom)
    Returns the tile that contains this tile at the specified (lower) zoom level.
    static int
    zoomFromSize(long size)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Tile

      public Tile()
  • Method Details

    • row

      public static int row(int tile)
    • column

      public static int column(int tile)
    • zoom

      public static int zoom(int tile)
    • tilesAtZoom

      public static int tilesAtZoom(int zoom)
    • sizeAtZoom

      public static long sizeAtZoom(int zoom)
      Returns the width/height of a tile at the given zoom level
      Parameters:
      zoom - a valid zoom level
      Returns:
      width/height in pixels
    • zoomFromSize

      public static int zoomFromSize(long size)
    • fromColumnRowZoom

      public static int fromColumnRowZoom(int col, int row, int zoom)
      Creates a tile number. This method does not check whether the given column, row, and zoom level are valid.
      Parameters:
      col - a valid column
      row - a valid row
      zoom - a valid zoom level
      Returns:
    • fromXYZ

      public static int fromXYZ(int x, int y, int zoom)
      Determines the tile to which a coordinate belongs; coordinates must be in the projection used by the Mercator class.
      Parameters:
      x -
      y -
      Returns:
    • columnFromXZ

      public static int columnFromXZ(int x, int zoom)
    • rowFromYZ

      public static int rowFromYZ(int y, int zoom)
    • fromXYZ

      public static int fromXYZ(double x, double y, int zoom)
    • isValid

      public static boolean isValid(int tile)
      Checks if the given number represents a valid tile number
      Parameters:
      tile -
      Returns:
    • leftX

      public static int leftX(int tile)
      Returns the leftmost (lowest) x-coordinate that lies within the given tile
      Parameters:
      tile -
      Returns:
    • rightX

      public static int rightX(int tile)
      Returns the rightmost (highest) x-coordinate that lies within the given tile
      Parameters:
      tile -
      Returns:
    • bottomY

      public static int bottomY(int tile)
      Returns the bottom (lowest) y-coordinate that lies within the given tile. Remember, going from top to bottom, tile rows *increase*, while y-coordinates *decrease*.
      Parameters:
      tile -
      Returns:
    • topY

      public static int topY(int tile)
    • zoomedOut

      public static int zoomedOut(int tile, int zoom)
      Returns the tile that contains this tile at the specified (lower) zoom level. If the zoom level is the same, the tile itself is returned.
      Parameters:
      tile - the tile
      zoom - zoom level of the parent tile (must be <= the tile's zoom level)
      Returns:
      the lower-zoom tile that contains the tile
    • neighbor

      public static int neighbor(int fromTile, Heading direction)
      Returns the tile number of an adjacent tile that lies in the specified direction.
      Parameters:
      fromTile - the current tile
      direction - the direction in which the neighbor tile is located
      Returns:
      the tile number of the adjacent tile
    • bounds

      public static Box bounds(int tile)
    • polygon

      public static Polygon polygon(int tile)
    • topLeft

      public static int topLeft(Bounds bbox, int zoom)
      Returns the top-left tile occupied by a bounding box.
      Parameters:
      bbox - the bounds
      zoom - the zoom level for which to return the tile
      Returns:
    • bottomRight

      public static int bottomRight(Bounds bbox, int zoom)
      Returns the bottom-right tile occupied by a bounding box.
      Parameters:
      bbox - the bounds
      zoom - the zoom level for which to return the tile
      Returns:
    • toString

      public static String toString(int tile)
    • fromString

      public static int fromString(String s)
      Parses a tile number from a String. Valid formats are: "zoom/column/row" or "column/row" (assumes zoom 12)
      Parameters:
      s -
      Returns:
      the tile number, or -1 if the String does not represent a valid tile number
    • isBlack

      public static boolean isBlack(int tile)
      Checks whether the tile would be black, if we imagine the tile grid being laid out like a checkerboard (with the top left tile being white). This allows us to implement an optimization strategy that significantly reduces the number of tiles we need to load to obtain the member ways of a large relation: We can check the color of the tiles where a way's start and end nodes are located, and preferably assign a uniform color tile as the home tile.
      Parameters:
      tile -
      Returns:
    • intersection

      public static Envelope intersection(int tile, Envelope env)
    • intersection

      public static Box intersection(int tile, Bounds bounds)
      Calculates a new BoundingBox that represents the area of overlap between the given bounds and the bounding box of a tile
      Parameters:
      tile - the tile to which to constrain the bounds
      bounds -
      Returns:
    • fromBounds

      public static int fromBounds(Bounds bbox, int zoom)
      Returns the tile occupied by the given bounding box, or -1 if its extends across multiple tiles.
      Parameters:
      bbox - the bounding box
      zoom - the zoom level of the tile
      Returns:
    • childrenOfTileAtZoom

      public static TileBox childrenOfTileAtZoom(int tile, int zoom)
    • relative

      public static int relative(int tile, int deltaCol, int deltaRow)