PostGIS  2.5.0dev-r@@SVN_REVISION@@

◆ ST_GeoHash()

Datum ST_GeoHash ( PG_FUNCTION_ARGS  )

Definition at line 2657 of file lwgeom_functions_basic.c.

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

Referenced by LWGEOM_affine().

2658 {
2659 
2660  GSERIALIZED *geom = NULL;
2661  int precision = 0;
2662  char *geohash = NULL;
2663  text *result = NULL;
2664 
2665  if ( PG_ARGISNULL(0) )
2666  {
2667  PG_RETURN_NULL();
2668  }
2669 
2670  geom = PG_GETARG_GSERIALIZED_P(0);
2671 
2672  if ( ! PG_ARGISNULL(1) )
2673  {
2674  precision = PG_GETARG_INT32(1);
2675  }
2676 
2677  geohash = lwgeom_geohash((LWGEOM*)(lwgeom_from_gserialized(geom)), precision);
2678 
2679  if ( ! geohash )
2680  PG_RETURN_NULL();
2681 
2682  result = cstring_to_text(geohash);
2683  pfree(geohash);
2684 
2685  PG_RETURN_TEXT_P(result);
2686 }
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:847
Here is the call graph for this function:
Here is the caller graph for this function: