PostGIS  2.1.10dev-r@@SVN_REVISION@@
Datum ST_GeoHash ( PG_FUNCTION_ARGS  )

Definition at line 2563 of file lwgeom_functions_basic.c.

References lwgeom_from_gserialized(), lwgeom_geohash(), and result.

2564 {
2565 
2566  GSERIALIZED *geom = NULL;
2567  int precision = 0;
2568  char *geohash = NULL;
2569  text *result = NULL;
2570 
2571  if ( PG_ARGISNULL(0) )
2572  {
2573  PG_RETURN_NULL();
2574  }
2575 
2576  geom = (GSERIALIZED *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
2577 
2578  if ( ! PG_ARGISNULL(1) )
2579  {
2580  precision = PG_GETARG_INT32(1);
2581  }
2582 
2583  geohash = lwgeom_geohash((LWGEOM*)(lwgeom_from_gserialized(geom)), precision);
2584 
2585  if ( ! geohash )
2586  PG_RETURN_NULL();
2587 
2588  result = cstring2text(geohash);
2589  pfree(geohash);
2590 
2591  PG_RETURN_TEXT_P(result);
2592 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
char ** result
Definition: liblwgeom.h:218
LWGEOM * geom
char * lwgeom_geohash(const LWGEOM *lwgeom, int precision)
Calculate the GeoHash (http://geohash.org) string for a geometry.
Definition: lwalgorithm.c:828

Here is the call graph for this function: