[postgis-devel] GeoHash decoding function

J Smith dark.panda+lists at gmail.com
Tue Apr 24 10:49:35 PDT 2012


On Tue, Apr 24, 2012 at 1:01 PM, Paul Ramsey <pramsey at opengeo.org> wrote:
>
> If you provide ST_GeomFromGeoHash() in C I dont' know why we wouldn't
> include it.
>

Alright, cool. When I get a chance, I'll try and code it up. For the
time being, I have an implementation in plpgsql that I'm going to be
using for my project. I've used the following function signatures:

ST_GeomFromGeoHash(geohash text) returns geometry
ST_GeomFromGeoHash(geohash text, prec integer) returns geometry

"prec" is the precision to use. By default, the decoder tries to use
as much precision as it can, i.e. use the length of the GeoHash as the
precision. The return value is a geometry, which can be either a
POINT, LINESTRING or POLYGON depending on the precision of the
GeoHash. I've marked the functions as IMMUTABLE, and a NULL GeoHash
returns NULL.

The plpgsql functions work well for now, so if that looks good, I'll
use this as the basis of a C implementation.

Cheers.



More information about the postgis-devel mailing list