[SCM] PostGIS branch master updated. 3.5.0-443-gb077696e7

git at osgeo.org git at osgeo.org
Thu Jul 10 14:06:02 PDT 2025


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  b077696e7f0cad9361be3d43392a340d77365643 (commit)
      from  1f78fc9da37ec4cfc1ccf8115a0f977aaeb7b1ae (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 b077696e7f0cad9361be3d43392a340d77365643
Author: Paul Ramsey <paul.ramsey at snowflake.com>
Date:   Thu Jul 10 14:04:50 2025 -0700

    Update raster module to work with new GDT_Int8
    pixel type in GDAL 3.7+.
    https://trac.osgeo.org/postgis/ticket/5901

diff --git a/loader/cunit/Makefile.in b/loader/cunit/Makefile.in
index 33a115d0e..ab9e8d791 100644
--- a/loader/cunit/Makefile.in
+++ b/loader/cunit/Makefile.in
@@ -20,7 +20,7 @@ CFLAGS=@CFLAGS@
 SHELL = @SHELL@
 LIBTOOL = @LIBTOOL@
 
-CUNIT_LDFLAGS=@CUNIT_LDFLAGS@
+CUNIT_LDFLAGS=@CUNIT_LDFLAGS@ @GEOS_LDFLAGS@
 CUNIT_CPPFLAGS = \
 	-I$(srcdir)/.. \
 	-I$(top_builddir)/liblwgeom \
diff --git a/raster/rt_core/rt_raster.c b/raster/rt_core/rt_raster.c
index d98591a86..99578fe87 100644
--- a/raster/rt_core/rt_raster.c
+++ b/raster/rt_core/rt_raster.c
@@ -1958,7 +1958,9 @@ rt_raster_to_gdal_mem(
 		/*
 			For all pixel types other than PT_8BSI, set pointer to start of data
 		*/
+#if POSTGIS_GDAL_VERSION < 30700
 		if (pt != PT_8BSI) {
+#endif
 			pVoid = rt_band_get_data(rtband);
 			RASTER_DEBUGF(4, "Band data is at pos %p", pVoid);
 
@@ -1989,12 +1991,12 @@ rt_raster_to_gdal_mem(
 				GDALClose(ds);
 				return 0;
 			}
-		}
+#if POSTGIS_GDAL_VERSION < 30700
 		/*
-			PT_8BSI is special as GDAL has no equivalent pixel type.
+			PT_8BSI is special as GDAL (prior to 3.7) has no equivalent pixel type.
 			Must convert 8BSI to 16BSI so create basic band
 		*/
-		else {
+		} else {
 			/* add band */
 			if (GDALAddBand(ds, gdal_pt, NULL) == CE_Failure) {
 				rterror("rt_raster_to_gdal_mem: Could not add GDAL raster band");
@@ -2004,6 +2006,7 @@ rt_raster_to_gdal_mem(
 				return 0;
 			}
 		}
+#endif
 
 		/* check band count */
 		if (GDALGetRasterCount(ds) != i + 1) {
@@ -2025,6 +2028,8 @@ rt_raster_to_gdal_mem(
 			return 0;
 		}
 
+#if POSTGIS_GDAL_VERSION < 30700
+
 		/* PT_8BSI requires manual setting of pixels */
 		if (pt == PT_8BSI) {
 			uint32_t nXBlocks, nYBlocks;
@@ -2120,6 +2125,7 @@ rt_raster_to_gdal_mem(
 
 			rtdealloc(values);
 		}
+#endif
 
 		/* Add nodata value for band */
 		if (rt_band_get_hasnodata_flag(rtband) != FALSE && excludeNodataValues[i]) {
diff --git a/raster/rt_core/rt_util.c b/raster/rt_core/rt_util.c
index 9c6a14a9b..e3e1f5415 100644
--- a/raster/rt_core/rt_util.c
+++ b/raster/rt_core/rt_util.c
@@ -129,6 +129,9 @@ rt_util_pixtype_to_gdal_datatype(rt_pixtype pt) {
 		case PT_8BUI:
 			return GDT_Byte;
 		case PT_8BSI:
+#if POSTGIS_GDAL_VERSION >= 30700
+			return GDT_Int8;
+#endif
 		case PT_16BSI:
 			return GDT_Int16;
 		case PT_16BUI:
@@ -160,6 +163,10 @@ rt_util_gdal_datatype_to_pixtype(GDALDataType gdt) {
 	switch (gdt) {
 		case GDT_Byte:
 			return PT_8BUI;
+#if POSTGIS_GDAL_VERSION >= 30700
+		case GDT_Int8:
+			return PT_8BSI;
+#endif
 		case GDT_UInt16:
 			return PT_16BUI;
 		case GDT_Int16:
diff --git a/raster/scripts/python/pixval.py b/raster/scripts/python/pixval.py
index 0477a5019..644e1aec6 100755
--- a/raster/scripts/python/pixval.py
+++ b/raster/scripts/python/pixval.py
@@ -31,6 +31,7 @@ import sys
 def pt2fmt(pt):
     fmttypes = {
         gdalc.GDT_Byte: 'B',
+        gdalc.GDT_Int8: 'B',
         gdalc.GDT_Int16: 'h',
         gdalc.GDT_UInt16: 'H',
         gdalc.GDT_Int32: 'i',
diff --git a/raster/scripts/python/raster2pgsql.py b/raster/scripts/python/raster2pgsql.py
index c76b1d7e2..c6401f925 100755
--- a/raster/scripts/python/raster2pgsql.py
+++ b/raster/scripts/python/raster2pgsql.py
@@ -214,6 +214,7 @@ def gdt2pt(gdt):
     """Translate GDAL data type to WKT Raster pixel type."""
     pixtypes = {
         gdalc.GDT_Byte    : { 'name': 'PT_8BUI',  'id':  4 },
+        gdalc.GDT_Int8    : { 'name': 'PT_8BSI',  'id':  3 },
         gdalc.GDT_Int16   : { 'name': 'PT_16BSI', 'id':  5 },
         gdalc.GDT_UInt16  : { 'name': 'PT_16BUI', 'id':  6 },
         gdalc.GDT_Int32   : { 'name': 'PT_32BSI', 'id':  7 },
diff --git a/raster/test/cunit/cu_gdal.c b/raster/test/cunit/cu_gdal.c
index d338dcf42..421bf93f3 100644
--- a/raster/test/cunit/cu_gdal.c
+++ b/raster/test/cunit/cu_gdal.c
@@ -384,7 +384,6 @@ static void test_gdal_to_raster() {
 
 	gdds = rt_raster_to_gdal_mem(raster, NULL, NULL, NULL, 0, &gddrv, &destroy);
 	CU_ASSERT(gddrv != NULL);
-	CU_ASSERT_EQUAL(destroy, 0);
 	CU_ASSERT(gdds != NULL);
 	CU_ASSERT_EQUAL((uint32_t)GDALGetRasterXSize(gdds), width);
 	CU_ASSERT_EQUAL((uint32_t)GDALGetRasterYSize(gdds), height);
@@ -404,6 +403,10 @@ static void test_gdal_to_raster() {
 		}
 	}
 
+	if (destroy && gddrv) {
+		GDALDeregisterDriver(gddrv);
+		GDALDestroyDriver(gddrv);
+	}
 	GDALClose(gdds);
 	gdds = NULL;
 	gddrv = NULL;
@@ -430,7 +433,6 @@ static void test_gdal_to_raster() {
 
 	gdds = rt_raster_to_gdal_mem(raster, NULL, NULL, NULL, 0, &gddrv, &destroy);
 	CU_ASSERT(gddrv != NULL);
-	CU_ASSERT_EQUAL(destroy, 0);
 	CU_ASSERT(gdds != NULL);
 	CU_ASSERT_EQUAL((uint32_t)GDALGetRasterXSize(gdds), width);
 	CU_ASSERT_EQUAL((uint32_t)GDALGetRasterYSize(gdds), height);
@@ -441,15 +443,27 @@ static void test_gdal_to_raster() {
 
 	band = rt_raster_get_band(rast, 0);
 	CU_ASSERT(band != NULL);
+#if POSTGIS_GDAL_VERSION < 30700
 	CU_ASSERT_EQUAL(rt_band_get_pixtype(band), PT_16BSI);
-
+#else
+	CU_ASSERT_EQUAL(rt_band_get_pixtype(band), PT_8BSI);
+#endif
 	for (x = 0; x < width; x++) {
 		for (y = 0; y < height; y++) {
 			rtn = rt_band_get_pixel(band, x, y, &value, NULL);
- 			CU_ASSERT_EQUAL(rtn, ES_NONE);
+#if POSTGIS_GDAL_VERSION < 30700
 			CU_ASSERT_DOUBLE_EQUAL(value, values[x][y], 1.);
+			CU_ASSERT_DOUBLE_EQUAL(value, values[x][y], DBL_EPSILON);
+#else
+ 			CU_ASSERT_EQUAL(rtn, ES_NONE);
+			CU_ASSERT_DOUBLE_EQUAL(value, values[x][y], DBL_EPSILON);
+#endif
 		}
 	}
+	if (destroy && gddrv) {
+		GDALDeregisterDriver(gddrv);
+		GDALDestroyDriver(gddrv);
+	}
 
 	GDALClose(gdds);
 	gdds = NULL;

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

Summary of changes:
 loader/cunit/Makefile.in              |  2 +-
 raster/rt_core/rt_raster.c            | 12 +++++++++---
 raster/rt_core/rt_util.c              |  7 +++++++
 raster/scripts/python/pixval.py       |  1 +
 raster/scripts/python/raster2pgsql.py |  1 +
 raster/test/cunit/cu_gdal.c           | 22 ++++++++++++++++++----
 6 files changed, 37 insertions(+), 8 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list