Class TileAddress

java.lang.Object
org.deltava.util.tile.TileAddress
All Implemented Interfaces:
Serializable, Comparable<TileAddress>
Direct Known Subclasses:
TileServlet.TileAddress5D

public class TileAddress extends Object implements Serializable, Comparable<TileAddress>
A class to store quadtree Tile addresses.
Since:
1.3
Version:
11.3
Author:
Luke
See Also:
  • Constructor Details

    • TileAddress

      public TileAddress(int x, int y, int level)
      Creates a new Tile Address from cartesian coordinates.
      Parameters:
      x - the zero-offset X coordinate
      y - the zero-offset Y coordinate
      level - the level
    • TileAddress

      public TileAddress(String name)
      Creates a new Tile Address from a tile filename.
      Parameters:
      name - the tile filename
      Throws:
      NullPointerException - if name is null
  • Method Details

    • fromPixel

      public static TileAddress fromPixel(int px, int py, int zoom)
      Creates a new Tile Address from pixel coordinates.
      Parameters:
      px - the zero-offset X coordinate
      py - the zero-offset Y coordinate
      zoom - the zoom level
      Returns:
      the new TileAddress
    • getLevel

      public int getLevel()
      Returns the Tile level.
      Returns:
      the level
    • getX

      public int getX()
      Returns the X-coordinate of this Tile.
      Returns:
      the zero-offset X coordinate
    • getY

      public int getY()
      Returns the Y-coordinate of this Tile.
      Returns:
      the zero-offset Y coordinate
    • getPixelX

      public int getPixelX()
      Returns the X-coordinate of this tile within the global image.
      Returns:
      the zero-offset pixel X coordinate
    • getPixelY

      public int getPixelY()
      Returns the Y-coordinate of this tile within the global image.
      Returns:
      the zero-offset pixel Y coordinate
    • getName

      public String getName()
      Returns the base filename of this Tile.
      Returns:
      the base filename
    • toString

      public String toString()
      Returns the coordinates and level of the Tile.
      Overrides:
      toString in class Object
    • compareTo

      public int compareTo(TileAddress addr2)
      Compares two addresses by comparing their levels, Y and X coordinates.
      Specified by:
      compareTo in interface Comparable<TileAddress>
      See Also:
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getParent

      public TileAddress getParent()
      Returns this Tile's parent address.
      Returns:
      the Tile's parent address
      See Also:
    • getParents

      public Collection<TileAddress> getParents()
      Returns the addresses of all of this Tile's parents.
      Returns:
      a Collection of TileAddress beans
      See Also:
    • getChildren

      public Collection<TileAddress> getChildren()
      Returns the addresses of all of this Tile's children.
      Returns:
      a Collection of TileAddress beans
      See Also:
    • getChildren

      public Collection<TileAddress> getChildren(int level)
      Returns the addresses of all of this Tile's descendents at a particular zoom level.
      Parameters:
      level - the new zoom level
      Returns:
      a Collection of TileAddress beans
    • zoomTo

      public TileAddress zoomTo(int newLevel)
      Returns the address of this Tile when zooming to another level. If zooming to a higher level, then the address of the top-left child will be returned.
      Parameters:
      newLevel - the new zoom level
      Returns:
      the Address of the tile