PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ LWGEOM_asSVG()

Datum LWGEOM_asSVG ( PG_FUNCTION_ARGS  )

Definition at line 469 of file lwgeom_export.c.

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

Referenced by LWGEOM_asGeoJson().

470 {
471  GSERIALIZED *geom;
472  LWGEOM *lwgeom;
473  char *svg;
474  text *result;
475  int relative = 0;
476  int precision=DBL_DIG;
477 
478  if ( PG_ARGISNULL(0) ) PG_RETURN_NULL();
479 
480  geom = PG_GETARG_GSERIALIZED_P(0);
481 
482  /* check for relative path notation */
483  if ( PG_NARGS() > 1 && ! PG_ARGISNULL(1) )
484  relative = PG_GETARG_INT32(1) ? 1:0;
485 
486  if ( PG_NARGS() > 2 && ! PG_ARGISNULL(2) )
487  {
488  precision = PG_GETARG_INT32(2);
489  /* TODO: leave this to liblwgeom ? */
490  if ( precision > DBL_DIG )
491  precision = DBL_DIG;
492  else if ( precision < 0 ) precision = 0;
493  }
494 
495  lwgeom = lwgeom_from_gserialized(geom);
496  svg = lwgeom_to_svg(lwgeom, precision, relative);
497  result = cstring2text(svg);
498  lwgeom_free(lwgeom);
499  pfree(svg);
500  PG_FREE_IF_COPY(geom, 0);
501 
502  PG_RETURN_TEXT_P(result);
503 }
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:42
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1050
LWGEOM * geom
uint8_t precision
Definition: cu_in_twkb.c:25
Here is the call graph for this function:
Here is the caller graph for this function: