Package oracle.spatial.util
Class GeoHash
- java.lang.Object
-
- oracle.spatial.util.GeoHash
-
- All Implemented Interfaces:
java.io.Serializable
public class GeoHash extends java.lang.Object implements java.io.Serializable- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.Stringbase32protected longbitsValueprotected shortnumberOfBits
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static double[]asMer(java.lang.String geohash)Finds the mer corresponding to a geohashstatic longdecimalValue(java.lang.String ghString)Computes the numeric value of a geohash stringstatic GeoHashgeohash(double longitude, double latitude, int hashLength)GeoHash from longitude, latitude with number of characters = hashLengthstatic GeoHashgeohash(long value, int hashLength)GeoHash corresponding to the long valuestatic GeoHashgeohash(java.lang.String bitString)GeoHash from a bit string the length of the string must be a multiple of 5static int[]geohashBits(double longitude, double latitude, int numBits)static GeoHashgeohashFromString(java.lang.String base32String)GeoHash from a string (base 32)java.lang.StringgeohashString(double longitude, double latitude, int hashLength)static GeoHashgeohashWithBitsLength(double longitude, double latitude, int numberOfBits)GeoHash from longitude, latitude with number of bits = numberOfBits numberOfBits must be a multiple of 5JPoint2DDgetCenterPoint()Computes the center point of the geohash merlonggetDecimalValue()Getter for the numeric value of the geohashGeoHash[]getEightNeighbors()Finds the eight neighbors of thisjava.lang.StringgetGeoHashString()Getter for geohash stringGeoHashgetGeoHashToTheEast()Finds the geohash to the east of this.GeoHashgetGeoHashToTheNorth()Finds the geohash to the north of this.GeoHashgetGeoHashToTheSouth()Finds the geohash to the south of thisGeoHashgetGeoHashToTheWest()Finds the geohash to the west of thisdouble[]getMer()Getter for mershortgetNumberOfBits()Getter for the number of bits in the geohash bit stringlonggetValue()GeoHashnext()Finds the next geohash.GeoHashnext(int numberOfSteps)Finds the geohash removed by a given number of steps from this.static longnumberOfStepsBetween(GeoHash gh1, GeoHash gh2)GeoHashprev()Finds the previous geohashjava.lang.StringtoBinaryString()Computes an equivalent bit string representation of the geohashbooleanwithin(JPoint2DD point)Checks whether the given point is inside the mer of this.booleanwithin(GeoHash gh)Checks whether the mer of the given geohash is inside the mer of this
-
-
-
Field Detail
-
base32
public static final java.lang.String base32
- See Also:
- Constant Field Values
-
bitsValue
protected long bitsValue
-
numberOfBits
protected short numberOfBits
-
-
Method Detail
-
geohash
public static GeoHash geohash(double longitude, double latitude, int hashLength)
GeoHash from longitude, latitude with number of characters = hashLength- Parameters:
longitude- longitude of the pointlatitude- latitude of the pointhashLength- precision of geohash in number of characters- Returns:
- GeoHash of the point
-
geohashWithBitsLength
public static GeoHash geohashWithBitsLength(double longitude, double latitude, int numberOfBits)
GeoHash from longitude, latitude with number of bits = numberOfBits numberOfBits must be a multiple of 5- Parameters:
longitude- longitude of the pointlatitude- latitude of the pointnumberOfBits- precision of geohash in number of bits- Returns:
- GeoHash of the point
-
geohash
public static GeoHash geohash(java.lang.String bitString)
GeoHash from a bit string the length of the string must be a multiple of 5- Parameters:
bitString- bit string- Returns:
- GeoHash of the string
-
geohash
public static GeoHash geohash(long value, int hashLength)
GeoHash corresponding to the long value- Parameters:
value- valuehashLength- precision of the geohash in number of characters- Returns:
- GeoHash of the value
-
geohashFromString
public static GeoHash geohashFromString(java.lang.String base32String)
GeoHash from a string (base 32)- Parameters:
base32String- base32 string- Returns:
- GeoHash of the string
-
geohashBits
public static int[] geohashBits(double longitude, double latitude, int numBits)
-
getGeoHashString
public java.lang.String getGeoHashString()
Getter for geohash string
-
getMer
public double[] getMer()
Getter for mer
-
getNumberOfBits
public short getNumberOfBits()
Getter for the number of bits in the geohash bit string
-
getDecimalValue
public long getDecimalValue()
Getter for the numeric value of the geohash
-
getCenterPoint
public JPoint2DD getCenterPoint()
Computes the center point of the geohash mer- Returns:
- JPoint2DD point
-
getValue
public long getValue()
-
toBinaryString
public java.lang.String toBinaryString()
Computes an equivalent bit string representation of the geohash- Returns:
- a bit string
-
next
public GeoHash next(int numberOfSteps)
Finds the geohash removed by a given number of steps from this.- Parameters:
numberOfSteps- number of steps to be moved- Returns:
- GeoHash
-
next
public GeoHash next()
Finds the next geohash.- Returns:
- GeoHash
-
prev
public GeoHash prev()
Finds the previous geohash- Returns:
- GeoHash
-
asMer
public static double[] asMer(java.lang.String geohash)
Finds the mer corresponding to a geohash- Returns:
- mer array
-
getGeoHashToTheNorth
public GeoHash getGeoHashToTheNorth()
Finds the geohash to the north of this.- Returns:
- GeoHash
-
getGeoHashToTheEast
public GeoHash getGeoHashToTheEast()
Finds the geohash to the east of this.- Returns:
- GeoHash
-
getGeoHashToTheSouth
public GeoHash getGeoHashToTheSouth()
Finds the geohash to the south of this- Returns:
- GeoHash
-
getGeoHashToTheWest
public GeoHash getGeoHashToTheWest()
Finds the geohash to the west of this- Returns:
- GeoHash
-
getEightNeighbors
public GeoHash[] getEightNeighbors()
Finds the eight neighbors of this- Returns:
- an array of GeoHash in the order N, NE, E, SE, S, SW, W, NW
-
within
public boolean within(GeoHash gh)
Checks whether the mer of the given geohash is inside the mer of this- Parameters:
gh- geohash to be checked
-
within
public boolean within(JPoint2DD point)
Checks whether the given point is inside the mer of this.- Parameters:
point- point to be checked- Returns:
- true if the point is inside mer
-
decimalValue
public static long decimalValue(java.lang.String ghString)
Computes the numeric value of a geohash string- Parameters:
ghString- base32 geohash string- Returns:
- decimal value
-
geohashString
public java.lang.String geohashString(double longitude, double latitude, int hashLength)
-
-