public class GeohashReferenceSystem.Coder extends Object
Coder
instance can read codes
at arbitrary precision, but formats at the specified precision.
The same Coder
instance can be reused for reading or writing many geohashes.
Defined in the sis-referencing-by-identifiers
module
Modifier | Constructor and Description |
---|---|
protected |
Coder()
Creates a new geohash coder/decoder initialized to the default precision.
|
Modifier and Type | Method and Description |
---|---|
AbstractLocation |
decode(CharSequence geohash)
Decodes the given geohash into a latitude and a longitude.
|
String |
encode(DirectPosition position)
Encodes the given position into a geohash.
|
String |
encode(double φ,
double λ)
Encodes the given latitude and longitude into a geohash.
|
int |
getHashLength()
Returns the length of geohashes strings to be encoded by the
encode(DirectPosition) method. |
void |
setHashLength(int length)
Sets the length of geohashes strings to be encoded by the
encode(DirectPosition) method. |
protected Coder()
public int getHashLength()
encode(DirectPosition)
method.
The default value for GeohashReferenceSystem.Format.BASE32
is 12.public void setHashLength(int length)
encode(DirectPosition)
method.length
- the new length of geohashes strings.public String encode(double φ, double λ) throws TransformException
GeohashReferenceSystem
constructor. For geohashing of
coordinates in different CRS, use encode(DirectPosition)
instead.φ
- latitude to encode, as decimal degrees in the [-90 … 90]° range.λ
- longitude to encode, as decimal degrees in the [-180 … 180]° range.TransformException
- if an error occurred while formatting the given coordinate.public String encode(DirectPosition position) throws TransformException
GeohashReferenceSystem
, then
delegates to encode(double, double)
.position
- the coordinate to encode.TransformException
- if an error occurred while transforming the given coordinate to a geohash reference.public AbstractLocation decode(CharSequence geohash) throws TransformException
GeohashReferenceSystem
.
org.opengis.referencing.gazetteer.Location
interface.
This change is pending GeoAPI revision.geohash
- geohash string to decode.TransformException
- if an error occurred while parsing the given string.Copyright © 2010–2017 The Apache Software Foundation. All rights reserved.