PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ lwgeom_to_svg()

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

Takes a GEOMETRY and returns a SVG representation.

Definition at line 559 of file lwout_svg.c.

560{
562 int type = geom->type;
563
564 /* Empty varlena for empties */
565 if(lwgeom_is_empty(geom))
566 {
569 return v;
570 }
571
573
574 switch (type)
575 {
576 case POINTTYPE:
577 assvg_point(&sb, (LWPOINT*)geom, relative, precision);
578 break;
579 case LINETYPE:
580 assvg_line(&sb, (LWLINE*)geom, relative, precision);
581 break;
582 case POLYGONTYPE:
583 assvg_polygon(&sb, (LWPOLY*)geom, relative, precision);
584 break;
585 case CIRCSTRINGTYPE:
586 assvg_circstring(&sb, (LWCIRCSTRING*)geom, relative, precision);
587 break;
588 case COMPOUNDTYPE:
589 assvg_compound(&sb, (LWCOMPOUND*)geom, relative, precision);
590 break;
591 case CURVEPOLYTYPE:
592 assvg_curvepoly(&sb, (LWCURVEPOLY*)geom, relative, precision);
593 break;
594 case MULTIPOINTTYPE:
595 assvg_multipoint(&sb, (LWMPOINT*)geom, relative, precision);
596 break;
597 case MULTILINETYPE:
598 assvg_multiline(&sb, (LWMLINE*)geom, relative, precision);
599 break;
600 case MULTICURVETYPE:
601 assvg_multicurve(&sb, (LWMCURVE*)geom, relative, precision);
602 break;
603 case MULTIPOLYGONTYPE:
604 assvg_multipolygon(&sb, (LWMPOLY*)geom, relative, precision);
605 break;
606 case MULTISURFACETYPE:
607 assvg_multisurface(&sb, (LWMSURFACE*)geom, relative, precision);
608 break;
609 case COLLECTIONTYPE:
610 assvg_collection(&sb, (LWCOLLECTION*)geom, relative, precision);
611 break;
612
613 default:
614 lwerror("lwgeom_to_svg: '%s' geometry type not supported", lwtype_name(type));
615 }
616
617 return stringbuffer_getvarlena(&sb);
618}
static uint8_t precision
Definition cu_in_twkb.c:25
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition lwutil.c:216
#define COLLECTIONTYPE
Definition liblwgeom.h:108
#define COMPOUNDTYPE
Definition liblwgeom.h:110
#define LWVARHDRSZ
Definition liblwgeom.h:311
#define CURVEPOLYTYPE
Definition liblwgeom.h:111
#define MULTILINETYPE
Definition liblwgeom.h:106
#define MULTISURFACETYPE
Definition liblwgeom.h:113
#define LINETYPE
Definition liblwgeom.h:103
#define MULTIPOINTTYPE
Definition liblwgeom.h:105
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition liblwgeom.h:102
void * lwalloc(size_t size)
Definition lwutil.c:227
#define MULTIPOLYGONTYPE
Definition liblwgeom.h:107
#define POLYGONTYPE
Definition liblwgeom.h:104
#define CIRCSTRINGTYPE
Definition liblwgeom.h:109
#define LWSIZE_SET(varsize, len)
Definition liblwgeom.h:325
#define MULTICURVETYPE
Definition liblwgeom.h:112
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.
static int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)
Definition lwinline.h:199
static void assvg_compound(stringbuffer_t *sb, const LWCOMPOUND *icompound, int relative, int precision)
Definition lwout_svg.c:261
static void assvg_multipoint(stringbuffer_t *sb, const LWMPOINT *mpoint, int relative, int precision)
Definition lwout_svg.c:332
static void assvg_curvepoly(stringbuffer_t *sb, const LWCURVEPOLY *curvepoly, int relative, int precision)
Definition lwout_svg.c:406
static void assvg_multiline(stringbuffer_t *sb, const LWMLINE *mline, int relative, int precision)
Definition lwout_svg.c:347
static void assvg_multipolygon(stringbuffer_t *sb, const LWMPOLY *mpoly, int relative, int precision)
Definition lwout_svg.c:361
static void assvg_line(stringbuffer_t *sb, const LWLINE *line, int relative, int precision)
Definition lwout_svg.c:152
static void assvg_polygon(stringbuffer_t *sb, const LWPOLY *poly, int relative, int precision)
Definition lwout_svg.c:309
static void assvg_circstring(stringbuffer_t *sb, const LWCIRCSTRING *icurve, int relative, int precision)
Definition lwout_svg.c:253
static void assvg_multicurve(stringbuffer_t *sb, const LWMCURVE *mcurve, int relative, int precision)
Definition lwout_svg.c:375
static void assvg_point(stringbuffer_t *sb, const LWPOINT *point, int circle, int precision)
Definition lwout_svg.c:135
static void assvg_multisurface(stringbuffer_t *sb, const LWMSURFACE *msurface, int relative, int precision)
Definition lwout_svg.c:444
static void assvg_collection(stringbuffer_t *sb, const LWCOLLECTION *col, int relative, int precision)
Definition lwout_svg.c:472
lwvarlena_t * stringbuffer_getvarlena(stringbuffer_t *s)
void stringbuffer_init_varlena(stringbuffer_t *s)
uint8_t type
Definition liblwgeom.h:462
uint32_t size
Definition liblwgeom.h:307

References assvg_circstring(), assvg_collection(), assvg_compound(), assvg_curvepoly(), assvg_line(), assvg_multicurve(), assvg_multiline(), assvg_multipoint(), assvg_multipolygon(), assvg_multisurface(), assvg_point(), assvg_polygon(), CIRCSTRINGTYPE, COLLECTIONTYPE, COMPOUNDTYPE, CURVEPOLYTYPE, LINETYPE, lwalloc(), lwerror(), lwgeom_is_empty(), LWSIZE_SET, lwtype_name(), LWVARHDRSZ, MULTICURVETYPE, MULTILINETYPE, MULTIPOINTTYPE, MULTIPOLYGONTYPE, MULTISURFACETYPE, POINTTYPE, POLYGONTYPE, precision, lwvarlena_t::size, stringbuffer_getvarlena(), stringbuffer_init_varlena(), and LWGEOM::type.

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

Here is the call graph for this function:
Here is the caller graph for this function: