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

Definition at line 2494 of file lwgeom_functions_basic.c.

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

2495 {
2496 
2497  GSERIALIZED *geom = NULL;
2498  int precision = 0;
2499  char *geohash = NULL;
2500  text *result = NULL;
2501 
2502  if ( PG_ARGISNULL(0) )
2503  {
2504  PG_RETURN_NULL();
2505  }
2506 
2507  geom = PG_GETARG_GSERIALIZED_P(0);
2508 
2509  if ( ! PG_ARGISNULL(1) )
2510  {
2511  precision = PG_GETARG_INT32(1);
2512  }
2513 
2514  geohash = lwgeom_geohash((LWGEOM*)(lwgeom_from_gserialized(geom)), precision);
2515 
2516  if ( ! geohash )
2517  PG_RETURN_NULL();
2518 
2519  result = cstring2text(geohash);
2520  pfree(geohash);
2521 
2522  PG_RETURN_TEXT_P(result);
2523 }
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:813

Here is the call graph for this function: