[postgis-tickets] [SCM] PostGIS branch stable-3.2 updated. 3.2.4-18-gfa7823d87

git at osgeo.org git at osgeo.org
Mon Apr 24 20:56:58 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.2 has been updated
       via  fa7823d8786cec471f12e304acdc3af33d189718 (commit)
      from  b782d025f08cd88605f8cb00a3e07fa278396244 (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 fa7823d8786cec471f12e304acdc3af33d189718
Author: Regina Obe <lr at pcorp.us>
Date:   Fri Apr 21 01:35:05 2023 -0400

    Change gdal polygonize tests to be sum of areas and values
    instead of checking individual elements.
    This is to account for GDAL 3.7 results array sorted in different order
    from prior versions.
    References #5366 for PostGIS 3.2.5

diff --git a/raster/test/cunit/cu_gdal.c b/raster/test/cunit/cu_gdal.c
index 54daa3ebd..c20da3b43 100644
--- a/raster/test/cunit/cu_gdal.c
+++ b/raster/test/cunit/cu_gdal.c
@@ -155,6 +155,8 @@ 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;
 	//char *wkt = NULL;
@@ -166,32 +168,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++) {
+		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 +191,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 +215,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 +239,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 +263,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 | 175 +++++++++++++-------------------------------
 1 file changed, 50 insertions(+), 125 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list