Class Tiles

java.lang.Object
dev.avelar.mapnik.Tiles

public final class Tiles extends Object
Maths for the standard "slippy map" tile grid used by web maps (XYZ or Google scheme): zoom 0 is one tile covering the world in Web Mercator (EPSG:3857), and each zoom splits every tile in four. Tile (0, 0) is at the top left, so y grows downwards. Pure Java: no native library needed.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    One tile of the grid.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final double
    The latitude Web Mercator cuts off at.
    static final int
    The highest zoom this class accepts.
    static final double
    Half the width of the Web Mercator world, in metres.
  • Method Summary

    Modifier and Type
    Method
    Description
    static Box2d
    bounds(int z, int x, int y)
    The area of tile (z, x, y) in Web Mercator metres.
    covering(Box2d lonLatBox, int z)
    Every tile at a zoom that touches a box given in degrees, row by row from the top left.
    static Box2d
    lonLatBounds(int z, int x, int y)
    The area of tile (z, x, y) in degrees.
    static double
    resolution(int z, int tileSize)
    The size of one pixel, in metres, for tiles tileSize pixels wide at a zoom.
    static Tiles.Tile
    tileAt(double lon, double lat, int z)
    The tile containing a location at a zoom.

    Methods inherited from class java.lang.Object

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

    • ORIGIN_SHIFT

      public static final double ORIGIN_SHIFT
      Half the width of the Web Mercator world, in metres.
      See Also:
    • MAX_ZOOM

      public static final int MAX_ZOOM
      The highest zoom this class accepts.
      See Also:
    • MAX_LATITUDE

      public static final double MAX_LATITUDE
      The latitude Web Mercator cuts off at.
      See Also:
  • Method Details

    • bounds

      public static Box2d bounds(int z, int x, int y)
      The area of tile (z, x, y) in Web Mercator metres.
    • lonLatBounds

      public static Box2d lonLatBounds(int z, int x, int y)
      The area of tile (z, x, y) in degrees.
    • tileAt

      public static Tiles.Tile tileAt(double lon, double lat, int z)
      The tile containing a location at a zoom. Latitudes beyond MAX_LATITUDE count as at the edge, and longitudes are clamped to the world.
    • covering

      public static List<Tiles.Tile> covering(Box2d lonLatBox, int z)
      Every tile at a zoom that touches a box given in degrees, row by row from the top left.
    • resolution

      public static double resolution(int z, int tileSize)
      The size of one pixel, in metres, for tiles tileSize pixels wide at a zoom.