PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ LWGEOM_asText()

Datum LWGEOM_asText ( PG_FUNCTION_ARGS  )

Definition at line 859 of file lwgeom_ogc.c.

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

Referenced by LWGEOM_from_WKB().

860 {
861  GSERIALIZED *geom;
862  LWGEOM *lwgeom;
863  char *wkt;
864  size_t wkt_size;
865  text *result;
866 
867  POSTGIS_DEBUG(2, "Called.");
868 
869  geom = PG_GETARG_GSERIALIZED_P(0);
870  lwgeom = lwgeom_from_gserialized(geom);
871 
872  /* Write to WKT and free the geometry */
873  wkt = lwgeom_to_wkt(lwgeom, WKT_ISO, DBL_DIG, &wkt_size);
874  lwgeom_free(lwgeom);
875  POSTGIS_DEBUGF(3, "WKT size = %u, WKT length = %u", (unsigned int)wkt_size, (unsigned int)strlen(wkt));
876 
877  /* Write to text and free the WKT */
878  result = cstring2text(wkt);
879  pfree(wkt);
880 
881  /* Return the text */
882  PG_FREE_IF_COPY(geom, 0);
883  PG_RETURN_TEXT_P(result);
884 }
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:1099
#define WKT_ISO
Definition: liblwgeom.h:2083
Here is the call graph for this function:
Here is the caller graph for this function: