PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ LWGEOM_asSVG()

Datum LWGEOM_asSVG ( PG_FUNCTION_ARGS  )

Definition at line 521 of file lwgeom_export.c.

522 {
523  GSERIALIZED *geom;
524  LWGEOM *lwgeom;
525  char *svg;
526  text *result;
527  int relative = 0;
528  int precision=DBL_DIG;
529 
530  if ( PG_ARGISNULL(0) ) PG_RETURN_NULL();
531 
532  geom = PG_GETARG_GSERIALIZED_P(0);
533 
534  /* check for relative path notation */
535  if ( PG_NARGS() > 1 && ! PG_ARGISNULL(1) )
536  relative = PG_GETARG_INT32(1) ? 1:0;
537 
538  if ( PG_NARGS() > 2 && ! PG_ARGISNULL(2) )
539  {
540  precision = PG_GETARG_INT32(2);
541  /* TODO: leave this to liblwgeom ? */
542  if ( precision > DBL_DIG )
543  precision = DBL_DIG;
544  else if ( precision < 0 ) precision = 0;
545  }
546 
547  lwgeom = lwgeom_from_gserialized(geom);
548  svg = lwgeom_to_svg(lwgeom, precision, relative);
549  result = cstring_to_text(svg);
550  lwgeom_free(lwgeom);
551  pfree(svg);
552  PG_FREE_IF_COPY(geom, 0);
553 
554  PG_RETURN_TEXT_P(result);
555 }
static uint8_t precision
Definition: cu_in_twkb.c:25
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:1144

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

Here is the call graph for this function: