org.apache.lucene.spatial.util

## Class GeoHashUtils

- java.lang.Object
- - org.apache.lucene.spatial.util.GeoHashUtils

-     public class GeoHashUtils
      extends Object

  Utilities for converting to/from the GeoHash standard The geohash long format is represented as lon/lat (x/y) interleaved with the 4 least significant bits representing the level (1-12) [xyxy...xyxyllll] This differs from a morton encoded value which interleaves lat/lon (y/x).
  WARNING: This API is experimental and might change in incompatible ways in the next release.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `PRECISION` maximum precision for geohash strings

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static <E extends Collection<? super String>> E` | `addNeighbors(String geohash, E neighbors)` Add all geohashes of the cells next to a given geohash to a list.
    `static <E extends Collection<? super String>> E` | `addNeighbors(String geohash, int length, E neighbors)` Add all geohashes of the cells next to a given geohash to a list.
    `static long` | `fromMorton(long morton, int level)` Convert from a morton encoded long from a geohash encoded long
    `static long` | `longEncode(double lon, double lat, int level)` Encode lon/lat to the geohash based long format (lon/lat interleaved, 4 least significant bits = level)
    `static long` | `longEncode(long geohash, int level)` Encode an existing geohash long to the provided precision
    `static long` | `longEncode(String hash)` Encode from geohash string to the geohash based long format (lon/lat interleaved, 4 least significant bits = level)
    `static long` | `mortonEncode(long geoHashLong)` Encode to a morton long value from a given geohash long value
    `static long` | `mortonEncode(String hash)` Encode to a morton long value from a given geohash string
    `static String` | `neighbor(String geohash, int level, int dx, int dy)` Calculate the geohash of a neighbor of a geohash
    `static Collection<? extends CharSequence>` | `neighbors(String geohash)` Calculate all neighbors of a given geohash cell.
    `static String` | `stringEncode(double lon, double lat)` Encode to a geohash string from full resolution longitude, latitude)
    `static String` | `stringEncode(double lon, double lat, int level)` Encode to a level specific geohash string from full resolution longitude, latitude
    `static String` | `stringEncode(long geoHashLong)` Encode to a geohash string from the geohash based long format
    `static String` | `stringEncodeFromMortonLong(long hashedVal)` Encode to a full precision geohash string from a given morton encoded long value
    `static String` | `stringEncodeFromMortonLong(long hashedVal, int level)` Encode to a geohash string at a given level from a morton long

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### PRECISION

          public static final int PRECISION

      maximum precision for geohash strings
      See Also:
        Constant Field Values

  - ### Method Detail

    - #### longEncode

          public static final long longEncode(double lon,
                        double lat,
                        int level)

      Encode lon/lat to the geohash based long format (lon/lat interleaved, 4 least significant bits = level)

    - #### longEncode

          public static final long longEncode(String hash)

      Encode from geohash string to the geohash based long format (lon/lat interleaved, 4 least significant bits = level)

    - #### longEncode

          public static long longEncode(long geohash,
                        int level)

      Encode an existing geohash long to the provided precision

    - #### fromMorton

          public static long fromMorton(long morton,
                        int level)

      Convert from a morton encoded long from a geohash encoded long

    - #### stringEncode

          public static final String stringEncode(long geoHashLong)

      Encode to a geohash string from the geohash based long format

    - #### stringEncode

          public static final String stringEncode(double lon,
                            double lat)

      Encode to a geohash string from full resolution longitude, latitude)

    - #### stringEncode

          public static final String stringEncode(double lon,
                            double lat,
                            int level)

      Encode to a level specific geohash string from full resolution longitude, latitude

    - #### stringEncodeFromMortonLong

          public static final String stringEncodeFromMortonLong(long hashedVal)
                                                         throws Exception

      Encode to a full precision geohash string from a given morton encoded long value
      Throws:
        `Exception`

    - #### stringEncodeFromMortonLong

          public static final String stringEncodeFromMortonLong(long hashedVal,
                                          int level)

      Encode to a geohash string at a given level from a morton long

    - #### mortonEncode

          public static final long mortonEncode(String hash)

      Encode to a morton long value from a given geohash string

    - #### mortonEncode

          public static final long mortonEncode(long geoHashLong)

      Encode to a morton long value from a given geohash long value

    - #### neighbors

          public static Collection<? extends CharSequence> neighbors(String geohash)

      Calculate all neighbors of a given geohash cell.
      Parameters:
        `geohash` - Geohash of the defined cell
      Returns:
        geohashes of all neighbor cells

    - #### neighbor

          public static final String neighbor(String geohash,
                        int level,
                        int dx,
                        int dy)

      Calculate the geohash of a neighbor of a geohash
      Parameters:
        `geohash` - the geohash of a cell
        `level` - level of the geohash
        `dx` - delta of the first grid coordinate (must be -1, 0 or +1)
        `dy` - delta of the second grid coordinate (must be -1, 0 or +1)
      Returns:
        geohash of the defined cell

    - #### addNeighbors

          public static final <E extends Collection<? super String>> E addNeighbors(String geohash,
                                                              E neighbors)

      Add all geohashes of the cells next to a given geohash to a list.
      Parameters:
        `geohash` - Geohash of a specified cell
        `neighbors` - list to add the neighbors to
      Returns:
        the given list

    - #### addNeighbors

          public static final <E extends Collection<? super String>> E addNeighbors(String geohash,
                                                              int length,
                                                              E neighbors)

      Add all geohashes of the cells next to a given geohash to a list.
      Parameters:
        `geohash` - Geohash of a specified cell
        `length` - level of the given geohash
        `neighbors` - list to add the neighbors to
      Returns:
        the given list

Copyright © 2000-2017 Apache Software Foundation. All Rights Reserved.