public class GeoHashUtils extends Object
Modifier and Type | Field and Description |
---|---|
static int |
PRECISION |
Modifier and Type | Method and Description |
---|---|
static <E extends Collection<? super String>> |
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>> |
addNeighbors(String geohash,
int length,
E neighbors)
Add all geohashes of the cells next to a given geohash to a list.
|
static GeoPoint |
decode(long geohash) |
static void |
decode(long geohash,
GeoPoint ret)
Decodes the given long-format geohash into a latitude and longitude
|
static GeoPoint |
decode(String geohash)
Decodes the given geohash
|
static GeoPoint |
decode(String geohash,
GeoPoint ret)
Decodes the given geohash into a latitude and longitude
|
static String |
encode(double latitude,
double longitude) |
static String |
encode(double latitude,
double longitude,
int precision)
Encodes the given latitude and longitude into a geohash
|
static long |
encodeAsLong(double latitude,
double longitude,
int precision)
Encodes latitude and longitude information into a single long with variable precision.
|
static Collection<? extends CharSequence> |
neighbors(String geohash)
Calculate all neighbors of a given geohash cell.
|
static String |
toString(long geohashAsLong)
Formats a geohash held as a long as a more conventional
String-based geohash
|
public static final int PRECISION
public static String encode(double latitude, double longitude)
public static String encode(double latitude, double longitude, int precision)
latitude
- Latitude to encodelongitude
- Longitude to encodepublic static Collection<? extends CharSequence> neighbors(String geohash)
geohash
- Geohash of the defined cellpublic static final <E extends Collection<? super String>> E addNeighbors(String geohash, E neighbors)
geohash
- Geohash of a specified cellneighbors
- list to add the neighbors topublic static final <E extends Collection<? super String>> E addNeighbors(String geohash, int length, E neighbors)
geohash
- Geohash of a specified celllength
- level of the given geohashneighbors
- list to add the neighbors topublic static GeoPoint decode(String geohash)
geohash
- Geohash to decocdeGeoPoint
at the center of cell, given by the geohashpublic static GeoPoint decode(String geohash, GeoPoint ret)
geohash
- Geohash to decocdeGeoPoint
reseted to the center of
cell, given by the geohashpublic static long encodeAsLong(double latitude, double longitude, int precision)
latitude
- longitude
- precision
- The required precision between 1 and 12public static String toString(long geohashAsLong)
geohashAsLong
- a geohash encoded as a longpublic static GeoPoint decode(long geohash)
public static void decode(long geohash, GeoPoint ret)
geohash
- long format Geohash to decoderet
- The Geopoint into which the latitude and longitude will be storedCopyright © 2009–2015. All rights reserved.