PostGIS  3.1.6dev-r@@SVN_REVISION@@

◆ geometry_to_jsonb()

Datum geometry_to_jsonb ( PG_FUNCTION_ARGS  )

Definition at line 277 of file lwgeom_export.c.

278 {
279  GSERIALIZED *geom = PG_GETARG_GSERIALIZED_P(0);
280  LWGEOM *lwgeom = lwgeom_from_gserialized(geom);
281  char *cstr = NULL;
282  lwvarlena_t *geojson = lwgeom_to_geojson(lwgeom, NULL, 15, 0);
283  lwgeom_free(lwgeom);
284  cstr = palloc0(VARSIZE_ANY_EXHDR(geojson) + 1);
285  memcpy(cstr, VARDATA(geojson), VARSIZE_ANY_EXHDR(geojson));
286  PG_RETURN_DATUM(DirectFunctionCall1(jsonb_in, PointerGetDatum(cstr)));
287 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
Definition: gserialized.c:239
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1138
lwvarlena_t * lwgeom_to_geojson(const LWGEOM *geo, const char *srs, int precision, int has_bbox)
Takes a GEOMETRY and returns a GeoJson representation.
Definition: lwout_geojson.c:49

References lwgeom_free(), lwgeom_from_gserialized(), and lwgeom_to_geojson().

Here is the call graph for this function: