PostGIS 3.0.6dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ LWGEOM_asEWKT()

Datum LWGEOM_asEWKT ( PG_FUNCTION_ARGS  )

Definition at line 2361 of file lwgeom_functions_basic.c.

2362{
2363 GSERIALIZED *geom;
2364 LWGEOM *lwgeom;
2365 char *wkt;
2366 size_t wkt_size;
2367 text *result;
2368
2369 POSTGIS_DEBUG(2, "LWGEOM_asEWKT called.");
2370
2371 geom = PG_GETARG_GSERIALIZED_P(0);
2372 lwgeom = lwgeom_from_gserialized(geom);
2373
2374 /* Write to WKT and free the geometry */
2375 wkt = lwgeom_to_wkt(lwgeom, WKT_EXTENDED, DBL_DIG, &wkt_size);
2376 lwgeom_free(lwgeom);
2377
2378 /* Write to text and free the WKT */
2379 result = cstring_to_text(wkt);
2380 lwfree(wkt);
2381
2382 /* Return the text */
2383 PG_FREE_IF_COPY(geom, 0);
2384 PG_RETURN_TEXT_P(result);
2385}
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
Definition lwgeom.c:1138
#define WKT_EXTENDED
Definition liblwgeom.h:2132
char * lwgeom_to_wkt(const LWGEOM *geom, uint8_t variant, int precision, size_t *size_out)
WKT emitter function.
Definition lwout_wkt.c:676
void lwfree(void *mem)
Definition lwutil.c:242

References lwfree(), lwgeom_free(), lwgeom_from_gserialized(), lwgeom_to_wkt(), and WKT_EXTENDED.

Here is the call graph for this function: