PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ geography_as_kml()

Datum geography_as_kml ( PG_FUNCTION_ARGS  )

Definition at line 326 of file geography_inout.c.

327{
328
329 lwvarlena_t *kml;
330 static const char *default_prefix = "";
331 char *prefixbuf;
332 const char *prefix = default_prefix;
333 GSERIALIZED *g = PG_GETARG_GSERIALIZED_P(0);
334 int precision = PG_GETARG_INT32(1);
335 text *prefix_text = PG_GETARG_TEXT_P(2);
336 LWGEOM *lwgeom = lwgeom_from_gserialized(g);
337
338 /* Condition the precision */
339 if (precision < 0)
340 precision = 0;
341
342 if (VARSIZE_ANY_EXHDR(prefix_text) > 0)
343 {
344 /* +2 is one for the ':' and one for term null */
345 prefixbuf = palloc(VARSIZE_ANY_EXHDR(prefix_text)+2);
346 memcpy(prefixbuf, VARDATA(prefix_text),
347 VARSIZE_ANY_EXHDR(prefix_text));
348 /* add colon and null terminate */
349 prefixbuf[VARSIZE_ANY_EXHDR(prefix_text)] = ':';
350 prefixbuf[VARSIZE_ANY_EXHDR(prefix_text)+1] = '\0';
351 prefix = prefixbuf;
352 }
353 else
354 {
355 prefix = "";
356 }
357
358 kml = lwgeom_to_kml2(lwgeom, precision, prefix);
359 if (kml)
360 PG_RETURN_TEXT_P(kml);
361 PG_RETURN_NULL();
362}
static uint8_t precision
Definition cu_in_twkb.c:25
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
lwvarlena_t * lwgeom_to_kml2(const LWGEOM *geom, int precision, const char *prefix)
Definition lwout_kml.c:44

References lwgeom_from_gserialized(), lwgeom_to_kml2(), and precision.

Here is the call graph for this function: