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

Definition at line 448 of file lwgeom_export.c.

References dumpnode::geom, lwgeom_free(), lwgeom_from_gserialized(), lwgeom_to_svg(), and result.

449 {
450  GSERIALIZED *geom;
451  LWGEOM *lwgeom;
452  char *svg;
453  text *result;
454  int relative = 0;
455  int precision=DBL_DIG;
456 
457  if ( PG_ARGISNULL(0) ) PG_RETURN_NULL();
458 
459  geom = (GSERIALIZED *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
460 
461  /* check for relative path notation */
462  if ( PG_NARGS() > 1 && ! PG_ARGISNULL(1) )
463  relative = PG_GETARG_INT32(1) ? 1:0;
464 
465  if ( PG_NARGS() > 2 && ! PG_ARGISNULL(2) )
466  {
467  precision = PG_GETARG_INT32(2);
468  /* TODO: leave this to liblwgeom ? */
469  if ( precision > DBL_DIG )
470  precision = DBL_DIG;
471  else if ( precision < 0 ) precision = 0;
472  }
473 
474  lwgeom = lwgeom_from_gserialized(geom);
475  svg = lwgeom_to_svg(lwgeom, precision, relative);
476  result = cstring2text(svg);
477  lwgeom_free(lwgeom);
478  pfree(svg);
479  PG_FREE_IF_COPY(geom, 0);
480 
481  PG_RETURN_TEXT_P(result);
482 }
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
LWGEOM * geom

Here is the call graph for this function: