[postgis-tickets] [SCM] PostGIS branch master updated. 3.3.0rc2-570-g50bb5edd9

git at osgeo.org git at osgeo.org
Thu Jan 26 11:48:05 PST 2023


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "PostGIS".

The branch, master has been updated
       via  50bb5edd95ac430689597ed8b1a12efaa06526b6 (commit)
      from  f8a0f8132aa321e2a62aef83dea358424fe4401b (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 50bb5edd95ac430689597ed8b1a12efaa06526b6
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Thu Jan 26 11:47:48 2023 -0800

    Convert AsSVG to use stringbuffer_t

diff --git a/liblwgeom/lwout_svg.c b/liblwgeom/lwout_svg.c
index 2151ab2fa..5b2ecbde6 100644
--- a/liblwgeom/lwout_svg.c
+++ b/liblwgeom/lwout_svg.c
@@ -33,446 +33,243 @@
 **********************************************************************/
 
 #include "liblwgeom_internal.h"
+#include "stringbuffer.h"
 
-static lwvarlena_t *assvg_point(const LWPOINT *point, int relative, int precision);
-static lwvarlena_t *assvg_line(const LWLINE *line, int relative, int precision);
-static lwvarlena_t *assvg_polygon(const LWPOLY *poly, int relative, int precision);
-static lwvarlena_t *assvg_multipoint(const LWMPOINT *mpoint, int relative, int precision);
-static lwvarlena_t *assvg_multiline(const LWMLINE *mline, int relative, int precision);
-static lwvarlena_t *assvg_multipolygon(const LWMPOLY *mpoly, int relative, int precision);
-static lwvarlena_t *assvg_collection(const LWCOLLECTION *col, int relative, int precision);
 
-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);
-static size_t pointArray_svg_size(POINTARRAY *pa, int precision);
-static size_t pointArray_svg_rel(POINTARRAY *pa, char * output, int close_ring, int precision);
-static size_t pointArray_svg_abs(POINTARRAY *pa, char * output, int close_ring, int precision);
+static void
+assvg_geom(stringbuffer_t* sb, const LWGEOM *geom, int relative, int precision);
 
 
-/**
- * Takes a GEOMETRY and returns a SVG representation
- */
-lwvarlena_t *
-lwgeom_to_svg(const LWGEOM *geom, int precision, int relative)
+static void
+pointArray_svg_rel(stringbuffer_t* sb, const POINTARRAY *pa, int close_ring, int precision)
 {
-	lwvarlena_t *ret = NULL;
-	int type = geom->type;
+	int i, end;
+	const POINT2D *pt;
 
-	/* Empty varlena for empties */
-	if( lwgeom_is_empty(geom) )
-	{
-		lwvarlena_t *v = lwalloc(LWVARHDRSZ);
-		LWSIZE_SET(v->size, LWVARHDRSZ);
-		return v;
-	}
+	double f = 1.0;
+	double dx, dy, x, y, accum_x, accum_y;
 
-	switch (type)
-	{
-	case POINTTYPE:
-		ret = assvg_point((LWPOINT*)geom, relative, precision);
-		break;
-	case LINETYPE:
-		ret = assvg_line((LWLINE*)geom, relative, precision);
-		break;
-	case POLYGONTYPE:
-		ret = assvg_polygon((LWPOLY*)geom, relative, precision);
-		break;
-	case MULTIPOINTTYPE:
-		ret = assvg_multipoint((LWMPOINT*)geom, relative, precision);
-		break;
-	case MULTILINETYPE:
-		ret = assvg_multiline((LWMLINE*)geom, relative, precision);
-		break;
-	case MULTIPOLYGONTYPE:
-		ret = assvg_multipolygon((LWMPOLY*)geom, relative, precision);
-		break;
-	case COLLECTIONTYPE:
-		ret = assvg_collection((LWCOLLECTION*)geom, relative, precision);
-		break;
+	char sx[OUT_DOUBLE_BUFFER_SIZE];
+	char sy[OUT_DOUBLE_BUFFER_SIZE];
 
-	default:
-		lwerror("lwgeom_to_svg: '%s' geometry type not supported",
-		        lwtype_name(type));
+	if (precision >= 0)
+	{
+		f = pow(10, precision);
 	}
 
-	return ret;
-}
+	end = close_ring ? pa->npoints : pa->npoints - 1;
 
+	/* Starting point */
+	pt = getPoint2d_cp(pa, 0);
 
-/**
- * Point Geometry
- */
+	x = round(pt->x*f)/f;
+	y = round(pt->y*f)/f;
 
-static size_t
-assvg_point_size(__attribute__((__unused__)) const LWPOINT *point, int circle, int precision)
-{
-	size_t size;
+	lwprint_double(x, precision, sx);
+	lwprint_double(-y, precision, sy);
 
-	size = (OUT_MAX_BYTES_DOUBLE + precision) * 2;
-	if (circle) size += sizeof("cx='' cy=''");
-	else size += sizeof("x='' y=''");
+	stringbuffer_aprintf(sb, "%s %s l", sx, sy);
 
-	return size;
-}
-
-static size_t
-assvg_point_buf(const LWPOINT *point, char * output, int circle, int precision)
-{
-	char *ptr=output;
-	char x[OUT_DOUBLE_BUFFER_SIZE];
-	char y[OUT_DOUBLE_BUFFER_SIZE];
-	POINT2D pt;
+	/* accum */
+	accum_x = x;
+	accum_y = y;
 
-	getPoint2d_p(point->point, 0, &pt);
+	/* All the following ones */
+	for (i = 1; i < end; i++)
+	{
+		pt = getPoint2d_cp(pa, i);
 
-	lwprint_double(pt.x, precision, x);
-	lwprint_double(-pt.y, precision, y);
+		x = round(pt->x*f)/f;
+		y = round(pt->y*f)/f;
 
-	if (circle) ptr += sprintf(ptr, "x=\"%s\" y=\"%s\"", x, y);
-	else ptr += sprintf(ptr, "cx=\"%s\" cy=\"%s\"", x, y);
+		dx = x - accum_x;
+		dy = y - accum_y;
 
-	return (ptr-output);
-}
+		accum_x += dx;
+		accum_y += dy;
 
-static lwvarlena_t *
-assvg_point(const LWPOINT *point, int circle, int precision)
-{
-	size_t size = assvg_point_size(point, circle, precision);
-	lwvarlena_t *v = lwalloc(LWVARHDRSZ + size);
-	size = assvg_point_buf(point, v->data, circle, precision);
-	LWSIZE_SET(v->size, LWVARHDRSZ + size);
-	return v;
+		lwprint_double(dx, precision, sx);
+		lwprint_double(-dy, precision, sy);
+		stringbuffer_aprintf(sb, " %s %s", sx, sy);
+	}
 }
 
 
 /**
- * Line Geometry
+ * Returns maximum size of rendered pointarray in bytes.
  */
-
-static size_t
-assvg_line_size(const LWLINE *line, __attribute__((__unused__)) int relative, int precision)
+static void
+pointArray_svg_abs(stringbuffer_t* sb, const POINTARRAY *pa, int close_ring, int precision)
 {
-	size_t size;
+	int i, end;
+	const POINT2D* pt;
+	char sx[OUT_DOUBLE_BUFFER_SIZE];
+	char sy[OUT_DOUBLE_BUFFER_SIZE];
 
-	size = sizeof("M ");
-	size += pointArray_svg_size(line->points, precision);
+	end = close_ring ? pa->npoints : pa->npoints - 1;
 
-	return size;
-}
+	for (i = 0; i < end; i++)
+	{
+		pt = getPoint2d_cp(pa, i);
 
-static size_t
-assvg_line_buf(const LWLINE *line, char * output, int relative, int precision)
-{
-	char *ptr=output;
+		if (i == 1) stringbuffer_append(sb, " L ");
+		else if (i) stringbuffer_append(sb, " ");
 
-	/* Start path with SVG MoveTo */
-	ptr += sprintf(ptr, "M ");
-	if (relative)
-		ptr += pointArray_svg_rel(line->points, ptr, 1, precision);
-	else
-		ptr += pointArray_svg_abs(line->points, ptr, 1, precision);
+		lwprint_double(pt->x, precision, sx);
+		lwprint_double(-(pt->y), precision, sy);
 
-	return (ptr-output);
+		stringbuffer_aprintf(sb, "%s %s", sx, sy);
+	}
 }
 
-static lwvarlena_t *
-assvg_line(const LWLINE *line, int relative, int precision)
-{
-	size_t size = assvg_line_size(line, relative, precision);
-	lwvarlena_t *v = lwalloc(LWVARHDRSZ + size);
-	size = assvg_line_buf(line, v->data, relative, precision);
-	LWSIZE_SET(v->size, LWVARHDRSZ + size);
-	return v;
-}
 
+static void
+assvg_point(stringbuffer_t* sb, const LWPOINT *point, int circle, int precision)
+{
+	char sx[OUT_DOUBLE_BUFFER_SIZE];
+	char sy[OUT_DOUBLE_BUFFER_SIZE];
 
-/**
- * Polygon Geometry
- */
+	const POINT2D* pt = getPoint2d_cp(point->point, 0);
+	lwprint_double(pt->x, precision, sx);
+	lwprint_double(-(pt->y), precision, sy);
 
-static size_t
-assvg_polygon_size(const LWPOLY *poly, __attribute__((__unused__)) int relative, int precision)
-{
-	uint32_t i;
-	size_t size=0;
+	stringbuffer_aprintf(sb,
+		circle ? "x=\"%s\" y=\"%s\"" : "cx=\"%s\" cy=\"%s\"",
+		sx, sy);
+}
 
-	for (i=0; i<poly->nrings; i++)
-		size += pointArray_svg_size(poly->rings[i], precision) + sizeof(" ");
-	size += sizeof("M  Z") * poly->nrings;
 
-	return size;
+static void
+assvg_line(stringbuffer_t* sb, const LWLINE *line, int relative, int precision)
+{
+	/* Start path with SVG MoveTo */
+	stringbuffer_append(sb, "M ");
+	if (relative)
+		pointArray_svg_rel(sb, line->points, 1, precision);
+	else
+		pointArray_svg_abs(sb, line->points, 1, precision);
 }
 
-static size_t
-assvg_polygon_buf(const LWPOLY *poly, char * output, int relative, int precision)
+
+static void
+assvg_polygon(stringbuffer_t* sb, const LWPOLY *poly, int relative, int precision)
 {
 	uint32_t i;
-	char *ptr=output;
 
-	for (i=0; i<poly->nrings; i++)
+	for (i = 0; i<poly->nrings; i++)
 	{
-		if (i) ptr += sprintf(ptr, " ");	/* Space beetween each ring */
-		ptr += sprintf(ptr, "M ");		/* Start path with SVG MoveTo */
+		if (i) stringbuffer_append(sb, " ");	/* Space beetween each ring */
+		stringbuffer_append(sb, "M ");		/* Start path with SVG MoveTo */
 
 		if (relative)
 		{
-			ptr += pointArray_svg_rel(poly->rings[i], ptr, 0, precision);
-			ptr += sprintf(ptr, " z");	/* SVG closepath */
+			pointArray_svg_rel(sb, poly->rings[i], 0, precision);
+			stringbuffer_append(sb, " z");	/* SVG closepath */
 		}
 		else
 		{
-			ptr += pointArray_svg_abs(poly->rings[i], ptr, 0, precision);
-			ptr += sprintf(ptr, " Z");	/* SVG closepath */
+			pointArray_svg_abs(sb, poly->rings[i], 0, precision);
+			stringbuffer_append(sb, " Z");	/* SVG closepath */
 		}
 	}
-
-	return (ptr-output);
 }
 
-static lwvarlena_t *
-assvg_polygon(const LWPOLY *poly, int relative, int precision)
-{
-	size_t size = assvg_polygon_size(poly, relative, precision);
-	lwvarlena_t *v = lwalloc(LWVARHDRSZ + size);
-	size = assvg_polygon_buf(poly, v->data, relative, precision);
-	LWSIZE_SET(v->size, LWVARHDRSZ + size);
-	return v;
-}
-
-
-/**
- * Multipoint Geometry
- */
-
-static size_t
-assvg_multipoint_size(const LWMPOINT *mpoint, int relative, int precision)
-{
-	const LWPOINT *point;
-	size_t size=0;
-	uint32_t i;
-
-	for (i=0 ; i<mpoint->ngeoms ; i++)
-	{
-		point = mpoint->geoms[i];
-		size += assvg_point_size(point, relative, precision);
-	}
-	size += sizeof(",") * --i;  /* Arbitrary comma separator */
-
-	return size;
-}
 
-static size_t
-assvg_multipoint_buf(const LWMPOINT *mpoint, char *output, int relative, int precision)
+static void
+assvg_multipoint(stringbuffer_t* sb, const LWMPOINT *mpoint, int relative, int precision)
 {
 	const LWPOINT *point;
 	uint32_t i;
-	char *ptr=output;
 
-	for (i=0 ; i<mpoint->ngeoms ; i++)
+	for (i = 0; i<mpoint->ngeoms; i++)
 	{
-		if (i) ptr += sprintf(ptr, ",");  /* Arbitrary comma separator */
+		if (i) stringbuffer_append(sb, ",");  /* Arbitrary comma separator */
 		point = mpoint->geoms[i];
-		ptr += assvg_point_buf(point, ptr, relative, precision);
+		assvg_point(sb, point, relative, precision);
 	}
-
-	return (ptr-output);
 }
 
-static lwvarlena_t *
-assvg_multipoint(const LWMPOINT *mpoint, int relative, int precision)
-{
-	size_t size = assvg_multipoint_size(mpoint, relative, precision);
-	lwvarlena_t *v = lwalloc(LWVARHDRSZ + size);
-	size = assvg_multipoint_buf(mpoint, v->data, relative, precision);
-	LWSIZE_SET(v->size, LWVARHDRSZ + size);
-	return v;
-}
-
-
-/**
- * Multiline Geometry
- */
-
-static size_t
-assvg_multiline_size(const LWMLINE *mline, int relative, int precision)
-{
-	const LWLINE *line;
-	size_t size=0;
-	uint32_t i;
-
-	for (i=0 ; i<mline->ngeoms ; i++)
-	{
-		line = mline->geoms[i];
-		size += assvg_line_size(line, relative, precision);
-	}
-	size += sizeof(" ") * --i;   /* SVG whitespace Separator */
-
-	return size;
-}
 
-static size_t
-assvg_multiline_buf(const LWMLINE *mline, char *output, int relative, int precision)
+static void
+assvg_multiline(stringbuffer_t* sb, const LWMLINE *mline, int relative, int precision)
 {
 	const LWLINE *line;
 	uint32_t i;
-	char *ptr=output;
 
-	for (i=0 ; i<mline->ngeoms ; i++)
+	for (i = 0; i<mline->ngeoms; i++)
 	{
-		if (i) ptr += sprintf(ptr, " ");  /* SVG whitespace Separator */
+		if (i) stringbuffer_append(sb, " ");  /* SVG whitespace Separator */
 		line = mline->geoms[i];
-		ptr += assvg_line_buf(line, ptr, relative, precision);
+		assvg_line(sb, line, relative, precision);
 	}
-
-	return (ptr-output);
 }
 
-static lwvarlena_t *
-assvg_multiline(const LWMLINE *mline, int relative, int precision)
-{
-	size_t size = assvg_multiline_size(mline, relative, precision);
-	lwvarlena_t *v = lwalloc(LWVARHDRSZ + size);
-	size = assvg_multiline_buf(mline, v->data, relative, precision);
-	LWSIZE_SET(v->size, LWVARHDRSZ + size);
-	return v;
-}
 
-
-/*
- * Multipolygon Geometry
- */
-
-static size_t
-assvg_multipolygon_size(const LWMPOLY *mpoly, int relative, int precision)
+static void
+assvg_multipolygon(stringbuffer_t* sb, const LWMPOLY *mpoly, int relative, int precision)
 {
 	const LWPOLY *poly;
-	size_t size=0;
 	uint32_t i;
 
-	for (i=0 ; i<mpoly->ngeoms ; i++)
+	for (i = 0; i<mpoly->ngeoms; i++)
 	{
+		if (i) stringbuffer_append(sb, " ");  /* SVG whitespace Separator */
 		poly = mpoly->geoms[i];
-		size += assvg_polygon_size(poly, relative, precision);
+		assvg_polygon(sb, poly, relative, precision);
 	}
-	size += sizeof(" ") * --i;   /* SVG whitespace Separator */
 
-	return size;
 }
 
-static size_t
-assvg_multipolygon_buf(const LWMPOLY *mpoly, char *output, int relative, int precision)
-{
-	const LWPOLY *poly;
-	uint32_t i;
-	char *ptr=output;
 
-	for (i=0 ; i<mpoly->ngeoms ; i++)
-	{
-		if (i) ptr += sprintf(ptr, " ");  /* SVG whitespace Separator */
-		poly = mpoly->geoms[i];
-		ptr += assvg_polygon_buf(poly, ptr, relative, precision);
-	}
-
-	return (ptr-output);
-}
-
-static lwvarlena_t *
-assvg_multipolygon(const LWMPOLY *mpoly, int relative, int precision)
-{
-	size_t size = assvg_multipolygon_size(mpoly, relative, precision);
-	lwvarlena_t *v = lwalloc(LWVARHDRSZ + size);
-	size = assvg_multipolygon_buf(mpoly, v->data, relative, precision);
-	LWSIZE_SET(v->size, LWVARHDRSZ + size);
-	return v;
-}
-
-
-/**
-* Collection Geometry
-*/
-
-static size_t
-assvg_collection_size(const LWCOLLECTION *col, int relative, int precision)
-{
-	uint32_t i = 0;
-	size_t size=0;
-	const LWGEOM *subgeom;
-
-	for (i=0; i<col->ngeoms; i++)
-	{
-		subgeom = col->geoms[i];
-		size += assvg_geom_size(subgeom, relative, precision);
-	}
-
-	if ( i ) /* We have some geometries, so add space for delimiters. */
-		size += sizeof(";") * --i;
-
-	if (size == 0) size++; /* GEOMETRYCOLLECTION EMPTY, space for null terminator */
-
-	return size;
-}
-
-static size_t
-assvg_collection_buf(const LWCOLLECTION *col, char *output, int relative, int precision)
+static void
+assvg_collection(stringbuffer_t* sb, const LWCOLLECTION *col, int relative, int precision)
 {
 	uint32_t i;
-	char *ptr=output;
 	const LWGEOM *subgeom;
 
 	/* EMPTY GEOMETRYCOLLECTION */
-	if (col->ngeoms == 0) *ptr = '\0';
+	if (col->ngeoms == 0) return;
 
-	for (i=0; i<col->ngeoms; i++)
+	for (i = 0; i<col->ngeoms; i++)
 	{
-		if (i) ptr += sprintf(ptr, ";");
+		if (i) stringbuffer_append(sb, ";");
 		subgeom = col->geoms[i];
-		ptr += assvg_geom_buf(subgeom, ptr, relative, precision);
+		assvg_geom(sb, subgeom, relative, precision);
 	}
 
-	return (ptr - output);
 }
 
-static lwvarlena_t *
-assvg_collection(const LWCOLLECTION *col, int relative, int precision)
-{
-	size_t size = assvg_collection_size(col, relative, precision);
-	lwvarlena_t *v = lwalloc(LWVARHDRSZ + size);
-	size = assvg_collection_buf(col, v->data, relative, precision);
-	LWSIZE_SET(v->size, LWVARHDRSZ + size);
-	return v;
-}
 
 
-static size_t
-assvg_geom_buf(const LWGEOM *geom, char *output, int relative, int precision)
+static void
+assvg_geom(stringbuffer_t* sb, const LWGEOM *geom, int relative, int precision)
 {
     int type = geom->type;
-	char *ptr=output;
 
 	switch (type)
 	{
 	case POINTTYPE:
-		ptr += assvg_point_buf((LWPOINT*)geom, ptr, relative, precision);
+		assvg_point(sb, (LWPOINT*)geom, relative, precision);
 		break;
 
 	case LINETYPE:
-		ptr += assvg_line_buf((LWLINE*)geom, ptr, relative, precision);
+		assvg_line(sb, (LWLINE*)geom, relative, precision);
 		break;
 
 	case POLYGONTYPE:
-		ptr += assvg_polygon_buf((LWPOLY*)geom, ptr, relative, precision);
+		assvg_polygon(sb, (LWPOLY*)geom, relative, precision);
 		break;
 
 	case MULTIPOINTTYPE:
-		ptr += assvg_multipoint_buf((LWMPOINT*)geom, ptr, relative, precision);
+		assvg_multipoint(sb, (LWMPOINT*)geom, relative, precision);
 		break;
 
 	case MULTILINETYPE:
-		ptr += assvg_multiline_buf((LWMLINE*)geom, ptr, relative, precision);
+		assvg_multiline(sb, (LWMLINE*)geom, relative, precision);
 		break;
 
 	case MULTIPOLYGONTYPE:
-		ptr += assvg_multipolygon_buf((LWMPOLY*)geom, ptr, relative, precision);
+		assvg_multipolygon(sb, (LWMPOLY*)geom, relative, precision);
 		break;
 
 	default:
@@ -480,150 +277,58 @@ assvg_geom_buf(const LWGEOM *geom, char *output, int relative, int precision)
 		        lwtype_name(type));
 	}
 
-	return (ptr-output);
 }
 
 
-static size_t
-assvg_geom_size(const LWGEOM *geom, int relative, int precision)
+
+
+/**
+ * Takes a GEOMETRY and returns a SVG representation
+ */
+lwvarlena_t *
+lwgeom_to_svg(const LWGEOM *geom, int precision, int relative)
 {
-    int type = geom->type;
-	size_t size = 0;
+	stringbuffer_t sb;
+	int type = geom->type;
+
+	/* Empty varlena for empties */
+	if(lwgeom_is_empty(geom))
+	{
+		lwvarlena_t *v = lwalloc(LWVARHDRSZ);
+		LWSIZE_SET(v->size, LWVARHDRSZ);
+		return v;
+	}
+
+	stringbuffer_init_varlena(&sb);
 
 	switch (type)
 	{
 	case POINTTYPE:
-		size = assvg_point_size((LWPOINT*)geom, relative, precision);
+		assvg_point(&sb, (LWPOINT*)geom, relative, precision);
 		break;
-
 	case LINETYPE:
-		size = assvg_line_size((LWLINE*)geom, relative, precision);
+		assvg_line(&sb, (LWLINE*)geom, relative, precision);
 		break;
-
 	case POLYGONTYPE:
-		size = assvg_polygon_size((LWPOLY*)geom, relative, precision);
+		assvg_polygon(&sb, (LWPOLY*)geom, relative, precision);
 		break;
-
 	case MULTIPOINTTYPE:
-		size = assvg_multipoint_size((LWMPOINT*)geom, relative, precision);
+		assvg_multipoint(&sb, (LWMPOINT*)geom, relative, precision);
 		break;
-
 	case MULTILINETYPE:
-		size = assvg_multiline_size((LWMLINE*)geom, relative, precision);
+		assvg_multiline(&sb, (LWMLINE*)geom, relative, precision);
 		break;
-
 	case MULTIPOLYGONTYPE:
-		size = assvg_multipolygon_size((LWMPOLY*)geom, relative, precision);
+		assvg_multipolygon(&sb, (LWMPOLY*)geom, relative, precision);
+		break;
+	case COLLECTIONTYPE:
+		assvg_collection(&sb, (LWCOLLECTION*)geom, relative, precision);
 		break;
 
 	default:
-		lwerror("assvg_geom_size: '%s' geometry type not supported.",
-		        lwtype_name(type));
+		lwerror("lwgeom_to_svg: '%s' geometry type not supported", lwtype_name(type));
 	}
 
-	return size;
+	return stringbuffer_getvarlena(&sb);
 }
 
-
-static size_t
-pointArray_svg_rel(POINTARRAY *pa, char *output, int close_ring, int precision)
-{
-	int i, end;
-	char *ptr;
-	char sx[OUT_DOUBLE_BUFFER_SIZE];
-	char sy[OUT_DOUBLE_BUFFER_SIZE];
-	const POINT2D *pt;
-
-	double f = 1.0;
-	double dx, dy, x, y, accum_x, accum_y;
-
-	ptr = output;
-
-	if (precision >= 0)
-	{
-		f = pow(10, precision);
-	}
-
-	if (close_ring) end = pa->npoints;
-	else end = pa->npoints - 1;
-
-	/* Starting point */
-	pt = getPoint2d_cp(pa, 0);
-
-	x = round(pt->x*f)/f;
-	y = round(pt->y*f)/f;
-
-	lwprint_double(x, precision, sx);
-	lwprint_double(-y, precision, sy);
-	ptr += sprintf(ptr,"%s %s l", sx, sy);
-
-	/* accum */
-	accum_x = x;
-	accum_y = y;
-
-	/* All the following ones */
-	for (i=1 ; i < end ; i++)
-	{
-		// lpt = pt;
-
-		pt = getPoint2d_cp(pa, i);
-
-		x = round(pt->x*f)/f;
-		y = round(pt->y*f)/f;
-		dx = x - accum_x;
-		dy = y - accum_y;
-
-		lwprint_double(dx, precision, sx);
-		lwprint_double(-dy, precision, sy);
-
-		accum_x += dx;
-		accum_y += dy;
-
-		ptr += sprintf(ptr," %s %s", sx, sy);
-	}
-
-	return (ptr-output);
-}
-
-
-/**
- * Returns maximum size of rendered pointarray in bytes.
- */
-static size_t
-pointArray_svg_abs(POINTARRAY *pa, char *output, int close_ring, int precision)
-{
-	int i, end;
-	char *ptr;
-	char x[OUT_DOUBLE_BUFFER_SIZE];
-	char y[OUT_DOUBLE_BUFFER_SIZE];
-	POINT2D pt;
-
-	ptr = output;
-
-	if (close_ring) end = pa->npoints;
-	else end = pa->npoints - 1;
-
-	for (i=0 ; i < end ; i++)
-	{
-		getPoint2d_p(pa, i, &pt);
-
-		lwprint_double(pt.x, precision, x);
-		lwprint_double(-pt.y, precision, y);
-
-		if (i == 1) ptr += sprintf(ptr, " L ");
-		else if (i) ptr += sprintf(ptr, " ");
-		ptr += sprintf(ptr,"%s %s", x, y);
-	}
-
-	return (ptr-output);
-}
-
-
-/**
- * Returns maximum size of rendered pointarray in bytes.
- */
-static size_t
-pointArray_svg_size(POINTARRAY *pa, int precision)
-{
-	return (OUT_MAX_BYTES_DOUBLE + precision + sizeof(" ")) * 2 * pa->npoints + sizeof(" L ");
-}

-----------------------------------------------------------------------

Summary of changes:
 liblwgeom/lwout_svg.c | 587 +++++++++++++-------------------------------------
 1 file changed, 146 insertions(+), 441 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list