PostGIS  2.5.1dev-r@@SVN_REVISION@@

◆ geography_as_svg()

Datum geography_as_svg ( PG_FUNCTION_ARGS  )

Definition at line 429 of file geography_inout.c.

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

Referenced by geography_as_kml().

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