PostGIS  2.5.1dev-r@@SVN_REVISION@@

◆ LWGEOM_asSVG()

Datum LWGEOM_asSVG ( PG_FUNCTION_ARGS  )

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

497 {
498  GSERIALIZED *geom;
499  LWGEOM *lwgeom;
500  char *svg;
501  text *result;
502  int relative = 0;
503  int precision=DBL_DIG;
504 
505  if ( PG_ARGISNULL(0) ) PG_RETURN_NULL();
506 
507  geom = PG_GETARG_GSERIALIZED_P(0);
508 
509  /* check for relative path notation */
510  if ( PG_NARGS() > 1 && ! PG_ARGISNULL(1) )
511  relative = PG_GETARG_INT32(1) ? 1:0;
512 
513  if ( PG_NARGS() > 2 && ! PG_ARGISNULL(2) )
514  {
515  precision = PG_GETARG_INT32(2);
516  /* TODO: leave this to liblwgeom ? */
517  if ( precision > DBL_DIG )
518  precision = DBL_DIG;
519  else if ( precision < 0 ) precision = 0;
520  }
521 
522  lwgeom = lwgeom_from_gserialized(geom);
523  svg = lwgeom_to_svg(lwgeom, precision, relative);
524  result = cstring_to_text(svg);
525  lwgeom_free(lwgeom);
526  pfree(svg);
527  PG_FREE_IF_COPY(geom, 0);
528 
529  PG_RETURN_TEXT_P(result);
530 }
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
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: