Class TileZXY

  • All Implemented Interfaces:
    ILatLon

    public final class TileZXY
    extends java.lang.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 Summary

      Fields 
      Modifier and Type Field Description
      private int x  
      private int y  
      private int zoom  
    • Constructor Summary

      Constructors 
      Constructor Description
      TileZXY​(int zoom, int x, int y)
      Create a new TileZXY object
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.stream.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
      static java.util.stream.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
      boolean equals​(java.lang.Object obj)  
      int hashCode()  
      double lat()
      Get the latitude for upper-left corner of this tile
      static TileZXY latLonToTile​(double lat, double lon, int zoom)
      Convert a lat, lon, and zoom to a tile coordiante
      double lon()
      Get the longitude for the upper-left corner of this tile
      static Bounds tileToBounds​(TileZXY tile)
      Convert a tile to the bounds for that tile
      java.lang.String toString()  
      int x()
      Get the x coordinate
      static double xToLon​(int x, int zoom)
      Convert a x tile coordinate to a latitude
      int y()
      Get the y coordinate
      static double yToLat​(int y, int zoom)
      Convert a y tile coordinate to a latitude
      int zoom()
      Get the zoom level
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • zoom

        private final int zoom
      • x

        private final int x
      • y

        private final int y
    • Constructor Detail

      • 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 Detail

      • 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 java.util.stream.Stream<TileZXYboundsToTiles​(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 java.util.stream.Stream<TileZXYboundsToTiles​(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 java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • hashCode

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

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object