PostGIS  2.2.7dev-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 42 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().

43 {
44  char *ret = NULL;
45  int type = geom->type;
46 
47  /* Empty string for empties */
48  if( lwgeom_is_empty(geom) )
49  {
50  ret = lwalloc(1);
51  ret[0] = '\0';
52  return ret;
53  }
54 
55  switch (type)
56  {
57  case POINTTYPE:
58  ret = assvg_point((LWPOINT*)geom, relative, precision);
59  break;
60  case LINETYPE:
61  ret = assvg_line((LWLINE*)geom, relative, precision);
62  break;
63  case POLYGONTYPE:
64  ret = assvg_polygon((LWPOLY*)geom, relative, precision);
65  break;
66  case MULTIPOINTTYPE:
67  ret = assvg_multipoint((LWMPOINT*)geom, relative, precision);
68  break;
69  case MULTILINETYPE:
70  ret = assvg_multiline((LWMLINE*)geom, relative, precision);
71  break;
72  case MULTIPOLYGONTYPE:
73  ret = assvg_multipolygon((LWMPOLY*)geom, relative, precision);
74  break;
75  case COLLECTIONTYPE:
76  ret = assvg_collection((LWCOLLECTION*)geom, relative, precision);
77  break;
78 
79  default:
80  lwerror("lwgeom_to_svg: '%s' geometry type not supported",
81  lwtype_name(type));
82  }
83 
84  return ret;
85 }
#define LINETYPE
Definition: liblwgeom.h:71
#define POLYGONTYPE
Definition: liblwgeom.h:72
#define MULTIPOINTTYPE
Definition: liblwgeom.h:73
static char * assvg_multipoint(const LWMPOINT *mpoint, int relative, int precision)
Definition: lwout_svg.c:287
static char * assvg_multiline(const LWMLINE *mline, int relative, int precision)
Definition: lwout_svg.c:339
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:188
static char * assvg_multipolygon(const LWMPOLY *mpoly, int relative, int precision)
Definition: lwout_svg.c:391
uint8_t precision
Definition: cu_in_twkb.c:25
static char * assvg_collection(const LWCOLLECTION *col, int relative, int precision)
Definition: lwout_svg.c:450
static char * assvg_line(const LWLINE *line, int relative, int precision)
Definition: lwout_svg.c:178
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:75
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:70
static char * assvg_point(const LWPOINT *point, int relative, int precision)
Definition: lwout_svg.c:134
uint8_t type
Definition: liblwgeom.h:380
void * lwalloc(size_t size)
Definition: lwutil.c:199
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:1297
static char * assvg_polygon(const LWPOLY *poly, int relative, int precision)
Definition: lwout_svg.c:235
#define MULTILINETYPE
Definition: liblwgeom.h:74
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:74
#define COLLECTIONTYPE
Definition: liblwgeom.h:76

Here is the call graph for this function:

Here is the caller graph for this function: