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

Definition at line 2654 of file lwgeom_functions_basic.c.

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

2655 {
2656 
2657  GSERIALIZED *geom = NULL;
2658  int precision = 0;
2659  char *geohash = NULL;
2660  text *result = NULL;
2661 
2662  if ( PG_ARGISNULL(0) )
2663  {
2664  PG_RETURN_NULL();
2665  }
2666 
2667  geom = PG_GETARG_GSERIALIZED_P(0);
2668 
2669  if ( ! PG_ARGISNULL(1) )
2670  {
2671  precision = PG_GETARG_INT32(1);
2672  }
2673 
2674  geohash = lwgeom_geohash((LWGEOM*)(lwgeom_from_gserialized(geom)), precision);
2675 
2676  if ( ! geohash )
2677  PG_RETURN_NULL();
2678 
2679  result = cstring2text(geohash);
2680  pfree(geohash);
2681 
2682  PG_RETURN_TEXT_P(result);
2683 }
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:838

Here is the call graph for this function: