Methods
(static) adjacent(geohash, direction) → {string}
Determines adjacent cell in given direction.
Parameters:
Name | Type | Description |
---|---|---|
geohash |
Cell to which adjacent cell is required. | |
direction |
Direction from geohash (N/S/E/W). |
- Source:
Throws:
Invalid geohash.
Returns:
Geocode of adjacent cell.
- Type
- string
(static) bounds(geohash) → {Object}
Returns SW/NE latitude/longitude bounds of specified geohash.
Parameters:
Name | Type | Description |
---|---|---|
geohash |
string | Cell that bounds are required of. |
- Source:
Throws:
Invalid geohash.
Returns:
- Type
- Object
(static) decode(geohash) → {Object}
Decode geohash to latitude/longitude (location is approximate centre of geohash cell,
to reasonable precision).
Parameters:
Name | Type | Description |
---|---|---|
geohash |
string | Geohash string to be converted to latitude/longitude. |
- Source:
Throws:
Invalid geohash.
Returns:
(Center of) geohashed location.
- Type
- Object
Example
const latlon = Geohash.decode('u120fxw'); // => { lat: 52.205, lon: 0.1188 }
(static) encode(lat, lon, precisionopt) → {string}
Encodes latitude/longitude to geohash, either to specified precision or to automatically
evaluated precision.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
lat |
number | Latitude in degrees. | |
lon |
number | Longitude in degrees. | |
precision |
number |
<optional> |
Number of characters in resulting geohash. |
- Source:
Throws:
Invalid geohash.
Returns:
Geohash of supplied latitude/longitude.
- Type
- string
Example
const geohash = Geohash.encode(52.205, 0.119, 7); // => 'u120fxw'
(static) neighbours(geohash) → {Object}
Returns all 8 adjacent cells to specified geohash.
Parameters:
Name | Type | Description |
---|---|---|
geohash |
string | Geohash neighbours are required of. |
- Source:
Throws:
Invalid geohash.
Returns:
- Type
- Object