PostGIS  2.1.10dev-r@@SVN_REVISION@@
Datum LWGEOM_to_text ( PG_FUNCTION_ARGS  )

Definition at line 303 of file lwgeom_inout.c.

References lwgeom_free(), lwgeom_from_gserialized(), lwgeom_to_hexwkb(), result, and WKB_EXTENDED.

304 {
305  GSERIALIZED *geom = (GSERIALIZED*)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
306  LWGEOM *lwgeom;
307  char *hexwkb;
308  size_t hexwkb_size;
309  text *result;
310 
311  /* Generate WKB hex text */
312  lwgeom = lwgeom_from_gserialized(geom);
313  hexwkb = lwgeom_to_hexwkb(lwgeom, WKB_EXTENDED, &hexwkb_size);
314  lwgeom_free(lwgeom);
315 
316  /* Copy into text obect */
317  result = cstring2text(hexwkb);
318  pfree(hexwkb);
319 
320  /* Clean up and return */
321  PG_FREE_IF_COPY(geom, 0);
322  PG_RETURN_TEXT_P(result);
323 }
char * lwgeom_to_hexwkb(const LWGEOM *geom, uint8_t variant, size_t *size_out)
Definition: lwout_wkb.c:776
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1006
char ** result
Definition: liblwgeom.h:218
LWGEOM * geom
#define WKB_EXTENDED
Definition: liblwgeom.h:1769

Here is the call graph for this function: