317 static const char* default_prefix =
"";
319 const char* prefix = default_prefix;
324 version = PG_GETARG_INT32(0);
327 elog(ERROR,
"Only KML 2 is supported");
332 if ( PG_ARGISNULL(1) ) PG_RETURN_NULL();
333 geom = PG_GETARG_GSERIALIZED_P(1);
336 if (PG_NARGS() >2 && !PG_ARGISNULL(2))
339 precision = PG_GETARG_INT32(2);
340 if ( precision > DBL_DIG )
342 else if ( precision < 0 ) precision = 0;
346 if (PG_NARGS() >3 && !PG_ARGISNULL(3))
348 prefix_text = PG_GETARG_TEXT_P(3);
349 if ( VARSIZE(prefix_text)-VARHDRSZ == 0 )
356 prefixbuf = palloc(VARSIZE(prefix_text)-VARHDRSZ+2);
357 memcpy(prefixbuf, VARDATA(prefix_text),
358 VARSIZE(prefix_text)-VARHDRSZ);
360 prefixbuf[VARSIZE(prefix_text)-VARHDRSZ] =
':';
361 prefixbuf[VARSIZE(prefix_text)-VARHDRSZ+1] =
'\0';
369 PG_FREE_IF_COPY(geom, 1);
374 result = cstring2text(kml);
377 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)