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

Definition at line 2553 of file lwgeom_functions_basic.c.

References dumpnode::geom, lwgeom_from_gserialized(), lwgeom_geohash(), and precision.

2554 {
2555 
2556  GSERIALIZED *geom = NULL;
2557  int precision = 0;
2558  char *geohash = NULL;
2559  text *result = NULL;
2560 
2561  if ( PG_ARGISNULL(0) )
2562  {
2563  PG_RETURN_NULL();
2564  }
2565 
2566  geom = PG_GETARG_GSERIALIZED_P(0);
2567 
2568  if ( ! PG_ARGISNULL(1) )
2569  {
2570  precision = PG_GETARG_INT32(1);
2571  }
2572 
2573  geohash = lwgeom_geohash((LWGEOM*)(lwgeom_from_gserialized(geom)), precision);
2574 
2575  if ( ! geohash )
2576  PG_RETURN_NULL();
2577 
2578  result = cstring2text(geohash);
2579  pfree(geohash);
2580 
2581  PG_RETURN_TEXT_P(result);
2582 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
LWGEOM * geom
uint8_t precision
Definition: cu_in_twkb.c:25
char * lwgeom_geohash(const LWGEOM *lwgeom, int precision)
Calculate the GeoHash (http://geohash.org) string for a geometry.
Definition: lwalgorithm.c:827

Here is the call graph for this function: