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

Definition at line 2359 of file lwgeom_functions_basic.c.

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

2360 {
2361  GSERIALIZED *geom;
2362  LWGEOM *lwgeom;
2363  char *wkt;
2364  size_t wkt_size;
2365  text *result;
2366 
2367  POSTGIS_DEBUG(2, "LWGEOM_asEWKT called.");
2368 
2369  geom = (GSERIALIZED*)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
2370  lwgeom = lwgeom_from_gserialized(geom);
2371 
2372  /* Write to WKT and free the geometry */
2373  wkt = lwgeom_to_wkt(lwgeom, WKT_EXTENDED, DBL_DIG, &wkt_size);
2374  lwgeom_free(lwgeom);
2375 
2376  /* Write to text and free the WKT */
2377  result = cstring2text(wkt);
2378  pfree(wkt);
2379 
2380  /* Return the text */
2381  PG_FREE_IF_COPY(geom, 0);
2382  PG_RETURN_TEXT_P(result);
2383 }
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
LWGEOM * geom
#define WKT_EXTENDED
Definition: liblwgeom.h:1778

Here is the call graph for this function: