PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ geometry_to_json()

Datum geometry_to_json ( PG_FUNCTION_ARGS  )

Definition at line 455 of file lwgeom_export.c.

456 {
457  GSERIALIZED *geom = PG_GETARG_GSERIALIZED_P(0);
458  LWGEOM *lwgeom = lwgeom_from_gserialized(geom);
459  char *geojson = lwgeom_to_geojson(lwgeom, NULL, 15, 0);
460  text *result = cstring_to_text(geojson);
461  lwgeom_free(lwgeom);
462  pfree(geojson);
463  PG_FREE_IF_COPY(geom, 0);
464  PG_RETURN_TEXT_P(result);
465 }
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
char * lwgeom_to_geojson(const LWGEOM *geo, 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: