PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ lwgeom_to_svg()

char* lwgeom_to_svg ( const LWGEOM geom,
int  precision,
int  relative 
)

Takes a GEOMETRY and returns a SVG representation.

Definition at line 56 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, ovdump::type, and LWGEOM::type.

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

57 {
58  char *ret = NULL;
59  int type = geom->type;
60 
61  /* Empty string for empties */
62  if( lwgeom_is_empty(geom) )
63  {
64  ret = lwalloc(1);
65  ret[0] = '\0';
66  return ret;
67  }
68 
69  switch (type)
70  {
71  case POINTTYPE:
72  ret = assvg_point((LWPOINT*)geom, relative, precision);
73  break;
74  case LINETYPE:
75  ret = assvg_line((LWLINE*)geom, relative, precision);
76  break;
77  case POLYGONTYPE:
78  ret = assvg_polygon((LWPOLY*)geom, relative, precision);
79  break;
80  case MULTIPOINTTYPE:
81  ret = assvg_multipoint((LWMPOINT*)geom, relative, precision);
82  break;
83  case MULTILINETYPE:
84  ret = assvg_multiline((LWMLINE*)geom, relative, precision);
85  break;
86  case MULTIPOLYGONTYPE:
87  ret = assvg_multipolygon((LWMPOLY*)geom, relative, precision);
88  break;
89  case COLLECTIONTYPE:
90  ret = assvg_collection((LWCOLLECTION*)geom, relative, precision);
91  break;
92 
93  default:
94  lwerror("lwgeom_to_svg: '%s' geometry type not supported",
95  lwtype_name(type));
96  }
97 
98  return ret;
99 }
#define LINETYPE
Definition: liblwgeom.h:86
#define POLYGONTYPE
Definition: liblwgeom.h:87
#define MULTIPOINTTYPE
Definition: liblwgeom.h:88
static char * assvg_multipoint(const LWMPOINT *mpoint, int relative, int precision)
Definition: lwout_svg.c:301
static char * assvg_multiline(const LWMLINE *mline, int relative, int precision)
Definition: lwout_svg.c:353
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:218
static char * assvg_multipolygon(const LWMPOLY *mpoly, int relative, int precision)
Definition: lwout_svg.c:405
uint8_t precision
Definition: cu_in_twkb.c:25
static char * assvg_collection(const LWCOLLECTION *col, int relative, int precision)
Definition: lwout_svg.c:464
static char * assvg_line(const LWLINE *line, int relative, int precision)
Definition: lwout_svg.c:192
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:90
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:85
static char * assvg_point(const LWPOINT *point, int relative, int precision)
Definition: lwout_svg.c:148
uint8_t type
Definition: liblwgeom.h:396
type
Definition: ovdump.py:41
void * lwalloc(size_t size)
Definition: lwutil.c:229
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:1346
static char * assvg_polygon(const LWPOLY *poly, int relative, int precision)
Definition: lwout_svg.c:249
#define MULTILINETYPE
Definition: liblwgeom.h:89
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
#define COLLECTIONTYPE
Definition: liblwgeom.h:91
Here is the call graph for this function:
Here is the caller graph for this function: