PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ LWGEOM_asEWKT()

Datum LWGEOM_asEWKT ( PG_FUNCTION_ARGS  )

Definition at line 2344 of file lwgeom_functions_basic.c.

2345 {
2346  GSERIALIZED *geom;
2347  LWGEOM *lwgeom;
2348  char *wkt;
2349  size_t wkt_size;
2350  text *result;
2351 
2352  POSTGIS_DEBUG(2, "LWGEOM_asEWKT called.");
2353 
2354  geom = PG_GETARG_GSERIALIZED_P(0);
2355  lwgeom = lwgeom_from_gserialized(geom);
2356 
2357  /* Write to WKT and free the geometry */
2358  wkt = lwgeom_to_wkt(lwgeom, WKT_EXTENDED, DBL_DIG, &wkt_size);
2359  lwgeom_free(lwgeom);
2360 
2361  /* Write to text and free the WKT */
2362  result = cstring_to_text(wkt);
2363  pfree(wkt);
2364 
2365  /* Return the text */
2366  PG_FREE_IF_COPY(geom, 0);
2367  PG_RETURN_TEXT_P(result);
2368 }
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_EXTENDED
Definition: liblwgeom.h:2077
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_EXTENDED.

Here is the call graph for this function: