PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ LWGEOM_asSVG()

Datum LWGEOM_asSVG ( PG_FUNCTION_ARGS  )

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

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