PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ geography_as_svg()

Datum geography_as_svg ( PG_FUNCTION_ARGS  )

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

414 {
415  GSERIALIZED *g = NULL;
416  LWGEOM *lwgeom = NULL;
417  char *svg;
418  text *result;
419  int relative = 0;
420  int precision=DBL_DIG;
421 
422  if ( PG_ARGISNULL(0) ) PG_RETURN_NULL();
423 
424  g = PG_GETARG_GSERIALIZED_P(0);
425 
426  /* Convert to lwgeom so we can run the old functions */
427  lwgeom = lwgeom_from_gserialized(g);
428 
429  /* check for relative path notation */
430  if ( PG_NARGS() > 1 && ! PG_ARGISNULL(1) )
431  relative = PG_GETARG_INT32(1) ? 1:0;
432 
433  if ( PG_NARGS() > 2 && ! PG_ARGISNULL(2) )
434  {
435  precision = PG_GETARG_INT32(2);
436  /* TODO: leave this to liblwgeom */
437  if ( precision > DBL_DIG )
438  precision = DBL_DIG;
439  else if ( precision < 0 ) precision = 0;
440  }
441 
442  svg = lwgeom_to_svg(lwgeom, precision, relative);
443 
444  lwgeom_free(lwgeom);
445  PG_FREE_IF_COPY(g, 0);
446 
447  result = cstring2text(svg);
448  lwfree(svg);
449 
450  PG_RETURN_TEXT_P(result);
451 }
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:1099
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: