PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ LWGEOM_asSVG()

Datum LWGEOM_asSVG ( PG_FUNCTION_ARGS  )

Definition at line 482 of file lwgeom_export.c.

483 {
484  GSERIALIZED *geom;
485  LWGEOM *lwgeom;
486  char *svg;
487  text *result;
488  int relative = 0;
489  int precision=DBL_DIG;
490 
491  if ( PG_ARGISNULL(0) ) PG_RETURN_NULL();
492 
493  geom = PG_GETARG_GSERIALIZED_P(0);
494 
495  /* check for relative path notation */
496  if ( PG_NARGS() > 1 && ! PG_ARGISNULL(1) )
497  relative = PG_GETARG_INT32(1) ? 1:0;
498 
499  if ( PG_NARGS() > 2 && ! PG_ARGISNULL(2) )
500  {
501  precision = PG_GETARG_INT32(2);
502  /* TODO: leave this to liblwgeom ? */
503  if ( precision > DBL_DIG )
504  precision = DBL_DIG;
505  else if ( precision < 0 ) precision = 0;
506  }
507 
508  lwgeom = lwgeom_from_gserialized(geom);
509  svg = lwgeom_to_svg(lwgeom, precision, relative);
510  result = cstring_to_text(svg);
511  lwgeom_free(lwgeom);
512  pfree(svg);
513  PG_FREE_IF_COPY(geom, 0);
514 
515  PG_RETURN_TEXT_P(result);
516 }
static uint8_t precision
Definition: cu_in_twkb.c:25
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
Definition: gserialized.c:239
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:1138

References lwgeom_free(), lwgeom_from_gserialized(), lwgeom_to_svg(), and precision.

Here is the call graph for this function: