geohash-mysql-func
geohash-mysql-func copied to clipboard
geohash function for mysql
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)