java.lang.Object
org.openstreetmap.josm.data.osm.visitor.paint.TileZXY
All Implemented Interfaces:
ILatLon

public final class TileZXY extends Object implements ILatLon
A record used for storing tile information for painting. The origin is upper-left, not lower-left (so more like Google tile coordinates than TMS tile coordinates).
Since:
19176
  • Field Details

    • zoom

      private final int zoom
    • x

      private final int x
    • y

      private final int y
  • Constructor Details

    • TileZXY

      public TileZXY(int zoom, int x, int y)
      Create a new TileZXY object
      Parameters:
      zoom - The zoom for which this tile was created
      x - The x coordinate at the specified zoom level
      y - The y coordinate at the specified zoom level
  • Method Details

    • zoom

      public int zoom()
      Get the zoom level
      Returns:
      The zoom level for which this tile was created
    • x

      public int x()
      Get the x coordinate
      Returns:
      The x coordinate for this tile
    • y

      public int y()
      Get the y coordinate
      Returns:
      The y coordinate for this tile
    • lat

      public double lat()
      Get the latitude for upper-left corner of this tile
      Specified by:
      lat in interface ILatLon
      Returns:
      The latitude
    • lon

      public double lon()
      Get the longitude for the upper-left corner of this tile
      Specified by:
      lon in interface ILatLon
      Returns:
      The longitude
    • boundsToTiles

      public static Stream<TileZXY> boundsToTiles(double minLat, double minLon, double maxLat, double maxLon, int zoom)
      Convert a bounds to a series of tiles that entirely cover the bounds
      Parameters:
      minLat - The minimum latitude
      minLon - The minimum longitude
      maxLat - The maximum latitude
      maxLon - The maximum longitude
      zoom - The zoom level to generate the tiles for
      Returns:
      The stream of tiles
    • boundsToTiles

      public static Stream<TileZXY> boundsToTiles(double minLat, double minLon, double maxLat, double maxLon, int zoom, int expansion)
      Convert a bounds to a series of tiles that entirely cover the bounds
      Parameters:
      minLat - The minimum latitude
      minLon - The minimum longitude
      maxLat - The maximum latitude
      maxLon - The maximum longitude
      zoom - The zoom level to generate the tiles for
      expansion - The number of tiles to expand on the x/y axis (1 row north, 1 row south, 1 column left, 1 column right)
      Returns:
      The stream of tiles
    • tileToBounds

      public static Bounds tileToBounds(TileZXY tile)
      Convert a tile to the bounds for that tile
      Parameters:
      tile - The tile to get the bounds for
      Returns:
      The bounds
    • xToLon

      public static double xToLon(int x, int zoom)
      Convert a x tile coordinate to a latitude
      Parameters:
      x - The x coordinate
      zoom - The zoom level to use for the calculation
      Returns:
      The latitude for the x coordinate (upper-left of the tile)
    • yToLat

      public static double yToLat(int y, int zoom)
      Convert a y tile coordinate to a latitude
      Parameters:
      y - The y coordinate
      zoom - The zoom level to use for the calculation
      Returns:
      The latitude for the y coordinate (upper-left of the tile)
    • latLonToTile

      public static TileZXY latLonToTile(double lat, double lon, int zoom)
      Convert a lat, lon, and zoom to a tile coordiante
      Parameters:
      lat - The latitude
      lon - The longitude
      zoom - The zoom level
      Returns:
      The specified tile coordinates at the specified zoom
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hashCode

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

      public boolean equals(Object obj)
      Overrides:
      equals in class Object