[postgis-tickets] [SCM] PostGIS branch master updated. 3.3.0rc2-684-ga3894467c

git at osgeo.org git at osgeo.org
Tue Mar 7 21:30:24 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  a3894467c6c6ca856a51cf993a4dc19730f42cec (commit)
      from  d048d7448e2735a34b1c813d2f04fd9c0ec5f0e0 (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 a3894467c6c6ca856a51cf993a4dc19730f42cec
Author: Regina Obe <lr at pcorp.us>
Date:   Wed Mar 8 00:28:40 2023 -0500

    Crash on ST_AsSVG with empties
    References #5350 for PostGIS 3.4.0

diff --git a/doc/xsl/postgis_gardentest.sql.xsl b/doc/xsl/postgis_gardentest.sql.xsl
index 0f14d1dbe..070a2b845 100644
--- a/doc/xsl/postgis_gardentest.sql.xsl
+++ b/doc/xsl/postgis_gardentest.sql.xsl
@@ -10,7 +10,7 @@
 	<xsl:output method="text" />
 	<xsl:variable name='testversion'>3.4.0</xsl:variable>
 	<xsl:variable name='fnexclude14'>AddGeometryColumn DropGeometryColumn DropGeometryTable</xsl:variable>
-	<xsl:variable name='fnexclude'>AddGeometryColumn DropGeometryColumn DropGeometryTable ST_AsSVG</xsl:variable>
+	<xsl:variable name='fnexclude'>AddGeometryColumn DropGeometryColumn DropGeometryTable</xsl:variable>
 	<!--This is just a place holder to state functions not supported or tested separately -->
 
 	<xsl:variable name='var_srid'>3395</xsl:variable>
diff --git a/liblwgeom/lwout_svg.c b/liblwgeom/lwout_svg.c
index 5b2ecbde6..fc96c1634 100644
--- a/liblwgeom/lwout_svg.c
+++ b/liblwgeom/lwout_svg.c
@@ -128,14 +128,15 @@ assvg_point(stringbuffer_t* sb, const LWPOINT *point, int circle, int precision)
 {
 	char sx[OUT_DOUBLE_BUFFER_SIZE];
 	char sy[OUT_DOUBLE_BUFFER_SIZE];
+	if ( !lwgeom_is_empty((LWGEOM*)point) ){
+		const POINT2D* pt = getPoint2d_cp(point->point, 0);
+		lwprint_double(pt->x, precision, sx);
+		lwprint_double(-(pt->y), precision, sy);
 
-	const POINT2D* pt = getPoint2d_cp(point->point, 0);
-	lwprint_double(pt->x, precision, sx);
-	lwprint_double(-(pt->y), precision, sy);
-
-	stringbuffer_aprintf(sb,
-		circle ? "x=\"%s\" y=\"%s\"" : "cx=\"%s\" cy=\"%s\"",
-		sx, sy);
+		stringbuffer_aprintf(sb,
+			circle ? "x=\"%s\" y=\"%s\"" : "cx=\"%s\" cy=\"%s\"",
+			sx, sy);
+	}
 }
 
 
@@ -224,7 +225,7 @@ assvg_multipolygon(stringbuffer_t* sb, const LWMPOLY *mpoly, int relative, int p
 static void
 assvg_collection(stringbuffer_t* sb, const LWCOLLECTION *col, int relative, int precision)
 {
-	uint32_t i;
+	uint32_t i; uint32_t j = 0;
 	const LWGEOM *subgeom;
 
 	/* EMPTY GEOMETRYCOLLECTION */
@@ -232,9 +233,15 @@ assvg_collection(stringbuffer_t* sb, const LWCOLLECTION *col, int relative, int
 
 	for (i = 0; i<col->ngeoms; i++)
 	{
-		if (i) stringbuffer_append(sb, ";");
 		subgeom = col->geoms[i];
-		assvg_geom(sb, subgeom, relative, precision);
+		if (!lwgeom_is_empty(subgeom) ){
+			/** Note the j is to prevent adding a ;
+			 * if the first geometry is empty, but subsequent aren't
+			 **/
+			if (j) stringbuffer_append(sb, ";");
+			j++;
+			assvg_geom(sb, subgeom, relative, precision);
+		}
 	}
 
 }
diff --git a/regress/core/tickets.sql b/regress/core/tickets.sql
index fd607f838..55d705187 100644
--- a/regress/core/tickets.sql
+++ b/regress/core/tickets.sql
@@ -1454,6 +1454,9 @@ SELECT
 -- https://trac.osgeo.org/postgis/ticket/5151
 SELECT '#5151', ST_SetPoint(ST_GeomFromText('LINESTRING EMPTY',4326), 1, ST_GeomFromText('POINT(40 50)',4326)) As result;
 
+-- https://trac.osgeo.org/postgis/ticket/5350
+SELECT '#5350',  ST_AsSVG(ST_GeomFromText('GEOMETRYCOLLECTION (POINT EMPTY, LINESTRING (0 0, 1 1))',4326), 3, 5 );
+
 -- https://trac.osgeo.org/postgis/ticket/5139
 SET client_min_messages TO ERROR;
 DROP TABLE IF EXISTS a;
diff --git a/regress/core/tickets_expected b/regress/core/tickets_expected
index 527f84d69..7c2bfbb34 100644
--- a/regress/core/tickets_expected
+++ b/regress/core/tickets_expected
@@ -462,6 +462,7 @@ ERROR:  LWGEOM_addpoint: Invalid offset
 #4799|{"type": "Feature", "geometry": {"type":"Point","crs":{"type":"name","properties":{"name":"EPSG:25832"}},"coordinates":[359667,5651729]}, "properties": {"id": 1, "geom1": {"type":"Point","crs":{"type":"name","properties":{"name":"EPSG:3035"}},"coordinates":[4110471,3103061]}}}
 #5008|f|f
 ERROR:  Line has no points
+#5350|M 0 0 l 1 -1
 #5139|100000
 #5139|1000000
 ERROR:  Geometry contains invalid coordinates

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

Summary of changes:
 doc/xsl/postgis_gardentest.sql.xsl |  2 +-
 liblwgeom/lwout_svg.c              | 27 +++++++++++++++++----------
 regress/core/tickets.sql           |  3 +++
 regress/core/tickets_expected      |  1 +
 4 files changed, 22 insertions(+), 11 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list