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

Definition at line 859 of file lwgeom_ogc.c.

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

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

Here is the call graph for this function: