public final class GeoHash extends Object
Constructor and Description |
---|
GeoHash(GeoPoint point)
Create a GeoHash from a point.
|
GeoHash(String hash)
Create a GeoHash from a hash string.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canEqual(Object obj)
Detects whether an object can be compared to this instance.
|
boolean |
contains(GeoHash other)
Specifies whether a GeoHash is contained within this one.
|
static GeoPoint |
decode(String hash)
Decodes a geoHash string into a GeoPoint.
|
GeoHash |
decreaseResolution()
Shortens the size of the GeoHash by one character, effectively decreasing the resolution.
|
GeoHash |
decreaseResolution(int amount)
Shortens the size of the GeoHash, so removes characters from the right, effectively decreasing the resolution.
|
static String |
encode(double lat,
double lon) |
static String |
encode(GeoPoint point)
Encodes a GeoPoint into a geoHash string.
|
boolean |
equals(Object obj)
Detects whether a given object is equal to this instance.
|
String |
getHash()
Return the geo hash string of this object.
|
GeoPoint |
getPoint()
Return the point (coordinate) of this geo hash.
|
int |
hashCode()
Returns the hashCode of this instance.
|
static boolean |
isValid(String hash)
Return whether a hash is a valid Geo Hash.
|
int |
length()
Gets the hash length.
|
GeoHash |
moveTo(GeoPoint point)
Creates a new GeoHash using the same resolution (length) as the current object to contain a new point.
|
GeoHash |
setResolution(int length)
Shortens the size of the GeoHash by an absolute value, so removes characters from the right.
|
String |
toString()
Converts the instance to a JSON encoded string.
|
GeoHash |
useResolution(GeoHash other)
Returns a new GeoHash object with the same resolution as the specified object.
|
public GeoHash(@Nonnull String hash) throws IllegalArgumentException
hash
- Geo hash string.IllegalArgumentException
@Nonnull public String getHash()
@Nonnull public GeoPoint getPoint()
@Nonnull public GeoHash moveTo(@Nonnull GeoPoint point)
point
- Point to be contained by new object.@Nonnull public GeoHash useResolution(@Nonnull GeoHash other)
other
- GeoHash object that specifies the resolution.@Nullable public GeoHash decreaseResolution()
@Nullable public GeoHash decreaseResolution(int amount)
amount
- The amount of characters to remove, must be 0 or bigger.@Nullable public GeoHash setResolution(int length)
length
- The new size of the GeoHash, must be > 0.public boolean contains(@Nonnull GeoHash other)
other
- Other GeoHash.public int length()
@Nonnull public static String encode(@Nonnull GeoPoint point)
point
- GeoPoint to be encoded.@Nonnull public static GeoPoint decode(@Nonnull String hash) throws IllegalArgumentException
hash
- String representation of a GeoHash.IllegalArgumentException
- when an invalid hash was given.public static boolean isValid(@Nullable String hash)
hash
- String representation of GeoHash.public boolean canEqual(@Nonnull Object obj)
obj
- The Object to be tested.public boolean equals(@Nullable Object obj)
Copyright © 2018 TomTom International BV. All rights reserved.