Postgis-Geohash is an extension for Postgres / Postgis to calculate per bit precision geohash.
It use 64 bits integer for store up to 60 bits geohash (12 digits in base32 common format).
liblwgeom
: Part of Postgis usually distribute as separate package, be careful to use the same version of liblwgeom when compiling postgis and this extension.
autoreconf --install
./configure
make
make install
[make installcheck]
tar -xzf geohash-x.y.z.tar.gz
./configure
make
make install
[make installcheck]
CREATE EXTENSION postgis;
CREATE EXTENSION postgis_geohash;
FUNCTION GeohashAsInt64(geom geometry, deep int4 DEFAULT 64)
RETURNS INT8
If geometry
is a POINT geometry, compute geohash, return NULL
value for others geometries.
Geohash is encoding over bits 2^59 to 2^(59-deep+1).
Bit 2^59 is for the first split according to latitude, bit 2^58 for the first split according to longitude.
Over bits are set to 0.
FUNCTION ReverseGeohashAsInt64(geom geometry, deep int4 DEFAULT 64)
RETURNS INT8
Like GeohashAsInt64
but bits are in reverse order.
Bit 2^0 is for the first split according to latitude, bit 2^1 for the first split according to longitude, ...
Over bits are set to 0.
FUNCTION GeohashAsText(geom geometry, deep int4 DEFAULT 64)
RETURNS TEXT
If geometry
is a POINT geometry, compute geohash, return NULL
value for others geometries.
Like GeohashAsInt64
but result is converted to a base 32.
Right zeros are truncated.
If geom
is a POINT:
GeohashAsText(geom, digits * 5) == ST_Geohash(geom, digits)
Postgis-Geohash may be distributed and/or modified under the conditions of the GNU General Public License, either version 3 or (at your option) any later version. Please refer to the COPYING file for details.
- Postgis: https://postgis.net/ -- GPL License
- Proj4: http://proj.osgeo.org -- X/MIT License
More details in respective folders.