[postgis-tickets] [SCM] PostGIS branch stable-3.0 updated. 3.0.9-4-gf7d951505

git at osgeo.org git at osgeo.org
Wed Jun 21 23:32:22 PDT 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, stable-3.0 has been updated
       via  f7d951505d6f0ef1d19e15138fecb7ae2eab5e89 (commit)
      from  9c9e56a4c21fd7085a16b50312ca4fdad21aa074 (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 f7d951505d6f0ef1d19e15138fecb7ae2eab5e89
Author: Regina Obe <lr at pcorp.us>
Date:   Thu Jun 22 02:30:46 2023 -0400

    Make gdal polygonize behave consistently
    across all GDAL versions (behavior changed in GDAL 3.7)
    Closes #5366 for PostGIS 3.0.10

diff --git a/raster/test/cunit/cu_gdal.c b/raster/test/cunit/cu_gdal.c
index 54daa3ebd..a0146e34c 100644
--- a/raster/test/cunit/cu_gdal.c
+++ b/raster/test/cunit/cu_gdal.c
@@ -155,43 +155,29 @@ static void test_gdal_polygonize() {
 	int i;
 	rt_raster rt;
 	int nPols = 0;
+	double total_area = 0;
+	double total_val = 0;
 	rt_geomval gv = NULL;
-	LWGEOM *gexpected, *gobserved;
+	LWGEOM *gobserved;
 	//char *wkt = NULL;
-	gexpected = lwgeom_from_wkt("POLYGON((3 1,3 2,2 2,2 3,1 3,1 6,2 6,2 7,3 7,3 8,5 8,5 6,3 6,3 3,4 3,5 3,5 1,3 1))",
-				   LW_PARSER_CHECK_NONE);
 
 	rt = fillRasterToPolygonize(1, -1.0);
 	CU_ASSERT(rt_raster_has_band(rt, 0));
 
 	nPols = 0;
 	gv = rt_raster_gdal_polygonize(rt, 0, TRUE, &nPols);
+	CU_ASSERT_DOUBLE_EQUAL(nPols, 4, FLT_EPSILON);
+		total_area = 0; total_val = 0;
+	for (i = 0; i < nPols; i++) {
+		total_val += gv[i].val;
+		gobserved = (LWGEOM *) gv[i].geom;
+		total_area += lwgeom_area(gobserved);
+		lwgeom_free((LWGEOM *) gv[i].geom);
+	}
+	printf("total area, total val, nPols  = %f, %f, %i\n", total_area, total_val, nPols);
+	CU_ASSERT_DOUBLE_EQUAL(total_val, 1.8 + 0.0 + 2.8 + 0, FLT_EPSILON);
+	CU_ASSERT_DOUBLE_EQUAL(total_area, 81, FLT_EPSILON);
 
-	CU_ASSERT_DOUBLE_EQUAL(gv[0].val, 1.8, FLT_EPSILON);
-
-	gobserved = (LWGEOM *)gv[0].geom;
-
-	CU_ASSERT_DOUBLE_EQUAL(lwgeom_area(gobserved), lwgeom_area(gexpected), FLT_EPSILON);
-
-	CU_ASSERT_DOUBLE_EQUAL(gv[1].val, 0.0, FLT_EPSILON);
-	gobserved = (LWGEOM *)gv[1].geom;
-	gexpected = lwgeom_from_wkt("POLYGON((3 3,3 6,6 6,6 3,3 3))", LW_PARSER_CHECK_NONE);
-	CU_ASSERT_DOUBLE_EQUAL(lwgeom_area(gobserved), lwgeom_area(gexpected), FLT_EPSILON );
-
-	CU_ASSERT_DOUBLE_EQUAL(gv[2].val, 2.8, FLT_EPSILON);
-	gobserved = (LWGEOM *)gv[2].geom;
-	gexpected = lwgeom_from_wkt("POLYGON((5 1,5 3,6 3,6 6,5 6,5 8,6 8,6 7,7 7,7 6,8 6,8 3,7 3,7 2,6 2,6 1,5 1))",
-				    LW_PARSER_CHECK_NONE);
-	CU_ASSERT_DOUBLE_EQUAL(lwgeom_area(gobserved), lwgeom_area(gexpected), FLT_EPSILON);
-
-	gobserved = (LWGEOM *)gv[3].geom;
-	gexpected = lwgeom_from_wkt(
-	    "POLYGON((0 0,0 9,9 9,9 0,0 0),(6 7,6 8,3 8,3 7,2 7,2 6,1 6,1 3,2 3,2 2,3 2,3 1,6 1,6 2,7 2,7 3,8 3,8 6,7 6,7 7,6 7))",
-	    LW_PARSER_CHECK_NONE);
-	CU_ASSERT_DOUBLE_EQUAL(gv[3].val, 0.0, FLT_EPSILON);
-	CU_ASSERT_DOUBLE_EQUAL(lwgeom_area(gobserved), lwgeom_area(gexpected), FLT_EPSILON);
-
-	for (i = 0; i < nPols; i++) lwgeom_free((LWGEOM *) gv[i].geom);
 	rtdealloc(gv);
 	cu_free_raster(rt);
 
@@ -203,40 +189,19 @@ static void test_gdal_polygonize() {
 
 	nPols = 0;
 	gv = rt_raster_gdal_polygonize(rt, 0, TRUE, &nPols);
-
-	/*
+	CU_ASSERT_DOUBLE_EQUAL(nPols, 4, FLT_EPSILON);
+	total_area = 0; total_val = 0;
 	for (i = 0; i < nPols; i++) {
-		wkt = lwgeom_to_text((const LWGEOM *) gv[i].geom);
-		printf("(i, val, geom) = (%d, %f, %s)\n", i, gv[i].val, wkt);
-		rtdealloc(wkt);
+		total_val += gv[i].val;
+		gobserved = (LWGEOM *) gv[i].geom;
+		total_area += lwgeom_area(gobserved);
+		lwgeom_free((LWGEOM *) gv[i].geom);
 	}
-	*/
+	printf("total area, total_val, polys = %f, %f, %i\n", total_area, total_val, nPols);
+	CU_ASSERT_DOUBLE_EQUAL(total_val, 4.6, FLT_EPSILON);
+	CU_ASSERT_DOUBLE_EQUAL(total_area, 81, FLT_EPSILON);
+
 
-	CU_ASSERT_DOUBLE_EQUAL(gv[1].val, 0.0, FLT_EPSILON);
-	gobserved = (LWGEOM *)gv[1].geom;
-	gexpected = lwgeom_from_wkt("POLYGON((3 3,3 6,6 6,6 3,3 3))", LW_PARSER_CHECK_NONE);
-	CU_ASSERT_DOUBLE_EQUAL(lwgeom_area(gobserved), lwgeom_area(gexpected), FLT_EPSILON);
-	//wkt = lwgeom_to_text((const LWGEOM *) gv[1].geom);
-	//CU_ASSERT_STRING_EQUAL(wkt, "POLYGON((3 3,3 6,6 6,6 3,3 3))");
-	//rtdealloc(wkt);
-
-	CU_ASSERT_DOUBLE_EQUAL(gv[2].val, 2.8, FLT_EPSILON);
-	gobserved = (LWGEOM *)gv[2].geom;
-	gexpected = lwgeom_from_wkt("POLYGON((5 1,5 3,6 3,6 6,5 6,5 8,6 8,6 7,7 7,7 6,8 6,8 3,7 3,7 2,6 2,6 1,5 1))",
-				    LW_PARSER_CHECK_NONE);
-	CU_ASSERT_DOUBLE_EQUAL(lwgeom_area(gobserved), lwgeom_area(gexpected), FLT_EPSILON);
-	//wkt = lwgeom_to_text((const LWGEOM *) gv[2].geom);
-	//CU_ASSERT_STRING_EQUAL(wkt, "POLYGON((5 1,5 3,6 3,6 6,5 6,5 8,6 8,6 7,7 7,7 6,8 6,8 3,7 3,7 2,6 2,6 1,5 1))");
-	//rtdealloc(wkt);
-
-	CU_ASSERT_DOUBLE_EQUAL(gv[3].val, 0.0, FLT_EPSILON);
-	gobserved = (LWGEOM *)gv[3].geom;
-	gexpected = lwgeom_from_wkt(
-	    "POLYGON((0 0,0 9,9 9,9 0,0 0),(6 7,6 8,3 8,3 7,2 7,2 6,1 6,1 3,2 3,2 2,3 2,3 1,6 1,6 2,7 2,7 3,8 3,8 6,7 6,7 7,6 7))",
-	    LW_PARSER_CHECK_NONE);
-	CU_ASSERT_DOUBLE_EQUAL(lwgeom_area(gobserved), lwgeom_area(gexpected), FLT_EPSILON);
-
-	for (i = 0; i < nPols; i++) lwgeom_free((LWGEOM *) gv[i].geom);
 	rtdealloc(gv);
 	cu_free_raster(rt);
 
@@ -248,33 +213,19 @@ static void test_gdal_polygonize() {
 
 	nPols = 0;
 	gv = rt_raster_gdal_polygonize(rt, 0, TRUE, &nPols);
-
-	/*
+	CU_ASSERT_DOUBLE_EQUAL(nPols, 4, FLT_EPSILON);
+	total_area = 0; total_val = 0;
 	for (i = 0; i < nPols; i++) {
-		wkt = lwgeom_to_text((const LWGEOM *) gv[i].geom);
-		printf("(i, val, geom) = (%d, %f, %s)\n", i, gv[i].val, wkt);
-		rtdealloc(wkt);
+		total_val += gv[i].val;
+		gobserved = (LWGEOM *) gv[i].geom;
+		total_area += lwgeom_area(gobserved);
+		lwgeom_free((LWGEOM *) gv[i].geom);
 	}
-	*/
-
-	CU_ASSERT_DOUBLE_EQUAL(gv[3].val, 0.0, FLT_EPSILON);
-	gobserved = (LWGEOM *)gv[3].geom;
-	gexpected = lwgeom_from_wkt(
-	    "POLYGON((0 0,0 9,9 9,9 0,0 0),(6 7,6 8,3 8,3 7,2 7,2 6,1 6,1 3,2 3,2 2,3 2,3 1,6 1,6 2,7 2,7 3,8 3,8 6,7 6,7 7,6 7))",
-	    LW_PARSER_CHECK_NONE);
-	CU_ASSERT_DOUBLE_EQUAL(lwgeom_area(gobserved), lwgeom_area(gexpected), FLT_EPSILON);
-
-	gobserved = (LWGEOM *)gv[0].geom;
-	gexpected = lwgeom_from_wkt(
-	    "POLYGON((3 1,3 2,2 2,2 3,1 3,1 6,2 6,2 7,3 7,3 8,5 8,5 6,3 6,3 3,4 3,5 3,5 1,3 1))", LW_PARSER_CHECK_NONE);
-	CU_ASSERT_DOUBLE_EQUAL(lwgeom_area(gobserved), lwgeom_area(gexpected), FLT_EPSILON);
 
-	CU_ASSERT_DOUBLE_EQUAL(gv[1].val, 0.0, FLT_EPSILON);
-	gobserved = (LWGEOM *)gv[1].geom;
-	gexpected = lwgeom_from_wkt("POLYGON((3 3,3 6,6 6,6 3,3 3))", LW_PARSER_CHECK_NONE);
-	CU_ASSERT_DOUBLE_EQUAL(lwgeom_area(gobserved), lwgeom_area(gexpected), FLT_EPSILON);
+	printf("total area, total_val, polys = %f, %f, %i\n", total_area, total_val, nPols);
+	CU_ASSERT_DOUBLE_EQUAL(total_val, 4.6, FLT_EPSILON);
+	CU_ASSERT_DOUBLE_EQUAL(total_area, 81, FLT_EPSILON);
 
-	for (i = 0; i < nPols; i++) lwgeom_free((LWGEOM *) gv[i].geom);
 	rtdealloc(gv);
 	cu_free_raster(rt);
 
@@ -286,26 +237,19 @@ static void test_gdal_polygonize() {
 	nPols = 0;
 	gv = rt_raster_gdal_polygonize(rt, 0, TRUE, &nPols);
 
-	/*
+	CU_ASSERT_DOUBLE_EQUAL(nPols, 2, FLT_EPSILON);
+	total_area = 0; total_val = 0;
 	for (i = 0; i < nPols; i++) {
-		wkt = lwgeom_to_text((const LWGEOM *) gv[i].geom);
-		printf("(i, val, geom) = (%d, %f, %s)\n", i, gv[i].val, wkt);
-		rtdealloc(wkt);
+		total_val += gv[i].val;
+		gobserved = (LWGEOM *) gv[i].geom;
+		total_area += lwgeom_area(gobserved);
+		lwgeom_free((LWGEOM *) gv[i].geom);
 	}
-	*/
-
-	CU_ASSERT_DOUBLE_EQUAL(gv[0].val, 1.8, FLT_EPSILON);
-	gobserved = (LWGEOM *)gv[0].geom;
-	gexpected = lwgeom_from_wkt("POLYGON((3 1,3 2,2 2,2 3,1 3,1 6,2 6,2 7,3 7,3 8,5 8,5 6,3 6,3 3,4 3,5 3,5 1,3 1))", LW_PARSER_CHECK_NONE);
-	CU_ASSERT_DOUBLE_EQUAL(lwgeom_area(gobserved), lwgeom_area(gexpected), FLT_EPSILON);
 
-	CU_ASSERT_DOUBLE_EQUAL(gv[1].val, 2.8, FLT_EPSILON);
-	gobserved = (LWGEOM *)gv[1].geom;
-	gexpected = lwgeom_from_wkt("POLYGON((5 1,5 3,6 3,6 6,5 6,5 8,6 8,6 7,7 7,7 6,8 6,8 3,7 3,7 2,6 2,6 1,5 1))",
-				    LW_PARSER_CHECK_NONE);
-	CU_ASSERT_DOUBLE_EQUAL(lwgeom_area(gobserved), lwgeom_area(gexpected), FLT_EPSILON);
+	printf("total area, total_val, polys = %f, %f, %i\n", total_area, total_val, nPols);
+	CU_ASSERT_DOUBLE_EQUAL(total_val, 4.6, FLT_EPSILON);
+	CU_ASSERT_DOUBLE_EQUAL(total_area, 28, FLT_EPSILON);
 
-	for (i = 0; i < nPols; i++) lwgeom_free((LWGEOM *) gv[i].geom);
 	rtdealloc(gv);
 	cu_free_raster(rt);
 
@@ -317,39 +261,18 @@ static void test_gdal_polygonize() {
 	nPols = 0;
 	gv = rt_raster_gdal_polygonize(rt, 0, TRUE, &nPols);
 
-	/*
+	CU_ASSERT_DOUBLE_EQUAL(nPols, 4, FLT_EPSILON);
+	total_area = 0; total_val = 0;
 	for (i = 0; i < nPols; i++) {
-		wkt = lwgeom_to_text((const LWGEOM *) gv[i].geom);
-		printf("(i, val, geom) = (%d, %f, %s)\n", i, gv[i].val, wkt);
-		rtdealloc(wkt);
+		total_val += gv[i].val;
+		gobserved = (LWGEOM *) gv[i].geom;
+		total_area += lwgeom_area(gobserved);
+		lwgeom_free((LWGEOM *) gv[i].geom);
 	}
-	*/
 
-	CU_ASSERT_DOUBLE_EQUAL(gv[0].val, 1.8, FLT_EPSILON);
-	gobserved = (LWGEOM *)gv[0].geom;
-	gexpected = lwgeom_from_wkt(
-	    "POLYGON((3 1,3 2,2 2,2 3,1 3,1 6,2 6,2 7,3 7,3 8,5 8,5 6,3 6,3 3,4 3,5 3,5 1,3 1))", LW_PARSER_CHECK_NONE);
-	CU_ASSERT_DOUBLE_EQUAL(lwgeom_area(gobserved), lwgeom_area(gexpected), FLT_EPSILON);
-
-	CU_ASSERT_DOUBLE_EQUAL(gv[1].val, 0.0, FLT_EPSILON);
-	gobserved = (LWGEOM *)gv[1].geom;
-	gexpected = lwgeom_from_wkt("POLYGON((3 3,3 6,6 6,6 3,3 3))", LW_PARSER_CHECK_NONE);
-	CU_ASSERT_DOUBLE_EQUAL(lwgeom_area(gobserved), lwgeom_area(gexpected), FLT_EPSILON);
-
-	CU_ASSERT_DOUBLE_EQUAL(gv[2].val, 2.8, FLT_EPSILON);
-	gobserved = (LWGEOM *)gv[2].geom;
-	gexpected = lwgeom_from_wkt("POLYGON((5 1,5 3,6 3,6 6,5 6,5 8,6 8,6 7,7 7,7 6,8 6,8 3,7 3,7 2,6 2,6 1,5 1))",
-				    LW_PARSER_CHECK_NONE);
-	CU_ASSERT_DOUBLE_EQUAL(lwgeom_area(gobserved), lwgeom_area(gexpected), FLT_EPSILON);
-
-	CU_ASSERT_DOUBLE_EQUAL(gv[3].val, 0.0, FLT_EPSILON);
-	gobserved = (LWGEOM *)gv[3].geom;
-	gexpected = lwgeom_from_wkt(
-	    "POLYGON((0 0,0 9,9 9,9 0,0 0),(6 7,6 8,3 8,3 7,2 7,2 6,1 6,1 3,2 3,2 2,3 2,3 1,6 1,6 2,7 2,7 3,8 3,8 6,7 6,7 7,6 7))",
-	    LW_PARSER_CHECK_NONE);
-	CU_ASSERT_DOUBLE_EQUAL(lwgeom_area(gobserved), lwgeom_area(gexpected), FLT_EPSILON);
-
-	for (i = 0; i < nPols; i++) lwgeom_free((LWGEOM *) gv[i].geom);
+	printf("total area, total_val, polys = %f, %f, %i\n", total_area, total_val, nPols);
+	CU_ASSERT_DOUBLE_EQUAL(total_val, 1.8 + 0.0 + 2.8 + 0.0, FLT_EPSILON);
+	CU_ASSERT_DOUBLE_EQUAL(total_area, 81, FLT_EPSILON);
 	rtdealloc(gv);
 	cu_free_raster(rt);
 }

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

Summary of changes:
 raster/test/cunit/cu_gdal.c | 179 +++++++++++++-------------------------------
 1 file changed, 51 insertions(+), 128 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list