PostGIS  2.1.10dev-r@@SVN_REVISION@@
char* lwgeom_to_svg ( const LWGEOM geom,
int  precision,
int  relative 
)

Takes a GEOMETRY and returns a SVG representation.

Definition at line 43 of file lwout_svg.c.

References assvg_collection(), assvg_line(), assvg_multiline(), assvg_multipoint(), assvg_multipolygon(), assvg_point(), assvg_polygon(), COLLECTIONTYPE, LINETYPE, lwalloc(), lwerror(), lwgeom_is_empty(), lwtype_name(), MULTILINETYPE, MULTIPOINTTYPE, MULTIPOLYGONTYPE, POINTTYPE, POLYGONTYPE, and LWGEOM::type.

Referenced by do_svg_test(), do_svg_unsupported(), geography_as_svg(), and LWGEOM_asSVG().

44 {
45  char *ret = NULL;
46  int type = geom->type;
47 
48  /* Empty string for empties */
49  if( lwgeom_is_empty(geom) )
50  {
51  ret = lwalloc(1);
52  ret[0] = '\0';
53  return ret;
54  }
55 
56  switch (type)
57  {
58  case POINTTYPE:
59  ret = assvg_point((LWPOINT*)geom, relative, precision);
60  break;
61  case LINETYPE:
62  ret = assvg_line((LWLINE*)geom, relative, precision);
63  break;
64  case POLYGONTYPE:
65  ret = assvg_polygon((LWPOLY*)geom, relative, precision);
66  break;
67  case MULTIPOINTTYPE:
68  ret = assvg_multipoint((LWMPOINT*)geom, relative, precision);
69  break;
70  case MULTILINETYPE:
71  ret = assvg_multiline((LWMLINE*)geom, relative, precision);
72  break;
73  case MULTIPOLYGONTYPE:
74  ret = assvg_multipolygon((LWMPOLY*)geom, relative, precision);
75  break;
76  case COLLECTIONTYPE:
77  ret = assvg_collection((LWCOLLECTION*)geom, relative, precision);
78  break;
79 
80  default:
81  lwerror("lwgeom_to_svg: '%s' geometry type not supported",
82  lwtype_name(type));
83  }
84 
85  return ret;
86 }
#define LINETYPE
Definition: liblwgeom.h:61
#define POLYGONTYPE
Definition: liblwgeom.h:62
#define MULTIPOINTTYPE
Definition: liblwgeom.h:63
static char * assvg_multipoint(const LWMPOINT *mpoint, int relative, int precision)
Definition: lwout_svg.c:288
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:67
static char * assvg_multiline(const LWMLINE *mline, int relative, int precision)
Definition: lwout_svg.c:340
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:164
static char * assvg_multipolygon(const LWMPOLY *mpoly, int relative, int precision)
Definition: lwout_svg.c:392
static char * assvg_collection(const LWCOLLECTION *col, int relative, int precision)
Definition: lwout_svg.c:451
static char * assvg_line(const LWLINE *line, int relative, int precision)
Definition: lwout_svg.c:179
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:65
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:60
static char * assvg_point(const LWPOINT *point, int relative, int precision)
Definition: lwout_svg.c:135
uint8_t type
Definition: liblwgeom.h:352
void * lwalloc(size_t size)
Definition: lwutil.c:175
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members) ...
Definition: lwgeom.c:1229
static char * assvg_polygon(const LWPOLY *poly, int relative, int precision)
Definition: lwout_svg.c:236
#define MULTILINETYPE
Definition: liblwgeom.h:64
#define COLLECTIONTYPE
Definition: liblwgeom.h:66

Here is the call graph for this function:

Here is the caller graph for this function: