https://github.com/simplegeo/libgeohash
A pure C implementation of the Geohash algorithm.
https://github.com/simplegeo/libgeohash
Last synced: about 1 year ago
JSON representation
A pure C implementation of the Geohash algorithm.
- Host: GitHub
- URL: https://github.com/simplegeo/libgeohash
- Owner: simplegeo
- License: bsd-3-clause
- Created: 2009-10-06T18:06:33.000Z (over 16 years ago)
- Default Branch: master
- Last Pushed: 2019-05-05T12:33:47.000Z (about 7 years ago)
- Last Synced: 2024-07-31T22:55:18.425Z (almost 2 years ago)
- Language: C
- Homepage: http://geohash.org
- Size: 218 KB
- Stars: 104
- Watchers: 13
- Forks: 33
- Open Issues: 5
-
Metadata Files:
- Readme: README.markdown
- License: LICENSE
Awesome Lists containing this project
- awesome-c - libgeohash - Pure C implementation of the Geohash algorithm. [BSD-3-Clause](https://spdx.org/licenses/BSD-3-Clause.html) (Utilities / YAML)
- awesome-c-zh - libgeohash - 3-Clause.html) (公用事业 / YAML)
- awesome-c - libgeohash - Pure C implementation of the Geohash algorithm. [BSD-3-Clause](https://spdx.org/licenses/BSD-3-Clause.html) (Utilities / YAML)
README
libgeohash
==========
Derek Smith
-----------
derek@simplegeo.com
-------------------
A static library used for encoding/decoding geohashes.
To use libgeohash just run make. Link libgeohash.a and include geohash.h into your project.
### Encode
char* geohash_encode(double lat, double lng, int precision);
Takes in latitude and longitude with a desired precision and returns the correct hash value. If
precision < 0 or precision > 20, a default value of 6 will be used.
### Decode
GeoCoord geohash_decode(char* hash);
Produces an allocated GeoCoord structure which contains the latitude and longitude that was decoded from
the geohash. A GeoCoord also provides the bounding box for the geohash (north, east, south, west).
### Neighbors
char** geohash_neighbors(char* hash);
Uses the bounding box declared at hash and calculates the 8 neighboring boxes. An example is show below.
+ ezefx ezs48 ezs49
+ ezefr ezs42 ezs43
+ ezefp ezs40 ezs41
The value returned is an array of char* with length of 8. The neighboring positions of values are shown
below with each box representing the index of the array.
+ 7 0 1
+ 6 * 2
+ 5 4 3