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

Definition at line 856 of file lwgeom_ogc.c.

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

857 {
858  GSERIALIZED *geom;
859  LWGEOM *lwgeom;
860  char *wkt;
861  size_t wkt_size;
862  text *result;
863 
864  POSTGIS_DEBUG(2, "Called.");
865 
866  geom = PG_GETARG_GSERIALIZED_P(0);
867  lwgeom = lwgeom_from_gserialized(geom);
868 
869  /* Write to WKT and free the geometry */
870  wkt = lwgeom_to_wkt(lwgeom, WKT_ISO, DBL_DIG, &wkt_size);
871  lwgeom_free(lwgeom);
872  POSTGIS_DEBUGF(3, "WKT size = %u, WKT length = %u", (unsigned int)wkt_size, (unsigned int)strlen(wkt));
873 
874  /* Write to text and free the WKT */
875  result = cstring2text(wkt);
876  pfree(wkt);
877 
878  /* Return the text */
879  PG_FREE_IF_COPY(geom, 0);
880  PG_RETURN_TEXT_P(result);
881 }
char * lwgeom_to_wkt(const LWGEOM *geom, uint8_t variant, int precision, size_t *size_out)
WKT emitter function.
Definition: lwout_wkt.c:669
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1063
#define WKT_ISO
Definition: liblwgeom.h:2055

Here is the call graph for this function: