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

Definition at line 495 of file lwgeom_export.c.

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

496 {
497  GSERIALIZED *geom;
498  LWGEOM *lwgeom;
499  char *svg;
500  text *result;
501  int relative = 0;
502  int precision=DBL_DIG;
503 
504  if ( PG_ARGISNULL(0) ) PG_RETURN_NULL();
505 
506  geom = PG_GETARG_GSERIALIZED_P(0);
507 
508  /* check for relative path notation */
509  if ( PG_NARGS() > 1 && ! PG_ARGISNULL(1) )
510  relative = PG_GETARG_INT32(1) ? 1:0;
511 
512  if ( PG_NARGS() > 2 && ! PG_ARGISNULL(2) )
513  {
514  precision = PG_GETARG_INT32(2);
515  /* TODO: leave this to liblwgeom ? */
516  if ( precision > DBL_DIG )
517  precision = DBL_DIG;
518  else if ( precision < 0 ) precision = 0;
519  }
520 
521  lwgeom = lwgeom_from_gserialized(geom);
522  svg = lwgeom_to_svg(lwgeom, precision, relative);
523  result = cstring2text(svg);
524  lwgeom_free(lwgeom);
525  pfree(svg);
526  PG_FREE_IF_COPY(geom, 0);
527 
528  PG_RETURN_TEXT_P(result);
529 }
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:56
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1137
LWGEOM * geom
uint8_t precision
Definition: cu_in_twkb.c:25

Here is the call graph for this function: