PostGIS  2.1.10dev-r@@SVN_REVISION@@
Datum geography_as_svg ( PG_FUNCTION_ARGS  )

Definition at line 399 of file geography_inout.c.

References lwfree(), lwgeom_free(), lwgeom_from_gserialized(), lwgeom_to_svg(), and result.

400 {
401  GSERIALIZED *g = NULL;
402  LWGEOM *lwgeom = NULL;
403  char *svg;
404  text *result;
405  int relative = 0;
406  int precision=DBL_DIG;
407 
408  if ( PG_ARGISNULL(0) ) PG_RETURN_NULL();
409 
410  g = (GSERIALIZED*)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
411 
412  /* Convert to lwgeom so we can run the old functions */
413  lwgeom = lwgeom_from_gserialized(g);
414 
415  /* check for relative path notation */
416  if ( PG_NARGS() > 1 && ! PG_ARGISNULL(1) )
417  relative = PG_GETARG_INT32(1) ? 1:0;
418 
419  if ( PG_NARGS() > 2 && ! PG_ARGISNULL(2) )
420  {
421  precision = PG_GETARG_INT32(2);
422  /* TODO: leave this to liblwgeom */
423  if ( precision > DBL_DIG )
424  precision = DBL_DIG;
425  else if ( precision < 0 ) precision = 0;
426  }
427 
428  svg = lwgeom_to_svg(lwgeom, precision, relative);
429 
430  lwgeom_free(lwgeom);
431  PG_FREE_IF_COPY(g, 0);
432 
433  result = cstring2text(svg);
434  lwfree(svg);
435 
436  PG_RETURN_TEXT_P(result);
437 }
void lwfree(void *mem)
Definition: lwutil.c:190
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
char * lwgeom_to_svg(const LWGEOM *geom, int precision, int relative)
Takes a GEOMETRY and returns a SVG representation.
Definition: lwout_svg.c:43
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1006
char ** result
Definition: liblwgeom.h:218

Here is the call graph for this function: