PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ ST_GeoHash()

Datum ST_GeoHash ( PG_FUNCTION_ARGS  )

Definition at line 2522 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().

2523 {
2524 
2525  GSERIALIZED *geom = NULL;
2526  int precision = 0;
2527  char *geohash = NULL;
2528  text *result = NULL;
2529 
2530  if ( PG_ARGISNULL(0) )
2531  {
2532  PG_RETURN_NULL();
2533  }
2534 
2535  geom = PG_GETARG_GSERIALIZED_P(0);
2536 
2537  if ( ! PG_ARGISNULL(1) )
2538  {
2539  precision = PG_GETARG_INT32(1);
2540  }
2541 
2542  geohash = lwgeom_geohash((LWGEOM*)(lwgeom_from_gserialized(geom)), precision);
2543 
2544  if ( ! geohash )
2545  PG_RETURN_NULL();
2546 
2547  result = cstring2text(geohash);
2548  pfree(geohash);
2549 
2550  PG_RETURN_TEXT_P(result);
2551 }
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:846
Here is the call graph for this function:
Here is the caller graph for this function: