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

Definition at line 830 of file lwgeom_ogc.c.

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

831 {
832  GSERIALIZED *geom;
833  LWGEOM *lwgeom;
834  char *wkt;
835  size_t wkt_size;
836  text *result;
837 
838  POSTGIS_DEBUG(2, "Called.");
839 
840  geom = PG_GETARG_GSERIALIZED_P(0);
841  lwgeom = lwgeom_from_gserialized(geom);
842 
843  /* Write to WKT and free the geometry */
844  wkt = lwgeom_to_wkt(lwgeom, WKT_ISO, DBL_DIG, &wkt_size);
845  lwgeom_free(lwgeom);
846  POSTGIS_DEBUGF(3, "WKT size = %u, WKT length = %u", (unsigned int)wkt_size, (unsigned int)strlen(wkt));
847 
848  /* Write to text and free the WKT */
849  result = cstring2text(wkt);
850  pfree(wkt);
851 
852  /* Return the text */
853  PG_FREE_IF_COPY(geom, 0);
854  PG_RETURN_TEXT_P(result);
855 }
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:1050
#define WKT_ISO
Definition: liblwgeom.h:1939

Here is the call graph for this function: