PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ geography_as_svg()

Datum geography_as_svg ( PG_FUNCTION_ARGS  )

Definition at line 431 of file geography_inout.c.

432 {
433  GSERIALIZED *g = NULL;
434  LWGEOM *lwgeom = NULL;
435  char *svg;
436  text *result;
437  int relative = 0;
438  int precision=DBL_DIG;
439 
440  if ( PG_ARGISNULL(0) ) PG_RETURN_NULL();
441 
442  g = PG_GETARG_GSERIALIZED_P(0);
443 
444  /* Convert to lwgeom so we can run the old functions */
445  lwgeom = lwgeom_from_gserialized(g);
446 
447  /* check for relative path notation */
448  if ( PG_NARGS() > 1 && ! PG_ARGISNULL(1) )
449  relative = PG_GETARG_INT32(1) ? 1:0;
450 
451  if ( PG_NARGS() > 2 && ! PG_ARGISNULL(2) )
452  {
453  precision = PG_GETARG_INT32(2);
454  /* TODO: leave this to liblwgeom */
455  if ( precision > DBL_DIG )
456  precision = DBL_DIG;
457  else if ( precision < 0 ) precision = 0;
458  }
459 
460  svg = lwgeom_to_svg(lwgeom, precision, relative);
461 
462  lwgeom_free(lwgeom);
463  PG_FREE_IF_COPY(g, 0);
464 
465  result = cstring_to_text(svg);
466  lwfree(svg);
467 
468  PG_RETURN_TEXT_P(result);
469 }
static uint8_t precision
Definition: cu_in_twkb.c:25
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
void lwfree(void *mem)
Definition: lwutil.c:244

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

Here is the call graph for this function: