PostGIS  2.2.7dev-r@@SVN_REVISION@@
Datum geography_as_svg ( PG_FUNCTION_ARGS  )

Definition at line 398 of file geography_inout.c.

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

399 {
400  GSERIALIZED *g = NULL;
401  LWGEOM *lwgeom = NULL;
402  char *svg;
403  text *result;
404  int relative = 0;
405  int precision=DBL_DIG;
406 
407  if ( PG_ARGISNULL(0) ) PG_RETURN_NULL();
408 
409  g = PG_GETARG_GSERIALIZED_P(0);
410 
411  /* Convert to lwgeom so we can run the old functions */
412  lwgeom = lwgeom_from_gserialized(g);
413 
414  /* check for relative path notation */
415  if ( PG_NARGS() > 1 && ! PG_ARGISNULL(1) )
416  relative = PG_GETARG_INT32(1) ? 1:0;
417 
418  if ( PG_NARGS() > 2 && ! PG_ARGISNULL(2) )
419  {
420  precision = PG_GETARG_INT32(2);
421  /* TODO: leave this to liblwgeom */
422  if ( precision > DBL_DIG )
423  precision = DBL_DIG;
424  else if ( precision < 0 ) precision = 0;
425  }
426 
427  svg = lwgeom_to_svg(lwgeom, precision, relative);
428 
429  lwgeom_free(lwgeom);
430  PG_FREE_IF_COPY(g, 0);
431 
432  result = cstring2text(svg);
433  lwfree(svg);
434 
435  PG_RETURN_TEXT_P(result);
436 }
void lwfree(void *mem)
Definition: lwutil.c:214
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
uint8_t precision
Definition: cu_in_twkb.c:25

Here is the call graph for this function: