Class GeoTileUtils


  • public final class GeoTileUtils
    extends java.lang.Object
    Implements geotile key hashing, same as used by many map tile implementations. The string key is formatted as "zoom/x/y" The hash value (long) contains all three of those values compacted into a single 64bit value: bits 58..63 -- zoom (0..29) bits 29..57 -- X tile index (0..2^zoom) bits 0..28 -- Y tile index (0..2^zoom)
    • Method Summary

      Modifier and Type Method Description
      static int checkPrecisionRange​(int precision)
      Assert the precision value is within the allowed range, and return it if ok, or throw.
      static long longEncode​(double longitude, double latitude, int precision)
      Encode lon/lat to the geotile based long format.
      static long longEncode​(java.lang.String hashAsString)
      Encode a geotile hash style string to a long.
      static java.lang.String stringEncode​(long hash)
      Encode to a geotile string from the geotile based long format
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • checkPrecisionRange

        public static int checkPrecisionRange​(int precision)
        Assert the precision value is within the allowed range, and return it if ok, or throw.
      • longEncode

        public static long longEncode​(double longitude,
                                      double latitude,
                                      int precision)
        Encode lon/lat to the geotile based long format. The resulting hash contains interleaved tile X and Y coordinates. The precision itself is also encoded as a few high bits.
      • longEncode

        public static long longEncode​(java.lang.String hashAsString)
        Encode a geotile hash style string to a long.
        Parameters:
        hashAsString - String in format "zoom/x/y"
        Returns:
        long encoded value of the given string hash
      • stringEncode

        public static java.lang.String stringEncode​(long hash)
        Encode to a geotile string from the geotile based long format