351 static const char* default_prefix =
"";
353 const char* prefix = default_prefix;
358 version = PG_GETARG_INT32(0);
361 elog(ERROR,
"Only KML 2 is supported");
366 if ( PG_ARGISNULL(1) ) PG_RETURN_NULL();
367 geom = PG_GETARG_GSERIALIZED_P(1);
370 if (PG_NARGS() >2 && !PG_ARGISNULL(2))
380 if (PG_NARGS() >3 && !PG_ARGISNULL(3))
382 prefix_text = PG_GETARG_TEXT_P(3);
383 if ( VARSIZE(prefix_text)-VARHDRSZ == 0 )
390 prefixbuf = palloc(VARSIZE(prefix_text)-VARHDRSZ+2);
391 memcpy(prefixbuf, VARDATA(prefix_text),
392 VARSIZE(prefix_text)-VARHDRSZ);
394 prefixbuf[VARSIZE(prefix_text)-VARHDRSZ] =
':';
395 prefixbuf[VARSIZE(prefix_text)-VARHDRSZ+1] =
'\0';
403 PG_FREE_IF_COPY(geom, 1);
408 result = cstring_to_text(kml);
411 PG_RETURN_POINTER(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)