PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ LWGEOM_asText()

Datum LWGEOM_asText ( PG_FUNCTION_ARGS  )

Definition at line 860 of file lwgeom_ogc.c.

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

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

Here is the call graph for this function: