PostGIS  2.3.8dev-r@@SVN_REVISION@@

◆ LWGEOM_asSVG()

Datum LWGEOM_asSVG ( PG_FUNCTION_ARGS  )

Definition at line 484 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().

485 {
486  GSERIALIZED *geom;
487  LWGEOM *lwgeom;
488  char *svg;
489  text *result;
490  int relative = 0;
491  int precision=DBL_DIG;
492 
493  if ( PG_ARGISNULL(0) ) PG_RETURN_NULL();
494 
495  geom = PG_GETARG_GSERIALIZED_P(0);
496 
497  /* check for relative path notation */
498  if ( PG_NARGS() > 1 && ! PG_ARGISNULL(1) )
499  relative = PG_GETARG_INT32(1) ? 1:0;
500 
501  if ( PG_NARGS() > 2 && ! PG_ARGISNULL(2) )
502  {
503  precision = PG_GETARG_INT32(2);
504  /* TODO: leave this to liblwgeom ? */
505  if ( precision > DBL_DIG )
506  precision = DBL_DIG;
507  else if ( precision < 0 ) precision = 0;
508  }
509 
510  lwgeom = lwgeom_from_gserialized(geom);
511  svg = lwgeom_to_svg(lwgeom, precision, relative);
512  result = cstring2text(svg);
513  lwgeom_free(lwgeom);
514  pfree(svg);
515  PG_FREE_IF_COPY(geom, 0);
516 
517  PG_RETURN_TEXT_P(result);
518 }
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:1063
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: