geohash function for mysql
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
example * fix double precision size, * add examples Apr 29, 2010
README
geohash.sql

README

geohash-mysql-func
----

usage
----

geohash_encode(
  latitude double(10, 7)
  longitude double(10, 7)
  precision tinyint -- aka hash length
)

mysql> select geohash_encode(57.64911, 10.40744, 12);
+----------------------------------------+
| geohash_encode(57.64911, 10.40744, 12) |
+----------------------------------------+
| u4pruydqqvqb                           | 
+----------------------------------------+

mysql> select geohash_encode(40.730885, -73.997383, 5);
+------------------------------------------+
| geohash_encode(40.730885, -73.997383, 5) |
+------------------------------------------+
| dr5rs                                    | 
+------------------------------------------+

geohash_decode(
  geohash varchar(12)
) returns varchar(77)

mysql> select geohash_decode('u4pru');
+----------------------------------------------------------------------------+
| geohash_decode('u4pru')                                                    |
+----------------------------------------------------------------------------+
| -82.7929688,-179.5605468
-82.7490234,-179.5166015
-82.7709961,-179.5385741 | 
+----------------------------------------------------------------------------+

csv format:
latidude0, longitude0
latidude1, longitude1
latidude2, longitude2

MORE INFORMATION
----
GeoHash on Wikipedia (http://en.wikipedia.org/wiki/Geohash)
GeoHash Routines for Javascript (http://github.com/davetroy/geohash-js)