[SCM] PostGIS branch master updated. 3.7.0beta1-111-gf7ee000308
git at osgeo.org
git at osgeo.org
Mon Jul 27 23:49:34 PDT 2026
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 f7ee000308768c13e9d5089ecff820adad2a8181 (commit)
via 11fd50a4e56c73a587402ccc7f408b4c425e0be8 (commit)
from dfe37406b35cac730494ff933ff603172f9bb51c (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 f7ee000308768c13e9d5089ecff820adad2a8181
Merge: dfe37406b3 11fd50a4e5
Author: Darafei Praliaskouski <komzpa at gmail.com>
Date: Mon Jul 27 23:49:33 2026 -0700
Merge pull request '[raster] Preserve integer values in ST_DumpAsPolygons' (!586) from Komzpa/postgis:codex/trac-3776-20260728 into master
`ST_DumpAsPolygons` merges distinct adjacent `32BUI` values once they cross the reported threshold because all raster bands are currently polygonized through GDAL's floating-point path. Values `1048576` and `1048577`, although stored distinctly, therefore produce one polygon.
Use `GDALPolygonize` for integer pixel types so their values remain exact, while retaining `GDALFPolygonize` for floating-point bands. Add regression coverage on both sides of the threshold and record the fix in `NEWS`.
Closes https://trac.osgeo.org/postgis/ticket/3776
Reviewed-on: https://gitea.osgeo.org/postgis/postgis/pulls/586
commit 11fd50a4e56c73a587402ccc7f408b4c425e0be8
Author: Darafei Praliaskouski <me at komzpa.net>
Date: Tue Jul 28 08:09:45 2026 +0400
[raster] Preserve integer values in ST_DumpAsPolygons
diff --git a/NEWS b/NEWS
index 43aa95bd86..c38a587886 100644
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,8 @@ These are only changes since 3.7.0beta1.
big-endian platforms (Darafei Praliaskouski)
- [raster] Fix invalid reads in raster band initialization and
geotransform property access (Darafei Praliaskouski)
+ - #3776, [raster] Keep distinct 32-bit integer pixel values separate in
+ ST_DumpAsPolygons (Darafei Praliaskouski)
- GT-504, Report extension script/library version mismatches before loading
functions unavailable in an older library (Darafei Praliaskouski)
- GT-515, Reject invalid ST_LargestEmptyCircle boundaries before GEOS can
diff --git a/raster/rt_core/rt_geometry.c b/raster/rt_core/rt_geometry.c
index 70d815c69b..1eb2b87f67 100644
--- a/raster/rt_core/rt_geometry.c
+++ b/raster/rt_core/rt_geometry.c
@@ -1000,6 +1000,7 @@ rt_raster_gdal_polygonize(
double dValue = 0.0;
int iBandHasNodataValue = FALSE;
double dBandNoData = 0.0;
+ rt_pixtype pixtype = PT_END;
uint32_t bandNums[1] = {nband};
int excludeNodataValues[1] = {exclude_nodata_value};
@@ -1020,6 +1021,7 @@ rt_raster_gdal_polygonize(
rterror("rt_raster_gdal_polygonize: Error getting band %d from raster", nband);
return NULL;
}
+ pixtype = rt_band_get_pixtype(band);
if (exclude_nodata_value) {
@@ -1141,12 +1143,22 @@ rt_raster_gdal_polygonize(
* unwind promptly when PostgreSQL requests cancellation (#4222).
* Use the band's nodata mask so large/infinite nodata values are excluded
* before polygonizing, bypassing the broken %f string-format filter (#6010).
+ * Polygonize integer bands through GDAL's integer buffer so nearby large
+ * values do not coalesce in GDALFPolygonize's Float32 buffer (#3776).
*/
GDALRasterBandH mask_band = iBandHasNodataValue
? GDALGetMaskBand(gdal_band)
: NULL;
- cplerr = GDALFPolygonize(
- gdal_band, mask_band, hLayer, iPixVal, NULL, rt_util_gdal_progress_func, (void *)"GDALFPolygonize");
+ if (pixtype == PT_16BF || pixtype == PT_32BF || pixtype == PT_64BF)
+ {
+ cplerr = GDALFPolygonize(
+ gdal_band, mask_band, hLayer, iPixVal, NULL, rt_util_gdal_progress_func, (void *)"GDALFPolygonize");
+ }
+ else
+ {
+ cplerr = GDALPolygonize(
+ gdal_band, mask_band, hLayer, iPixVal, NULL, rt_util_gdal_progress_func, (void *)"GDALPolygonize");
+ }
if (cplerr != CE_None) {
rterror("rt_raster_gdal_polygonize: Could not polygonize GDAL band");
@@ -1276,4 +1288,3 @@ rt_raster_gdal_polygonize(
return pols;
}
-
diff --git a/raster/test/regress/rt_polygon.sql b/raster/test/regress/rt_polygon.sql
index ea1e3461d1..ea3bc37a07 100644
--- a/raster/test/regress/rt_polygon.sql
+++ b/raster/test/regress/rt_polygon.sql
@@ -165,3 +165,22 @@ SELECT count(*) = 1 FROM ST_DumpAsPolygons(
ST_AddBand(ST_MakeEmptyRaster(3, 3, 0, 0, 1, -1, 0, 0, 0),
1, '64BF'::text, -9.0, 1.7976931348623157e+308),
1, 2, 2, 1.7976931348623157e+308));
+
+-- #3776: integer values on either side of 2^20 must not be grouped together
+WITH r AS (
+ SELECT ST_SetValue(
+ ST_AddBand(ST_MakeEmptyRaster(1, 2, 0, 0, 1), '32BUI'::text, 1048575),
+ 1, 1, 1, 1048576) AS rast
+)
+SELECT '#3776.before', count(*), count(DISTINCT val), array_agg(val ORDER BY val)
+FROM r
+CROSS JOIN LATERAL ST_DumpAsPolygons(r.rast) AS gv;
+
+WITH r AS (
+ SELECT ST_SetValue(
+ ST_AddBand(ST_MakeEmptyRaster(1, 2, 0, 0, 1), '32BUI'::text, 1048576),
+ 1, 1, 1, 1048577) AS rast
+)
+SELECT '#3776.after', count(*), count(DISTINCT val), array_agg(val ORDER BY val)
+FROM r
+CROSS JOIN LATERAL ST_DumpAsPolygons(r.rast) AS gv;
diff --git a/raster/test/regress/rt_polygon_expected b/raster/test/regress/rt_polygon_expected
index 22ec3b7199..9c67e7530d 100644
--- a/raster/test/regress/rt_polygon_expected
+++ b/raster/test/regress/rt_polygon_expected
@@ -7,3 +7,5 @@ t
t
t
t
+#3776.before|2|2|{1048575,1048576}
+#3776.after|2|2|{1048576,1048577}
-----------------------------------------------------------------------
Summary of changes:
NEWS | 2 ++
raster/rt_core/rt_geometry.c | 17 ++++++++++++++---
raster/test/regress/rt_polygon.sql | 19 +++++++++++++++++++
raster/test/regress/rt_polygon_expected | 2 ++
4 files changed, 37 insertions(+), 3 deletions(-)
hooks/post-receive
--
PostGIS
More information about the postgis-tickets
mailing list