94 lwerror(
"lwgeom_to_svg: '%s' geometry type not supported",
112 if (circle) size +=
sizeof(
"cx='' cy=''");
113 else size +=
sizeof(
"x='' y=''");
129 sprintf(x,
"%.*f", precision, pt.
x);
131 sprintf(x,
"%g", pt.
x);
136 sprintf(y,
"%.*f", precision, fabs(pt.
y) ? pt.
y * -1 : pt.
y);
138 sprintf(y,
"%g", fabs(pt.
y) ? pt.
y * -1 : pt.
y);
141 if (circle) ptr += sprintf(ptr,
"x=\"%s\" y=\"%s\"", x, y);
142 else ptr += sprintf(ptr,
"cx=\"%s\" cy=\"%s\"", x, y);
182 ptr += sprintf(ptr,
"M ");
215 for (i=0; i<poly->
nrings; i++)
217 size +=
sizeof(
"M Z") * poly->
nrings;
228 for (i=0; i<poly->
nrings; i++)
230 if (i) ptr += sprintf(ptr,
" ");
231 ptr += sprintf(ptr,
"M ");
236 ptr += sprintf(ptr,
" z");
241 ptr += sprintf(ptr,
" Z");
273 for (i=0 ; i<mpoint->
ngeoms ; i++)
275 point = mpoint->
geoms[i];
278 size +=
sizeof(
",") * --i;
290 for (i=0 ; i<mpoint->
ngeoms ; i++)
292 if (i) ptr += sprintf(ptr,
",");
293 point = mpoint->
geoms[i];
325 for (i=0 ; i<mline->
ngeoms ; i++)
327 line = mline->
geoms[i];
330 size +=
sizeof(
" ") * --i;
342 for (i=0 ; i<mline->
ngeoms ; i++)
344 if (i) ptr += sprintf(ptr,
" ");
345 line = mline->
geoms[i];
377 for (i=0 ; i<mpoly->
ngeoms ; i++)
379 poly = mpoly->
geoms[i];
382 size +=
sizeof(
" ") * --i;
394 for (i=0 ; i<mpoly->
ngeoms ; i++)
396 if (i) ptr += sprintf(ptr,
" ");
397 poly = mpoly->
geoms[i];
429 for (i=0; i<col->
ngeoms; i++)
431 subgeom = col->
geoms[i];
436 size +=
sizeof(
";") * --i;
438 if (size == 0) size++;
451 if (col->
ngeoms == 0) *ptr =
'\0';
453 for (i=0; i<col->
ngeoms; i++)
455 if (i) ptr += sprintf(ptr,
";");
456 subgeom = col->
geoms[i];
460 return (ptr - output);
510 lwerror(
"assvg_geom_buf: '%s' geometry type not supported.",
551 lwerror(
"assvg_geom_size: '%s' geometry type not supported.",
569 double dx, dy,
x,
y, accum_x, accum_y;
575 f = pow(10, precision);
578 if (close_ring) end = pa->
npoints;
584 x = round(pt->
x*f)/f;
585 y = round(pt->
y*f)/f;
588 sprintf(sx,
"%.*f", precision, x);
590 sprintf(sx,
"%g", x);
594 sprintf(sy,
"%.*f", precision, fabs(y) ? y * -1 : y);
596 sprintf(sy,
"%g", fabs(y) ? y * -1 : y);
599 ptr += sprintf(ptr,
"%s %s l", sx, sy);
606 for (i=1 ; i < end ; i++)
612 x = round(pt->
x*f)/f;
613 y = round(pt->
y*f)/f;
618 sprintf(sx,
"%.*f", precision, dx);
620 sprintf(sx,
"%g", dx);
625 sprintf(sy,
"%.*f", precision,
626 fabs(dy) ? dy * -1: dy);
629 fabs(dy) ? dy * -1: dy);
635 ptr += sprintf(ptr,
" %s %s", sx, sy);
656 if (close_ring) end = pa->
npoints;
659 for (i=0 ; i < end ; i++)
664 sprintf(x,
"%.*f", precision, pt.
x);
666 sprintf(x,
"%g", pt.
x);
671 sprintf(y,
"%.*f", precision, fabs(pt.
y) ? pt.
y * -1:pt.
y);
673 sprintf(y,
"%g", fabs(pt.
y) ? pt.
y * -1:pt.
y);
676 if (i == 1) ptr += sprintf(ptr,
" L ");
677 else if (i) ptr += sprintf(ptr,
" ");
678 ptr += sprintf(ptr,
"%s %s", x, y);
692 * 2 * pa->
npoints +
sizeof(
" L ");
static size_t assvg_line_buf(const LWLINE *line, char *output, int relative, int precision)
static size_t pointArray_svg_rel(POINTARRAY *pa, char *output, int close_ring, int precision)
#define OUT_MAX_DOUBLE_PRECISION
void trim_trailing_zeros(char *num)
static char * assvg_multipoint(const LWMPOINT *mpoint, int relative, int precision)
static size_t assvg_polygon_buf(const LWPOLY *poly, char *output, int relative, int precision)
static size_t assvg_multipoint_buf(const LWMPOINT *mpoint, char *output, int relative, int precision)
char * lwgeom_to_svg(const LWGEOM *geom, int precision, int relative)
Takes a GEOMETRY and returns a SVG representation.
static size_t assvg_line_size(const LWLINE *line, int relative, int precision)
Line Geometry.
static char * assvg_multiline(const LWMLINE *mline, int relative, int precision)
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
static size_t assvg_multiline_size(const LWMLINE *mline, int relative, int precision)
Multiline Geometry.
const POINT2D * getPoint2d_cp(const POINTARRAY *pa, int n)
Returns a POINT2D pointer into the POINTARRAY serialized_ptlist, suitable for reading from...
static char * assvg_multipolygon(const LWMPOLY *mpoly, int relative, int precision)
static size_t assvg_polygon_size(const LWPOLY *poly, int relative, int precision)
Polygon Geometry.
static size_t assvg_multiline_buf(const LWMLINE *mline, char *output, int relative, int precision)
static size_t assvg_multipoint_size(const LWMPOINT *mpoint, int relative, int precision)
Multipoint Geometry.
static size_t assvg_multipolygon_size(const LWMPOLY *mpoly, int relative, int precision)
static size_t pointArray_svg_size(POINTARRAY *pa, int precision)
Returns maximum size of rendered pointarray in bytes.
static char * assvg_collection(const LWCOLLECTION *col, int relative, int precision)
int getPoint2d_p(const POINTARRAY *pa, int n, POINT2D *point)
static char * assvg_line(const LWLINE *line, int relative, int precision)
static size_t assvg_collection_buf(const LWCOLLECTION *col, char *output, int relative, int precision)
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
static size_t assvg_point_buf(const LWPOINT *point, char *output, int circle, int precision)
static char * assvg_point(const LWPOINT *point, int relative, int precision)
static size_t pointArray_svg_abs(POINTARRAY *pa, char *output, int close_ring, int precision)
Returns maximum size of rendered pointarray in bytes.
static size_t assvg_collection_size(const LWCOLLECTION *col, int relative, int precision)
Collection Geometry.
static size_t assvg_multipolygon_buf(const LWMPOLY *mpoly, char *output, int relative, int precision)
void * lwalloc(size_t size)
#define OUT_MAX_DIGS_DOUBLE
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members) ...
static char * assvg_polygon(const LWPOLY *poly, int relative, int precision)
static size_t assvg_point_size(const LWPOINT *point, int circle, int precision)
Point Geometry.
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
static size_t assvg_geom_size(const LWGEOM *geom, int relative, int precision)
static size_t assvg_geom_buf(const LWGEOM *geom, char *output, int relative, int precision)