349{
350
351 char *kml;
352 text *result;
353 static const char *default_prefix = "";
354 char *prefixbuf;
355 const char *prefix = default_prefix;
358 text *prefix_text = PG_GETARG_TEXT_P(2);
360
361
366
367 if (VARSIZE_ANY_EXHDR(prefix_text) > 0)
368 {
369
370 prefixbuf = palloc(VARSIZE_ANY_EXHDR(prefix_text)+2);
371 memcpy(prefixbuf, VARDATA(prefix_text),
372 VARSIZE_ANY_EXHDR(prefix_text));
373
374 prefixbuf[VARSIZE_ANY_EXHDR(prefix_text)] = ':';
375 prefixbuf[VARSIZE_ANY_EXHDR(prefix_text)+1] = '\0';
376 prefix = prefixbuf;
377 }
378 else
379 {
380 prefix = "";
381 }
382
384
386 PG_FREE_IF_COPY(g, 0);
387
388 if (!kml)
389 PG_RETURN_NULL();
390
391 result = cstring_to_text(kml);
393
394 PG_RETURN_TEXT_P(result);
395}
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
char * lwgeom_to_kml2(const LWGEOM *geom, int precision, const char *prefix)