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

Definition at line 823 of file lwgeom_ogc.c.

References lwgeom_free(), lwgeom_from_gserialized(), lwgeom_to_wkt(), result, and WKT_ISO.

824 {
825  GSERIALIZED *geom;
826  LWGEOM *lwgeom;
827  char *wkt;
828  size_t wkt_size;
829  text *result;
830 
831  POSTGIS_DEBUG(2, "Called.");
832 
833  geom = (GSERIALIZED*)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
834  lwgeom = lwgeom_from_gserialized(geom);
835 
836  /* Write to WKT and free the geometry */
837  wkt = lwgeom_to_wkt(lwgeom, WKT_ISO, DBL_DIG, &wkt_size);
838  lwgeom_free(lwgeom);
839  POSTGIS_DEBUGF(3, "WKT size = %u, WKT length = %u", (unsigned int)wkt_size, (unsigned int)strlen(wkt));
840 
841  /* Write to text and free the WKT */
842  result = cstring2text(wkt);
843  pfree(wkt);
844 
845  /* Return the text */
846  PG_FREE_IF_COPY(geom, 0);
847  PG_RETURN_TEXT_P(result);
848 }
char * lwgeom_to_wkt(const LWGEOM *geom, uint8_t variant, int precision, size_t *size_out)
WKT emitter function.
Definition: lwout_wkt.c:655
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
#define WKT_ISO
Definition: liblwgeom.h:1776
LWGEOM * geom

Here is the call graph for this function: