360 static const char *default_prefix =
"";
362 const char* prefix = default_prefix;
367 version = PG_GETARG_INT32(0);
370 elog(ERROR,
"Only KML 2 is supported");
375 if ( PG_ARGISNULL(1) ) PG_RETURN_NULL();
376 g = PG_GETARG_GSERIALIZED_P(1);
382 if (PG_NARGS() >2 && !PG_ARGISNULL(2))
392 if (PG_NARGS() >3 && !PG_ARGISNULL(3))
394 prefix_text = PG_GETARG_TEXT_P(3);
395 if ( VARSIZE(prefix_text)-VARHDRSZ == 0 )
402 prefixbuf = palloc(VARSIZE(prefix_text)-VARHDRSZ+2);
403 memcpy(prefixbuf, VARDATA(prefix_text),
404 VARSIZE(prefix_text)-VARHDRSZ);
406 prefixbuf[VARSIZE(prefix_text)-VARHDRSZ] =
':';
407 prefixbuf[VARSIZE(prefix_text)-VARHDRSZ+1] =
'\0';
415 PG_FREE_IF_COPY(g, 1);
420 result = cstring_to_text(kml);
423 PG_RETURN_TEXT_P(result);
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)