342 static const char *default_prefix =
"";
344 const char* prefix = default_prefix;
349 version = PG_GETARG_INT32(0);
352 elog(ERROR,
"Only KML 2 is supported");
357 if ( PG_ARGISNULL(1) ) PG_RETURN_NULL();
358 g = PG_GETARG_GSERIALIZED_P(1);
364 if (PG_NARGS() >2 && !PG_ARGISNULL(2))
366 precision = PG_GETARG_INT32(2);
368 if ( precision > DBL_DIG )
370 else if ( precision < 0 ) precision = 0;
374 if (PG_NARGS() >3 && !PG_ARGISNULL(3))
376 prefix_text = PG_GETARG_TEXT_P(3);
377 if ( VARSIZE(prefix_text)-VARHDRSZ == 0 )
384 prefixbuf = palloc(VARSIZE(prefix_text)-VARHDRSZ+2);
385 memcpy(prefixbuf, VARDATA(prefix_text),
386 VARSIZE(prefix_text)-VARHDRSZ);
388 prefixbuf[VARSIZE(prefix_text)-VARHDRSZ] =
':';
389 prefixbuf[VARSIZE(prefix_text)-VARHDRSZ+1] =
'\0';
397 PG_FREE_IF_COPY(g, 1);
402 result = cstring2text(kml);
405 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)