[postgis-tickets] [SCM] PostGIS; Spatial objects for PostgreSQL. branch master updated. 570fbdb10de728e56957f3b7b449ac9532a53a47

git at osgeo.org git at osgeo.org
Thu Oct 31 05:39:00 PDT 2019


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; Spatial objects for PostgreSQL.".

The branch, master has been updated
       via  570fbdb10de728e56957f3b7b449ac9532a53a47 (commit)
      from  9193bb02d4ccfcb2d5c93c6f8b8de0c35c5ea6b2 (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 570fbdb10de728e56957f3b7b449ac9532a53a47
Author: Raul Marin <git at rmr.ninja>
Date:   Thu Oct 31 10:48:44 2019 +0100

    Fix oversimplification of polygon inner rings
    
    This also adapts a MVT test which is checking whether it crashes with an
    input or not. Since the exact output depends on the backend
    (GEOS vs wagyu), we just ensure the input passes through the function.
    
    Closes #4568
    Closes #4556
    Closes https://github.com/postgis/postgis/pull/504

diff --git a/NEWS b/NEWS
index bba30be..cb9f4b7 100644
--- a/NEWS
+++ b/NEWS
@@ -18,6 +18,7 @@ PostGIS 3.1.0
   - #4545, Fix leak in wkt_parser_triangle_new (Raúl Marín)
   - #4549, Fix several functions when the schema isn't the search_path (Raúl Marín)
   - #4546, Fix PLPGSQL functions missing the schema qualification (Raúl Marín)
+  - #4558, Fix oversimplification of polygon inner rings (Raúl Marín)
 
 
 PostGIS 3.0.0
diff --git a/liblwgeom/cunit/cu_algorithm.c b/liblwgeom/cunit/cu_algorithm.c
index fe50148..a9bb846 100644
--- a/liblwgeom/cunit/cu_algorithm.c
+++ b/liblwgeom/cunit/cu_algorithm.c
@@ -1302,6 +1302,48 @@ static void test_lwgeom_simplify(void)
 	lwgeom_free(g);
 	lwgeom_free(l);
 	lwfree(ewkt);
+
+	/* POLYGON with multiple inner rings*/
+	g = lwgeom_from_wkt(
+	    "POLYGON("
+	    "(0 0, 100 0, 100 100, 0 100, 0 0),"
+	    "(1 1, 1 5, 5 5, 5 1, 1 1),"
+	    "(20 20, 20 40, 40 40, 40 20, 20 20)"
+	    ")",
+	    LW_PARSER_CHECK_NONE);
+	l = lwgeom_simplify(g, 10, LW_FALSE);
+	ewkt = lwgeom_to_ewkt(l);
+	ASSERT_STRING_EQUAL(ewkt, "POLYGON((0 0,100 0,100 100,0 100,0 0),(20 20,20 40,40 40,40 20,20 20))");
+	lwgeom_free(g);
+	lwgeom_free(l);
+	lwfree(ewkt);
+
+	/* Reorder inner rings: Same result */
+	g = lwgeom_from_wkt(
+	    "POLYGON("
+	    "(0 0, 100 0, 100 100, 0 100, 0 0),"
+	    "(20 20, 20 40, 40 40, 40 20, 20 20),"
+	    "(1 1, 1 5, 5 5, 5 1, 1 1)"
+	    ")",
+	    LW_PARSER_CHECK_NONE);
+	l = lwgeom_simplify(g, 10, LW_FALSE);
+	ewkt = lwgeom_to_ewkt(l);
+	ASSERT_STRING_EQUAL(ewkt, "POLYGON((0 0,100 0,100 100,0 100,0 0),(20 20,20 40,40 40,40 20,20 20))");
+	lwgeom_free(g);
+	lwgeom_free(l);
+	lwfree(ewkt);
+
+	g = lwgeom_from_wkt(
+	    "POLYGON("
+	    "(0 0, 100 0, 100 100, 0 100, 0 0),"
+	    "(20 20, 20 40, 40 40, 40 20, 20 20),"
+	    "(1 1, 1 5, 5 5, 5 1, 1 1)"
+	    ")",
+	    LW_PARSER_CHECK_NONE);
+	l = lwgeom_simplify(g, 100, LW_FALSE);
+	CU_ASSERT_EQUAL(l, NULL);
+	lwgeom_free(g);
+	lwgeom_free(l);
 }
 
 
diff --git a/liblwgeom/lwgeom.c b/liblwgeom/lwgeom.c
index 854fa20..a9fbfd4 100644
--- a/liblwgeom/lwgeom.c
+++ b/liblwgeom/lwgeom.c
@@ -1782,14 +1782,22 @@ lwgeom_simplify_in_place(LWGEOM *geom, double epsilon, int preserve_collapsed)
 				/* Drop collapsed rings */
 				if(pa->npoints < 4)
 				{
-					/* Any ring deeper than this one is, by OGR definition, smaller
-					 * so we drop them all */
-					for (; i < g->nrings; i++)
+					if (i == 0)
 					{
-						pa = g->rings[i];
+						/* If the outter ring is dropped, all can be dropped */
+						for (i = 0; i < g->nrings; i++)
+						{
+							pa = g->rings[i];
+							ptarray_free(pa);
+						}
+						break;
+					}
+					else
+					{
+						/* Drop this inner ring only */
 						ptarray_free(pa);
+						continue;
 					}
-					break;
 				}
 				g->rings[j++] = pa;
 			}
diff --git a/regress/core/mvt.sql b/regress/core/mvt.sql
index 491a714..105f584 100644
--- a/regress/core/mvt.sql
+++ b/regress/core/mvt.sql
@@ -577,14 +577,14 @@ SELECT encode(ST_AsMVT(1, 'test', 4096, 'geom'), 'base64');
 SELECT 'TU3', encode(ST_AsMVT(q, 'test', 4096, 'geom'), 'base64')
 	FROM (SELECT NULL::integer AS c1, NULL AS geom) AS q;
 
--- Ticket #3922
-SELECT '#3922', St_Area(ST_AsMVTGeom(
+-- Ticket #3922 (Check for crash)
+SELECT '#3922', St_GeometryType(ST_AsMVTGeom(
 		st_geomfromtwkb('\x06000104a501d0a7db06dad0940120ee030660229604109c010ed6011246143e76201a22b401a601f001b801580ef40122d803ca01de0cf00e80049204ac02b602be0138ca08bc02d605d201d2013cb804a401be013c9c03cd028608c106f001c1018601c7011e970125f10207439b02850a76ff0415030d0725431973132f227768671a5f133f17290865e405ba0154ab030415348502cc038d120c37d326c706850896109f01e201350f6f0a1903930165830121412d052928651d2b0d0f1107170b490c33120f010f0813034f47f50259190181031b3713ed04d901bd01439b02639507c10201021062054c1d3c101e6a0c2000684e6a7c1a681f443d160f044f0f490f03020b08051c01080c0e18013a012801380e08005808522d3a4c1c062a0f0e192a190a3b22194803261c1376122ac201d8011a101c065a17a8011c303206460c164a18a4015c56620801162d1404a402c601262a143002421222290f7b581d0719011d0311002908250a25021d030f0111030f05a3014315050d05110383011b9d011f3309a70347170325058b03417515130361190b4e19b40105fe208810041314041018270705c0039d0416251a1213241b0ffd02f5029408d001990218110607100c070a0b0819031c263432302454322a1e262a101e2a521426101c0c10101210
 121e18341c321c2c1c26222230162a10320c280e3202080e26123e0a2c041a002805360002051e010807161b281b1e1312010213101b14150e0906130c331e3518250e250c230a1d0a110e091407140718031a0008031a03140112093a199a01199801052e04100a0c120a4a0c7e1e2406220c4e20b60236c8013014020c0510090a110e1b0e11140d18021c08261054261417080f082504a702ea012c58068801180e0f1477209301082f062f00271f0b4b17170311020d100b180d180b0c1502190019031f09512d9b01592a1f120d0c0f0a15126b0637060f100b16032c0a2a1410120c120a240014011a03160314001482010100810900311753478d0117218b02b3027a692223745b2a111e031e130403061902691aa50118752ea70158045818562cae0170202614200e2e208a012e6c4a154c33448b01242f34651e2b221d481f2017122334a1010a510f2b6d8d021d5f073304351233242bce01772a251c3106291b4b032110351c2324239c016f260f5c138a01074e14261422282844221c7a24779a022db90127450b174319b501019b015a61b00105782a4e2a7615741305313a14422a4a079c01519001c9019c013388017352291c371c4110497e26442a8a0108502a2e2e19100980011984010b0e01840136042e1a6a22781f32356813280104370a5b12a5012b533e07482
 44e3e54355c064a45880115289d01103904453e810127290b5103a70152174841680b10254814402a4e305e82017232581792010522512e2516370023380b9801125434584c2a3e5202042f4e390f2f0e050205001f0801380d00430515421744fd01311b16614c038001241a482c3e44061e0a3881012605244d0e2d5d291a192c5710759d01284b20150f752308530a7f198101113d145d1f13534727290a291f490f4b0215246b196929752d2f2581012675371d432f090c4d2c0d080b141f0a0034051401110735152921055940010a023c0c0c35030519270825382f104512753e014001ae013b041708356ced012a0f7c2d041d0415631507e501012f0a491327411d1b310811072947493d0843125f4b7b16'),
 		'SRID=3347;POLYGON((3658201 658873,3658201 5958872.97428571,8958201.49428571 5958872.97428571,8958201.49428571 658873,3658201 658873))'::geometry,
 		4096,
 		0,
 		true
-		)) BETWEEN 4.5 AND 6.5;
+		));
 
 SELECT '#4294_Horizontal', ST_AsText(ST_AsMVTGeom(
 	ST_GeomFromText('MULTILINESTRING((0 0, 0 5))'),
diff --git a/regress/core/mvt_expected b/regress/core/mvt_expected
index e88d4b0..bffbca4 100644
--- a/regress/core/mvt_expected
+++ b/regress/core/mvt_expected
@@ -121,7 +121,7 @@ D7|POINT(1 4094)
 TU2
 ERROR:  pgis_asmvt_transfn: parameter row cannot be other than a rowtype
 TU3|
-#3922|t
+#3922|ST_Polygon
 #4294_Horizontal|LINESTRING(0 10,0 5)
 #4294_Vertical|LINESTRING(0 10,5 10)
 #4314|

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

Summary of changes:
 NEWS                           |  1 +
 liblwgeom/cunit/cu_algorithm.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 liblwgeom/lwgeom.c             | 18 +++++++++++++-----
 regress/core/mvt.sql           |  6 +++---
 regress/core/mvt_expected      |  2 +-
 5 files changed, 60 insertions(+), 9 deletions(-)


hooks/post-receive
-- 
PostGIS; Spatial objects for PostgreSQL.


More information about the postgis-tickets mailing list